1

I managed to instruct maven to create a jar with all dependencies. When I run 'mvn package', it will produce two files: elvt-1.0.jar and elvt-1.0-jar-with-dependencies.jar.

However, I don't care for a jar without dependencies, and I would like the name of the jar with dependencies to be elvt-1.0.jar. I managed to do this by adding

<appendAssemblyId>false</appendAssemblyId>

to the configuration section of the maven-assembly-plugin artifact. This will produce two warnings however:

[WARNING] Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing.
Instead of attaching the assembly file: /home/user/workspace/elvt/target/elvt-1.0.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: /home/user/workspace/elvt/target/elvt-1.0.jar
with assembly file: /home/user/workspace/elvt/target/elvt-1.0.jar

If I understand correctly, they both warn me about overwriting the jar without dependencies. How can I tell maven not to produce a jar without dependencies?

For reference purposes, this is what my pom.xml looks like:

<project>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>Program</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>elvt</artifactId>
<version>1.0</version>
</project>
user1785730
  • 3,150
  • 4
  • 27
  • 50

0 Answers0