I am using mvn release-plugin
and assembly-plugin
to deploy jar with dependency. It works fine, when I use it with mvn release
. It creates two files: normal XXX.jar
and XXX.jar-with-dependencies.jar
and deploys them both.
But I need also deploy snapshot to another repository by using mvn deploy
. In this repository I only need the XXX.jar without dependencies.
So I hope that I could use mvn deploy
to deploy snapshot version without dependencies with followed setting.
POM.xml setting:
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>install</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
PS: mvn clean install deploy
will be called by jenkins scm pulling
schedule every morning.
Artifacts produced by maven-assmbly-plugin
are automatically attached to the project and hence are deployed when you call mvn deploy
.
What you can do is to define a profile (say 'with-dependencies') where you put the assembly plugin execution. In this case if you call mvn deploy
it will build a -SNAPSHOT version and push it to the snapshot repository and for the release you will have to call mvn release:prepare release:perform -Pwith-dependencies
<profile>
<id>with-dependencies</id>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>install</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</profile>