Deprecation of configureForSourceSet

I have noted the following deprecation message introduced
in 4.0, however not mentioned in the release notes.

The configureForSourceSet(SourceSet, AbstractCompile) method has been deprecated and is scheduled to be removed in Gradle 5.0.

The method in question is https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/JavaBasePlugin.html#configureForSourceSet(org.gradle.api.tasks.SourceSet,%20org.gradle.api.tasks.compile.AbstractCompile) and I suspect are used in a number of third-party language plugins. This is probably not a trivial migration to those maintainers.

What is the new appraoch here? Are there better APIs available since 4.0 for implementing JVM language plugins?

From looking at the Gradle source, usage of configureForSourceSet has been replaced by calling an internal API SourceSetUtils.configureForSourceSet. This is not a feasible solution for plugin developers.

has this been fixed? I have a plugin I need to upgrade and no idea how to do it and it uses that method too?

thanks,
Dean

oh, I am on https://services.gradle.org/distributions/gradle-4.8.1-bin.zip release so not sure if I need to be on a certain release where there is a public method I can use before the upgrade to 5.0?

I need to get it working before 5.0 or end up in a circular issue since my build uses the plugin it also creates…lol…sort of like eating my own medicine BUT it causes issues were I need replacements exposed before the previous methods are removed.

It definitely has been removed.

AFAIK you know have to resort to doing more work yourself. Firstly by calling

project.convention.getPlugin(JavaPluginConvention).sourceSets.all { SourceSet sourceSet ->
   // ...
}

Look at the subprojects//plugins/src/main/java/org/gradle/api/plugins/GroovyBasePlugin.java file in the Gradle repository for some (de)motivation.

1 Like

thanks, basically copied over all that code and it worked like a charm.