Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When docs-gen is used by the exec-maven-plugin's
exec:java
goal, there is a problem forSystem.exit
calls.The
exec:java
goal execute the docs-gen in the same maven VM. When docs-gen callsSystem.exit
, it halts the maven itself immediately without any maven post processing(showing maven outputs in console).This is a limitation of
exec:java
goal because it runs the program on the same maven process.This is problematic to the docs-gen for error handlings. When docs-gen encounters an error, it should fail the maven process in appropriate way.
If
System.exit
is not used, even the docs-gen failed in middle, the maven execution continues to the next step rather than stop with failure.To use
System.exit
in docs-gen for proper error handlings, we cannot useexec:java
goal.Approach
One approach to solve this problem is to use
exec:exec
goal. This goal runs the docs-gen in a separate process. Hence, theSystem.exit
does not stop the maven process. However, this approach requires a new set of challenges such as managing the dependent libraries and resolving the location of the executable.To use
exec:exec
goal, this PR makes docs-gen artifact a self contained executable jar(fat jar).Using executable fat jar has several advantages. First, to run the jar, it does not need to solve dependent library files. Another benefit is that the fat jar itself is distributed as a maven dependency, so it could be referenced by a known location(local maven repo).
One disadvantage I can think of is that the jar file is not suitable to be used as a library. Since it shades the all required library, there will be conflicts with application libraries.(Can be avoided by relocating the dependent library packages while shading.) However, the docs-gen is more of an independent jar file, so it should not be used as a library.
Run the fat jar in maven:
Run the fat jar in gradle: