tinesoft / nxrocks

Set of Nx plugins to enhance your Nx workspace (even more!)
MIT License
308 stars 36 forks source link

[Bug] buildJar does not run successfully #43

Closed mattagohni closed 2 years ago

mattagohni commented 3 years ago

Plugin Name and Version: @nxrocks/nx-spring-boot@1.3.1

Nx Version (nx --version): 11.3.0

Angular CLI version (ng --version): 11.3.0

Expected Behaviour

when

$ nx buildJar <mySpringBootApp>

is executed the SpringBoot Application is repackaged successfully.

Actual Behaviour

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.3:repackage (default-cli) on project mySpringBootApp: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.3:repackage failed: Source file must not be null -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Steps to reproduce the behaviour

More Information

tinesoft commented 3 years ago

Hi @mattagohni

Thanks for using the plugin and for reporting this issue. As you said, this may be a general problem on Spring Boot side. I'm monitoring the original issue to see if I need to take some actions or not.

Stay tuned

ZaLiTHkA commented 2 years ago

I discovered this Nx plugin the other day, only got to play with it now though.. experiencing the same issue here with two Spring web app projects: one intended as a "standalone" jar, another as a "deployable" war.

searching for more info on the core error message, I noticed a comment from @wilkinsona (Spring member) where he's asking:

[snip] can you please help us to understand your use case for calling the spring-boot:repackage goal in isolation rather than relying upon it being bound to the package phase?

this prompted me to go try the typical clean and package goals workflow from within each Nx workspace app folder, which works exactly as expected, both with the bundled mvnw and with my globally installed 3.6.3 version.


my environment:


now for the ultimate clincher: I am a JS dev (in a broad sense), not a Java dev.. so firstly, a monstrous thank you for making it so easy for someone like me to even get this far with creating Java apps. projects like Nx and plugins like this make it so much easier to learn new things. ๐Ÿ‘๐Ÿผ

either way, I'm curious now: would this not perhaps be "solved" by making the nx run <app-name>:buildJar and nx run <app-name>:buildJar commands execute mvn package instead of mvn spring-boot:repackage? or would this have other side effects in the workflow?


lastly, on a semi-related note: since this plugin can generate an application explicitly configured either for war or jar outputs, would it not be simpler to replace (wrap?) the buildJar and buildWar plugin executors with just build, and getting the "jar or war" output details from the project config..? ๐Ÿค”

tinesoft commented 2 years ago

Hi @ZaLiTHkA

Thanks for using the plugin and for your interest, I'm glad it is useful to you ๐Ÿ˜‡

The reason why I chose the repackage goal, was because it is present in both mavenand gradle plugins for Spring Boot, whereas the default package goal only exists for Maven. Besides, the documentation didn't clearly mention that repackage was not meant to be used directly....

In light with the last information, I will update the plugin to use package (resp. build) to build the artifact for Maven (resp. Gradle). That should fix this issue.

Also, your suggestion of using a single build executor (that would alias current buildJar/buildWar) is totally valid ๐Ÿ‘๐Ÿพ I will add this feature as well.

Stay tuned

ZaLiTHkA commented 2 years ago

thanks @tinesoft, that all sounds pretty awesome.. I must say, I was "thinking out loud" there more than anything else. my personal experience is quite limited with Maven and Gradle, mostly just from tweaking generated build files.

in my mind, the idea of keeping a Java-powered API, a JS-powered static site, and [insert favourite project here] in a single monorepo, with the ability to control the build process from one common system (aka: nx) is a developer's dream... Nrwl may have created Nx itself, but it's projects like this one that provide the real power. so, thank you very much for that!

feel free to ping me if you need a hand with testing anything, insomnia gives me lots of time to play with things like this... ๐Ÿคฃ

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version @nxrocks/nx-spring-boot-v4.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version @nxrocks/nx-melos-v1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: