Reputation: 3403
I've got a Maven project (submodule of a parent project) which I need to create a "jar with dependencies" for. I added the maven-assembly-plugin
to the pom.xml, but it didn't create the artifact. I've slowly stripped everything else out of the pom.xml, until all that's left is dependencies and this plugin, and it still won't create a jar with dependencies. Watching the output of mvn clean package
it runs clean
, compile
, and jar
but never runs the assembly
plugin. I don't know why. Here's the pom.xml, can anyone spot the problem?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project</groupId>
<artifactId>project-name</artifactId>
<version>1.0</version>
<name>project-name</name>
<properties>
<build.time>${maven.build.timestamp}</build.time>
<spring.framework.version>4.3.1.RELEASE</spring.framework.version>
<spring.security.version>4.1.1.RELEASE</spring.security.version>
<spring.webflow.version>2.4.2.RELEASE</spring.webflow.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<sourceDirectory>${project.basedir}/src/java</sourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/resources</directory>
</resource>
</resources>
<outputDirectory>${project.basedir}/target/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
[snip]
</dependencies>
</project>
Upvotes: 1
Views: 3039
Reputation: 131516
Assemble an application bundle or distribution from an assembly descriptor. This goal is suitable either for binding to the lifecycle or calling directly from the command line (provided all required files are available before the build starts, or are produced by another goal specified before this one on the command line).
The asssembly:single
goal may be used in two ways :
either by binding it to the lifecycle
or by calling it directly from the command line
You do no one of them.
You can for example do it to bind the plugin execution to the package
phase :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<phase>package</phase> <!-- bind to the packaging phase -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Now the mvn package
or mvn install
command will create the jar with dependencies.
You can also keep your actual plugin configuration and run the mvn assembly:single
command.
The second way allows to create the jar with dependencies on demand and not for every build.
Which may be desirable if the jar creation is a long task that doesn't need to be executed at each build.
Upvotes: 3