2014-12-28

Make Maven package all dependency jars into my jar


Add the following in pom.xml


<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>fully.qualified.MainClass</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
    </plugin>
  </plugins>
</build>
 
and you run it with
mvn clean compile assembly:single Compile goal should be added before assembly:single or otherwise the code on your own project is not included.

Source

No comments:

Popular Posts