Apply from in a subprojects with java plugin filter

Hi,

I’ve created a task that depends on the ‘jar’ task. Then I made it available to all subprojects with a java plugin enabled like:

subprojects {

        plugins.withType(JavaPlugin) {
            task javaDist(dependsOn: 'jar') { }
        }
}

It works fine, but i wanted to move it into the separate script, so I’ve made a corrections:

subprojects {

        plugins.withType(JavaPlugin) {
            apply from: "$rootDir/buildSrc/unemDist.gradle"
        }
}

And I am getting the following error:

* What went wrong:
A problem occurred evaluating project ':bp'.
> Failed to apply plugin [id 'org.gradle.java']
   > java.util.LinkedHashMap cannot be cast to org.gradle.api.internal.project.ProjectInternal

If I move the ‘apply from’ outside the filtering closure it works fine.

Thanks !

Hi @deepres,

I am hitting the same issue. Have you been able to solve it?

Thank you in advance for any info,
M.

Unfortunately not, I am using inline tasks.

@deepres and @marmax, I ran into the same issue and found that changing apply from: to project.apply from: fixes the problem.