How can I deploy a zip file created with the maven-antrun-plugin?
The solution that worked for me (I'm not sure if it is ideal, it seems rather hackish) was to switch to the deploy:deploy-file
goal:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>artifactory</repositoryId>
<packaging>zip</packaging>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${WORKSPACE}/MyZip.zip</file>
</configuration>
</plugin>
and invoke it explicitly:
mvn -U -X -pl projectname clean install deploy:deploy-file
The solution worked for me is to add the <attachartifact>
tag after zip creation, filled with the same path and zip filename . So something like:
<executions>
<execution>
<id>zip-artifacts</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<zip destfile="${project.build.directory}/MyStuff-${project.version}.zip" update="true" comment="This is my comment...">
<fileset dir="${project.build.directory}/MyStuff" />
</zip>
<attachartifact file="${project.build.directory}/MyStuff-${project.version}.zip" type="zip" />
</target>
</configuration>
</execution>
</executions>
Remember that the zip file has to exists, otherwise attachartifact
returns "file does not exists" error (consider to use whenempty="create"
in tag in order to avoid errors).