appengine-plugins icon indicating copy to clipboard operation
appengine-plugins copied to clipboard

Spring Boot Gradle plugin >= v2.5.0 outputs both executable fat jar and plain jar, and GAE Gradle plugin uses plain one.

Open polyomino24 opened this issue 4 years ago • 9 comments

This is not a bug, but a feature request. Spring Boot Gradle plugin in the current version generates both executable fat jar and plain jar in the default settings like build/libs/aaa-0.0.1.jar build/libs/aaa-0.0.1-plain.jar , and when I run ./gradlew appengineShowConfiguration, it shows stage artifact is plain one.

My feature request is that GAE plugin will use fat one automatically without specifying artifact or disabling generating plain one.

environment: macOS10.15.7 openjdk version "11.0.12" 2021-07-20 LTS gradle 6.8.3 Spring Boot Gradle plugin 2.5.4 GAE Gradle plugin 2.4.2 GAE: flexible and custom runtime

reference: https://docs.spring.io/spring-boot/docs/2.5.1/gradle-plugin/reference/htmlsingle/#packaging-executable.and-plain-archives

polyomino24 avatar Sep 15 '21 03:09 polyomino24

@polyomino-24 Just to clarity, does the GAE gradle plugin deploy the correct JAR with appengineDeploy, and only shows the wrong JAR in appengineShowConfiguration?

elefeint avatar Sep 15 '21 14:09 elefeint

@elefeint Thanks for reading the issue. No, when I run appengineDeploy, the files in build/staged-app directory are only plain jar, Dockerfile, and app.yaml. Actually, my Dockerfile is

FROM openjdk:11-oracle
COPY main-0.0.1.jar main.jar
CMD ["java", "-Duser.timezone=Asia/Tokyo", "-jar", "/main.jar"]%

and when I updated Spring Boot Gradle plugin, I became unable to deploy with appengineDeploy because main-0.0.1.jar(fat jar) was not in the build/stage-app directory.

polyomino24 avatar Sep 15 '21 14:09 polyomino24

Did this work with the earlier versions of Spring Boot plugin?

elefeint avatar Sep 15 '21 14:09 elefeint

Yes, version 2.4.4 did work.

polyomino24 avatar Sep 15 '21 14:09 polyomino24

You can set appengine.stage.artifact to specify a deploy artifact:

appengine.stage.artifact = 'build/libs/demo-0.0.1-SNAPSHOT.jar'

I'm afraid this feature request is a very low priority for us. We accept contributions though.

chanseokoh avatar Sep 24 '21 19:09 chanseokoh

Thanks for your comment! I know that this workaround works and this request is a low priority for your team, but I think Gradle + Spring boot + Google App Engine is a commonly used combination so I wrote this issue to help someone. Please close this issue if you want.

polyomino24 avatar Sep 25 '21 05:09 polyomino24

Thanks for the feedback. I will leave this open.

chanseokoh avatar Sep 27 '21 14:09 chanseokoh

more friendly one:

appengine {
    stage {
        artifact = bootJar.archiveFile.get()
    }
}

zp-chen-hkmci avatar Aug 08 '22 04:08 zp-chen-hkmci

At minimum we should document these workarounds. I've run into this last year and thoroughly forgot.

elefeint avatar Aug 11 '22 14:08 elefeint