When I create a jar file I want to fit inside my dependencies. For that, I use
maven-assembly-plugin such as follows:
This code works OK and it does what it’s expected to do. However, this creates a new jar called
myjar-GUI-jar-with-dependencies.jar. I would like to eliminate that “jar-with-dependencies” ending. Does anybody knows how to do that?
I have used that commented line you can see on my code, but that produces the following warning that I don’t know how to solve it:
[WARNING] Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing.
Instead of attaching the assembly file: [myJar-GUI].jar, it will become the file for main project artifact.
NOTE: If multiple descriptors or descriptor-formats are provided for this project, the value of this file will be non-deterministic!
[WARNING] Replacing pre-existing project main-artifact file: [myJar].jar with assembly file: [myJar-GUI].jar
After the solution the user Tunaki suggested, I used a different pluggin and maven works as I want it to do it. The code is as follows:
First, you need to understand why you are getting this warning.
The Maven convention is that one project should create a single main artifact. For a project of packaging
jar, the main artifact is the result of the
maven-jar-plugin. This plugin will package as a JAR the classes contained in your project only.
One project can eventually generate additional artifacts that will be distinguished from the main one by their classifier:
Beside the main artifact there can be additional files which are attached to the Maven project. Such attached filed can be recognized and accessed by their classifier.
The classifier is an identifier than will be appended to the main artifact name.
So what happens when you want to create an uber-jar? Somehow, your project needs to generate two jars. The main one will be a JAR containing the classes of your project and the second one will be the uber-jar resulting of
maven-assembly-plugin. To distinguish this secondary additional artifact from the main one, the classifier
jar-with-dependencies is added.
So when you remove the classifier, you effectively replace the main artifact with the uber-jar.
maven-assembly-plugin will emit a warning in this case, and that’s the warning you are having. You can ignore it completely: it just reminds you that you are replacing the main artifact of the project by an additional artifact.
maven-assembly-plugin, do note that you can also generate an uber-jar with the
This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade – i.e. rename – the packages of some of the dependencies.