autoconfigure-gradle-plugin
autoconfigure-gradle-plugin copied to clipboard
The JavaLibraryPlugin must not be applied for project/module that is creating an executable artifact
By default the JavaLibraryPlugin is applied to all modules (the project). The JavaLibraryPlugin only should be applied when producing a shareable library JAR. For an executable artifact it is sufficient to apply the JavaPlugin or in addition the application/SpringBoot plugin.
Having the JavaLibraryPlugin applied by default causes the Spring Boot native image build to try producing a dynamic link library instead of producing an executable.
Below is a first attempt to fix that
class JavaConfigurePlugin : Plugin<Project> {
override fun apply(project: Project) {
if (project.name.endsWith("-server")) { // TODO figure out how to use isServer()
project.plugins.apply(JavaPlugin::class)
} else {
project.plugins.apply(JavaLibraryPlugin::class)
}
...
that is already merged since a couple of versions, forgot to close
now the "api" configuration is not available anymore: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation
* What went wrong:
A problem occurred evaluating project ':contract-client'.
> Could not find method api() for arguments [io.cloudflight.conto:conto-signature-api] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Also see https://github.com/cloudflightio/autoconfigure-gradle-plugin/issues/195
Yes, as of #127 and #137 we decided to not apply the JavaLibraryPlugin automatically anymore at least in applicationBuilds. As we can only evaluate that property afterEvaluate, we decided to not apply the JavaLibraryPlugin at all any more. In case you need it, please apply it manually.
The problematic code here is that one: https://github.com/cloudflightio/autoconfigure-gradle-plugin/blob/main/src/main/kotlin/io/cloudflight/gradle/autoconfigure/java/JavaConfigurePlugin.kt#L69
We need to wait for afterEvaluate, and that's too late to apply the plugin.
This is quite a breaking change.
The breaking change was marked with a new minor version because there wasn't a 1.0.0 released at that time. See https://github.com/cloudflightio/autoconfigure-gradle-plugin/releases/tag/0.9.0. In these release notes it is also written what to do if you still need the java-library
plugin: If you need the api dependency scope, then please apply the java-library plugin in your modules yourself
.
For better clarity I've updated the documentation in https://github.com/cloudflightio/autoconfigure-gradle-plugin/pull/196.
With this I kindly ask you to close this issue or state a reason to keep this issue opened.