There were many places where I stumbled, so it's an amnesia.
Create a Gradle project. Since it is a root project, uncheck all from "Additional libraries and frameworks".
Right-click "Project View" in IntelliJ and select [New]-> [Module] from the context menu to add a shared module.
Here, check [Java] in "Additional libraries and frameworks"
It seems like adding from the "Project Structure" window instead of from the "Project View". (For some reason, the parent project cannot be specified in the "Add as next module" field) |
When the addition is complete, implement the appropriate common functions.
Next, add the module that uses the common function in the same procedure.
When the addition is complete, add the shared module to dependecies
in the" build.gradle "file and implement the appropriate functionality.
Next, set "Run / Debug Configuration" and check that it can be executed.
In the default state, Gradle's output directory setting and IntelliJ's setting are different, so a normal JAR file is not generated.
Therefore, explicitly specify the output directory in the "build.gradle" file of the shared module and app module.
Next, select [+]-> [JAR]-> [From Dependent Modules ...] from [Artifacts] in "Project Settings" in the "Project Structure" window to add the artifacts.
Change the manifest file directory from java
to resources
when specifying the module and main class.
Finally, make sure that the JAR file can be executed normally.
Recommended Posts