Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The JavaLibraryPlugin must not be applied for project/module that is creating an executable artifact #127

Open
MartinAhrer opened this issue Nov 28, 2022 · 7 comments

Comments

@MartinAhrer
Copy link
Contributor

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)
        }
...

klu2 added a commit that referenced this issue Dec 14, 2022
…ication modules and also provide the possibility to activate the spring boot plugin also locally

Signed-off-by: Klaus Lehner <[email protected]>
@klu2 klu2 linked a pull request Dec 14, 2022 that will close this issue
@klu2 klu2 self-assigned this Dec 14, 2022
klu2 added a commit that referenced this issue Jan 13, 2023
klu2 added a commit that referenced this issue Jan 13, 2023
@klu2
Copy link
Contributor

klu2 commented May 16, 2023

that is already merged since a couple of versions, forgot to close

@klu2 klu2 closed this as completed May 16, 2023
@haraldradi
Copy link

now the "api" configuration is not available anymore: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation

@haraldradi haraldradi reopened this Dec 11, 2023
@haraldradi
Copy link

* 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.

@haraldradi
Copy link

Also see #195

@klu2 klu2 removed their assignment Dec 11, 2023
@klu2
Copy link
Contributor

klu2 commented Dec 11, 2023

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.

@haraldradi
Copy link

This is quite a breaking change.

@rspiegl
Copy link
Contributor

rspiegl commented Dec 11, 2023

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 #196.
With this I kindly ask you to close this issue or state a reason to keep this issue opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants