Define task in apply from script

I’m trying to define a task in a script included with apply from

task uploadBom (type: io.github.httpbuilderng.http.HttpTask) {

But this yields the error Could not get unknown property 'io' for root project 'gradle-java' of type org.gradle.api.Project.

If I move this task up to build.gradle it compiles fine.

I have been able to define tasks without a type this way, but this one with a type. Is there some other syntax that is required. Or is there something special about scripts included with apply from?

Your included script has a different classloader to build.gradle. You can do this:


ext {
   HttpTask = io.github.httpbuilderng.http.HttpTask
apply from: 'other.gradle'


task uploadBom (type: HttpTask) {...} 

Another option is to repeat the buildscript {...} dependencies in other.gradle