Rework excluding Gradle APIs for java-gradle-plugin#948
Conversation
|
@Goooler as far as I can understand this will break compilation of consumer projects in the following scenario:
Module 1: class C : TaskModule 2: fun f(c: C) {
println(c.project.name)
}Because the I don't think shadow should affect users in this way, but rather it should filter the necessary views of configurations as needed, just like publishing. (This is theoretical, haven't tested it, but I've seen similar issues in the past.) |
|
|
|
Ooops, I missed it's |
| project.plugins.withType(JavaGradlePluginPlugin).configureEach { | ||
| // Remove the gradleApi so it isn't merged into the jar file. | ||
| // This is required because 'java-gradle-plugin' adds gradleApi() to the 'api' configuration. | ||
| // See https://github.com/gradle/gradle/blob/972c3e5c6ef990dd2190769c1ce31998a9402a79/subprojects/plugin-development/src/main/java/org/gradle/plugin/devel/plugins/JavaGradlePluginPlugin.java#L161 | ||
| project.configurations.named(JavaPlugin.API_CONFIGURATION_NAME) { | ||
| it.dependencies.remove(project.dependencies.gradleApi()) | ||
| } | ||
| // Compile only gradleApi() to make sure the plugin can compile against Gradle API. | ||
| project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { | ||
| it.dependencies.add(project.dependencies.gradleApi()) | ||
| } | ||
| } |
There was a problem hiding this comment.
I did the same thing with the logic from com.gradle.publish.PublishTaskShadowAction.
private void manipulateDependencies(ConfigurationContainer configurations) {
Dependency gradleApi = project.getDependencies().gradleApi();
Configuration api = configurations.findByName("api");
if (api != null) {
api.getDependencies().remove(gradleApi);
}
Configuration compileOnly = configurations.findByName("compileOnly");
if (compileOnly != null) {
compileOnly.getDependencies().add(gradleApi);
}
}
Uh oh!
There was an error while loading. Please reload this page.