sanity
sanity

Reputation: 35772

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...?

Upvotes: 9

Views: 9095

Answers (2)

Raghuram
Raghuram

Reputation: 52645

$ 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.

Upvotes: 6

alphazero
alphazero

Reputation: 27224

(Not a definitive answer but too long for a comment)

I noted that all my projects include the following for the assembly plugin:

            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>attached</goal>
                    </goals>
                </execution>
            </executions>

Note that executions is sibling of descriptorRefs.

Try that.

Also:

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

It also a good practice to spec the version of the assembly plugin.

[edit/corrected: executions, not execute]

Upvotes: 4

Related Questions