I'm using IntelliJ Idea (14.1.2) to develop a simple java command-line application.
My application is composed of two modules:
- A main module that just contains the "main" class
- A library module that contains the actual code that "does things" (this module also includes and use a maven library)
Everything works when debugging from within IntelliJ, but now I want to build a JAR file in order to use the tool outside of the IDE. So, as suggested by the IntelliJ documentation, I used the "Artifacts" menu to setup a JAR artifact to be generated at build time.
The JAR seems to build correctly, but it doesn't. The problem is this: the code from my library module is NOT included in the jar, only the code from the main module is! In fact, strangest of all, the code from the maven library which my library module includes is included in the jar, but not the code of my module library itself! This obviously means that the final jar throws a ClassNotFound exception as soon as the main program tries to use a class from the library module.
I don't know what I am doing wrong, the dependencies are all set, in the Artifact creation menu I told it to include the dependencies in the jar...
EDIT: Here's the script created by IntelliJ, all seems in order:
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="delta.desktoptools.manifestgenerator:jar">
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
<root id="archive" name="delta.desktoptools.manifestgenerator.jar">
<element id="module-output" name="delta.desktoptools.manifestgenerator" />
<element id="module-output" name="delta.desktoptools.lib" /> <!-- This doesn't get included :( -->
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/github/javaparser/javaparser-core/2.0.0/javaparser-core-2.0.0.jar" path-in-jar="/" />
</root>
</artifact>
</component>
EDIT: A screen of my artifact configuration, for better clarity. As you can see the compilation output of my library module is included in the artifact, but is absent from the final JAR.