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

Document that the jar task should not be disabled when building a native image #33238

Closed
michalkrajcovic opened this issue Nov 17, 2022 · 1 comment
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@michalkrajcovic
Copy link

We use assemble task in our CI/CD pipeline to build artifacts. From Spring Boot 2.5.0 jar task generates an additional jar archive which ends with -plain.jar. This breaks builds if you use patterns like *.jar to copy the build archive. To restrict the additional jar creation Spring Boot documentation provides guidance here that we can disable the jar task if we prefer that the plain archive isn’t built at all. This doesn’t play well with nativeCompile task.

To Reproduce
Environment

  • Spring Boot: 3.0.0-RC2
  • Native Buildtools: 0.9.17
  • GraalVM version : graalvm-ce-java17-22.3.0
  • JDK version: openjdk 17.0.5
  • Architecture: AMD64

Sample project
https://github.com/michalkrajcovic/spring-native-plain-archives

Compile

./gradlew nativeCompile

Fails with

Error: Main entry point class 'com.example.springnativeplainarchives.Application' neither found on the classpath nor on the modulepath.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 17, 2022
@wilkinsona
Copy link
Member

Thanks for trying the release candidate.

The behavior you are seeing is to be expected as nativeCompile uses the jar task as an input. This is done by adding a dependency on the project itself to the nativeImageCompileOnly configuration. When the jar task is disabled, the classpath for nativeCompile is incomplete as none of the project's own classes can be found.

We'll update the documentation to indicate that you should not disable the jar task if you want to build a native image.

As an alternative, if you need the jar task to remain disabled, add the main source set's output as a dependency of the nativeImageCompileOnly configuration:

dependencies {
	nativeImageCompileOnly(sourceSets.main.output)
}

@wilkinsona wilkinsona changed the title nativeCompile task fails with Error: Main entry point class <application class> neither found on the classpath nor on the modulepath. when jar task is disabled Document that the jar task should not be disabled when building a native image Nov 17, 2022
@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 17, 2022
@wilkinsona wilkinsona added this to the 3.0.x milestone Nov 17, 2022
@mhalbritter mhalbritter self-assigned this Nov 18, 2022
@mhalbritter mhalbritter modified the milestones: 3.0.x, 3.0.0 Nov 18, 2022
joka8508 added a commit to stockholmuniversity/vaulttool that referenced this issue Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants