Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven assembly plugin not producing jar-with-dependencies any more, why?

This is in my pom.xml:

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
    <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    <archive>
        <manifest>
            <mainClass>tahrir.TrMain</mainClass>
        </manifest>
    </archive>
</configuration>
</plugin>

You can view the entire pom.xml here.

And this is the output when I run "mvn -DskipTests=true assembly:assembly".

Note that it seems to be building
tahrir/target/tahrir-0.0.1-SNAPSHOT.jar
but not
tahrir/target/tahrir-0.0.1-SNAPSHOT-jar-with-dependencies.jar.

Why isn't it building jar-with-dependencies given that this is the descriptionRef I've specified in the pom? This was working properly before and I don't know what might have changed to break it...?

like image 531
sanity Avatar asked Aug 03 '11 01:08

sanity


1 Answers

$ mvn -DskipTests=true assembly:assembly

It looks like you are directly invoking the assembly goal of assembly plugin rather than use the maven lifecycle like install or package.

[INFO] --- proguard-maven-plugin:2.0.4:proguard (default) @ tahrir ---

And the proguard plugin kicks in before the assembly is complete. It looks for the jar-with-dependencies which does not exist as yet.

Edit: You can try binding your assembly plugin explicitly to the package phase by adding the following:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2.1</version>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest>
                <mainClass>tahrir.TrMain</mainClass>
            </manifest>
        </archive>
     </configuration>
    <executions>
        <execution>
            <id>make-assembly</id> 
            <phase>package</phase> <!-- bind to the packaging phase -->
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Then run mvn package or mvn install skipping test as required.

like image 173
Raghuram Avatar answered Sep 28 '22 09:09

Raghuram