generator-jhipster: Executable JAR is not recommended, not supported by buildpack
Overview of the issue
Currently, JHipster uses Spring Boot Maven plugin to build a self executable jar (i.e., Zip file w/ a self-executable expansion). This is done in the pom.xml
pom.xml w/ Spring Boot Maven Plugin
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<executable>true</executable>
</configuration>
...
The JAR can be executed as if it’s a binary (e.g., $ target/myapp.jar in addition to $ java -jar target/myapp.jar). However, this self expansion is not supported by all tools, including Cloud Native Buildpack (https://github.com/cloudfoundry/archive-expanding-cnb/issues/2).
Recommend setting this flag to false by default.
Motivation for or Use Case
This prevents Cloud Native Buildpack to work w/ JHipster
Reproduce the error
Use cnb pack to pack JHipster source to container. It’ll fail with:
build-step-build] Cloud Foundry Archive Expanding Buildpack 1.0.0-BUILD-SNAPSHOT
[build-step-build] Expanding /workspace/demo-0.0.1-SNAPSHOT.jar to /workspace
[build-step-build] zip: not a valid zip file
[build-step-build] Error: failed to build: exit status 103
[build-step-build] Build Failed
Related issues
https://github.com/cloudfoundry/archive-expanding-cnb/issues/2
Suggest a Fix
Don’t produce executable JAR. Set executable to false
JHipster Version(s)
6.2.0
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
- Checking this box is mandatory (this is just to show you read everything)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 27 (27 by maintainers)
Yes put an if in the template depending on a yo-rc property. Then in the jhipster init method somewhere we have a method that patch the yo-rc if some props are undefined, you should add executable = true there.
thank you for the pr!
@saturnism @atomfrede : I’ve pushed the Gradle stuff as well. 😄
i vote for consistency btwn maven and gradle builds
It is easy to add. If you like I can do it after this is merged, but it is just adding
to the
bootJartask.https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#packaging-executable-configuring-launch-script
@saturnism : We use bootJar task for creating the jar on gradle side; but we haven’t enabled
launchScript. So the JAR created by gradle isn’t fully executable. So the answer is no; we don’t have to do anything to the gradle side. By default it is not a fully executable jar.EDIT: @PierreBesson : However it got me thinking that perhaps we might want to add support for fully executable jars on the gradle side as well?
Let’s not rush things. I have yet to test this to see if this is better than what spring provides.
Just found out this cool project to create executable jars as a separare goal : https 😕/github.com/salesforce/grpc-java-contrib/blob/master/canteen/README.md