wildfly-maven-plugin doesn't deploy anything - maven-3

I would like Maven to start up a wildfly server which is available in my target-folder at /path/to/project/target/wildfly-8.1.2-Final. The plugin is supposed to deploy a war-artifact during pre-integration-test phase. That very artifact was created by maven-war-plugin during package-phase right before wildfly-maven-plugin starts.
When running the maven build, wildfly starts up, however does not deploy anything. It just hangs after starting up and lets the Maven build fail after a timeout of 60 seconds...
This is my effective pom:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.1.0.Alpha8</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<port>18080</port>
<timeout>60</timeout>
<skip>false</skip>
<hostname>127.0.0.1</hostname>
<name>/path/to/project/target/my-artifact.war</name>
<targetDir>/path/to/project/target/wildfly-8.2.1.Final/standalone/deployments</targetDir>
<server-config>standalone.xml</server-config>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<add-user>
<users>
<user>
<username>wildfly-admin</username>
<password>wildfly.1234</password>
<groups>
<group>admin</group>
<group>user</group>
</groups>
<application-user>false</application-user>
<realm>ManagementRealm</realm>
</user>
<user>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<groups>
<group>user</group>
</groups>
<application-user>true</application-user>
<realm>ApplicationRealm</realm>
</user>
</users>
</add-user>
</configuration>
</execution>
<execution>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
<goal>shutdown</goal>
</goals>
<configuration>
<hostname>127.0.0.1</hostname>
<port>18888</port>
<skip>false</skip>
<name>/path/to/project/target/my-artifact.war</name>
<targetDir>/path/to/project/target/wildfly-8.2.1.Final/standalone/deployments</targetDir>
<server-config>standalone.xml</server-config>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<add-user>
<users>
<user>
<username>wildfly-admin</username>
<password>wildfly.1234</password>
<groups>
<group>admin</group>
<group>user</group>
</groups>
<application-user>false</application-user>
<realm>ManagementRealm</realm>
</user>
<user>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<groups>
<group>user</group>
</groups>
<application-user>true</application-user>
<realm>ApplicationRealm</realm>
</user>
</users>
</add-user>
</configuration>
</execution>
</executions>
<configuration>
<skip>false</skip>
<hostname>127.0.0.1</hostname>
<port>18080</port>
<name>/path/to/project/target/my-artifact.war</name>
<targetDir>/path/to/project/target/wildfly-8.2.1.Final/standalone/deployments</targetDir>
<server-config>standalone.xml</server-config>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<add-user>
<users>
<user>
<username>wildfly-admin</username>
<password>wildfly.1234</password>
<groups>
<group>admin</group>
<group>user</group>
</groups>
<application-user>false</application-user>
<realm>ManagementRealm</realm>
</user>
<user>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<groups>
<group>user</group>
</groups>
<application-user>true</application-user>
<realm>ApplicationRealm</realm>
</user>
</users>
</add-user>
</configuration>
</plugin>
Has anybody experienced a similar behaviour?
Maybe somebody could give me a pointer on what is wrong here... Any help is highly appreciated.
Thanks
Walter

You are using port 18080. I guess, as you are using 18888 either you changed the port?
The default configuration is 8080.

After reading the documentation I can tell it's not clear what <port/> is used for. The port configuration property is used to tell the plugin which port the management interface is listening on. That is why using port 9990 works. Same with the <hostname/>.
The <targetDir/> seems to be wrong as well. It's poorly named, but that directory is used find the deployment. Essentially it's the target directory where maven put the compiled archive.
Looking at the configuration you're defining a lot of the defaults that shouldn't be necessary. Below is an example stripped down version of the plugin configuration from the example you posted.
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.1.0.Alpha8</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<add-user>
<users>
<user>
<username>wildfly-admin</username>
<password>wildfly.1234</password>
<groups>
<group>admin</group>
<group>user</group>
</groups>
<application-user>false</application-user>
<realm>ManagementRealm</realm>
</user>
<user>
<username>wildfly-test</username>
<password>wildfly.1234</password>
<groups>
<group>user</group>
</groups>
<application-user>true</application-user>
<realm>ApplicationRealm</realm>
</user>
</users>
</add-user>
</configuration>
</execution>
<execution>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>

Related

Maven JIB: Creating Docker images, multiple executions defined in POM.xml?

I am creating docker images with the JIB module from google for maven. I configured my POM.XML.
My goal
Create two Images, one with a dynamic tag 1ef234f, and one static latest)
My try
As you can see, i tried to define two executions, however, just the first one is executed.
I also tried within the JIB module, e.g. two , or two , however nothing is working.
Actually I thought maven should be able to do two executions?
My POM.xml
<profile>
<id>buildImage</id>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>create-image-snapshot-version</id>
<phase>compile</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<skip>false</skip>
<allowInsecureRegistries>true</allowInsecureRegistries>
<from>
<image>${base.image}</image>
</from>
<to>
<image>${image.repo}:${image.tag}</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xmx2G</jvmFlag>
</jvmFlags>
</container>
</configuration>
</execution>
<execution>
<id>create-image-latest</id>
<phase>compile</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<skip>false</skip>
<allowInsecureRegistries>true</allowInsecureRegistries>
<from>
<image>${base.image}</image>
</from>
<to>
<image>${image.repo}:latest</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xmx2G</jvmFlag>
</jvmFlags>
</container>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Okay, i found the solution. #Chanseok Oh was actually right, but
it needs to be like
<from>
<image>${base.image}</image>
</from>
<to>
<image>${image.repo}:${image.tag}</image>
<tags>
<tag>latest</tag>
</tags>
</to>

How to run `jacoco-maven-plugin` with `-Xbootclasspath/p:my.jar` option?

To successfully run my unit tests I have to provide JVM with some replaced standard classes. Therefore, I use following configuration for maven-surefire-plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skipTests>${skipUTs}</skipTests>
<argLine>-Xbootclasspath/p:my.jar</argLine>
</configuration>
</plugin>
plugin/configuration/argLine added, nothing special. But how can I tell jacoco the same thing? The jacoco doesn’t have configuration/argLine :( .
I have configured the Maven JaCoCo plugin as follows in my pom.xml file:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<configuration>
<skip>${skipUTs}</skip>
<!-- NO ONE (((((
<argLine>-Xbootclasspath/p:my.jar</argLine>
-->
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>1.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
As stated in documentation of prepare-agent - it simply sets property argLine that is used by maven-surefire-plugin, and you have two options to add additional arguments:
<properties>
<argLine>-your -extra -arguments</argLine>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- no argLine here -->
</configuration>
</plugin>
or using late property evaluation feature of maven-surefire-plugin:
<properties>
<!-- empty to avoid JVM startup error "Could not find or load main class #{argLine}" in case when jacoco-maven-plugin not executed -->
<argLine></argLine>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>#{argLine} -your -extra -arguments</argLine>
</configuration>
</plugin>

zip construction in folder using maven assembly

I'm able to construct a zip, happy. But when I unzip, the content is not packed in one folder(my file name). I saw many questions and followed, all are similar but nothing cleared this. Can anyone help me in this making zip.
Thanks in advance.......
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<inherited>true</inherited>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>${maven.compile.target}</target>
<source>${maven.compile.source}</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<inherited>true</inherited>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
<configuration>
<includePom>true</includePom>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<filtering>false</filtering>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="version" value="${maven.version}" />
<property name="timestamp" value="${timestamp}" />
<property name="revision" value="${buildNumber}" />
<property name="basedir" value="${maven.basedir}" />
<property name="targetdir" value="${project.build.directory}" />
<property name="workbench.jar" value="${project.artifactId}-${project.version}.${project.packaging}" />
<!-- build timestamp -->
<echo file="${targetdir}/generated-resources/META-INF/build-timestamp.txt">Version: ${project.version} / Revision: ${revision} / Build: ${timestamp}</echo>
<!-- start scripts -->
<mkdir dir="${targetdir}/start" />
<copy todir="${targetdir}/start" overwrite="true">
<fileset dir="${basedir}/src/main/start" />
</copy>
<replace dir="${targetdir}/start">
<replacefilter token="#workbench.jar#" value="${workbench.jar}" />
<replacefilter token="#version#" value="Version: ${project.version} / Revision: ${revision} / Build: ${timestamp}" />
<replacefilter token="#versionnumber#" value="${project.version}" />
</replace>
<chmod dir="${targetdir}/start" perm="+x" includes="**/*.sh" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<workspace>.</workspace>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<mainClass>org.apache.chemistry.opencmis.workbench.Workbench</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix />
</manifest>
<manifestEntries>
<X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>pack-workbench</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<attach>true</attach>
<descriptors>
<descriptor>src/main/assembly/workbench-assembly.xml</descriptor>
<descriptor>src/main/assembly/workbench-ri-assembly.xml</descriptor>
<descriptor>src/main/assembly/workbench-cxf-assembly.xml</descriptor>
<descriptor>src/main/assembly/workbench-axis2-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>mac-workbench</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<attach>true</attach>
<finalName>CMIS Workbench ${project.version}.app</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>
src/main/assembly/workbench-mac-assembly.xml
</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo.webstart</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<goals>
<goal>jnlp-inline</goal>
</goals>
</execution>
</executions>
<configuration>
<libPath>lib</libPath>
<jnlp>
<mainClass>org.apache.chemistry.opencmis.workbench.Workbench</mainClass>
</jnlp>
<pack200>true</pack200>
<gzip>true</gzip>
<sign>
<keystore>${project.build.directory}/keystore</keystore>
<keypass>password</keypass>
<storepass>password</storepass>
<alias>webstart</alias>
<validity>365</validity>
<dnameCn>OpenCMIS Development Team</dnameCn>
<dnameOu>Apache Chemistry OpenCMIS</dnameOu>
<dnameO>The Apache Software Foundation</dnameO>
<verify>true</verify>
<keystoreConfig>
<delete>true</delete>
<gen>true</gen>
</keystoreConfig>
</sign>
</configuration>
</plugin>
</plugins>
</build>
It is a bit mistake in xml file under assemblies directory. Where we need to set "true" for baseIncludeDirectory tag....

maven - jibx codegen - storing binding.xml

I'm using maven to build a jar containing generated code from an schema file using jibx. To do this I'm using the jibx-maven-plugin with the schema-codegen goal. I want to include the generated binding.xml file as part of the resulting maven jar. Is there any way of directing the jar creation to include the generated binding.xml
Currently using:
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<schemaLocation>src/main/jibx</schemaLocation>
<includeSchemas>
<includeSchema>dataoneTypes.xsd</includeSchema>
</includeSchemas>
<options>
<package>org.dataone.ns.service.types.v1</package>
</options>
</configuration>
<executions>
<execution>
<goals>
<goal>schema-codegen</goal>
</goals>
</execution>
</executions>
</plugin>
David,
Good! While including the binding.xml file is not required, it is good practice. The new jibx-maven-plugin can use this file later when creating a new binding that is based on the original schema. There are plenty of examples in the JiBX source repository.
Since JiBX is OSGi enabled, it is also good practice to add an OSGi manifest when creating your jar file. This also simplifies including the binding.xml file. Even if you don't use OSGi, your jar will work fine. Here is what your project file should look like:
<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>org.dataone.ns.service</groupId>
<artifactId>org.dataone.ns.service.types.v1</artifactId>
<version>0.0.1</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>generate-java-code-from-schema</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/jibx</schemaLocation>
<includeSchemas>
<includeSchema>dataoneTypes.xsd</includeSchema>
</includeSchemas>
<options>
<package>org.dataone.ns.service.types.v1</package>
</options>
</configuration>
</execution>
<execution>
<id>compile-binding</id>
<goals>
<goal>bind</goal>
</goals>
<configuration>
<schemaBindingDirectory>target/generated-sources</schemaBindingDirectory>
<includes>
<include>binding.xml</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>META-INF/binding.xml=${basedir}/target/generated-sources/binding.xml</Include-Resource>
<Export-Package>org.dataone.ns.service.types.v1.*;version=${project.version}</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-extras</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</project>
Take a look at your jar file. Your classes, the binding.xml file, and OSGi manifest entries are there!
Don Corley
jibx-maven-plugin author
You can always use maven-antrun-plugin to copy your file(set) to target/classes.
Make sure that:
you attach the jibx plugin to a phase before package - best is generate-resources
you attach the antrun execution to the same or later, but again, before package - best is generate-resources or process-resources
the jibx plugin declaration precedes antrun declaration
Then you can use something like this:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy file="${project.build.directory}/PATH/TO/binding.xml" todir="${project.build.outputDirectory}/PATH/IN/JAR/"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
...
You can create your binding.xml in the target directory you want it to be placed in the jar like this:
...
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
...
<targetDirectory>target/resources</targetDirectory>
...
</configuration>
...
When binding the code, you can use the refer to this directory with the <bindingDirectory> tag
You can do it using the add-resource goal of the build-helper-maven-plugin.
Example:
<build>
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>generate-java-code-from-schema</id>
<phase>generate-sources</phase>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources</schemaLocation>
<includeSchemas>
<includeSchema>foobar.xsd</includeSchema>
</includeSchemas>
</configuration>
</execution>
<execution>
<id>compile-binding</id>
<phase>process-classes</phase>
<goals>
<goal>bind</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.build.directory}/generated-sources</directory>
<includes>
<include>binding.xml</include>
</includes>
<targetPath>JiBX</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
You will find the binding.xml file in your jar at:
JiBX/binding.xml

How can I deploy a zip file created with the maven-antrun-plugin?

I'm using the maven-antrun-plugin to do a bunch of work with Ant, which ultimately results in a zip file. I'd like to deploy the zip file to our maven server (Artifactory). The maven-antrun-portion works as intended and successfully creates the zip file; however deployment fails with the following error message:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy (default-deploy) on project projectname: The packaging for this project did not assign a file to the build artifact
My POM file is as follows:
<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>com.company.division</groupId>
<artifactId>projectname</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>com.company.product</groupId>
<artifactId>parentproject</artifactId>
<version>1.0.0</version>
</parent>
<distributionManagement>
<snapshotRepository>
<id>artifactory</id>
<name>artifactory-snapshots</name>
<url>http://localartifactoryserver/artifactory/libs-snapshot-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
<dependencies>
<!-- Some dependencies... -->
</dependencies>
<build>
<plugins>
<!-- Compiler plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF8</encoding>
<optimize>true</optimize>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<!-- Do lots of other stuff with Ant. -->
<!-- Create a zip file. -->
<zip basedir="mydir" destfile="${WORKSPACE}/MyZip.zip" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>zip</packaging>
<file>MyZip.zip</file>
<url>${project.distributionManagement.snapshotRepository.url}</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I invoke this (from the parent POM) with mvn -U -pl projectname clean deploy I get the aforementioned error during the deploy phase. Does anyone know what I'm doing wrong or how I can fix this?
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).
While looking for a way to add comment to a zip file I found this question. The deploy worked fine but had troubles with the maven release to post into nexus. The solution below solved my problem, I made an empty zip assembly and then simply replaced it with the zip file from the ant task which allowed me to add the comment to the zip file.
This way the artifact is generated and not transitive.
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>${project.build.finalName}</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/MyStuff/emptydir</directory>
<outputDirectory></outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
<plugin>
<!-- make an assembly (zip the LxBase) for the distribuition -->
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs-assembly</id>
<phase>package</phase>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assemble.xml</descriptor>
</descriptors>
</configuration>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<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>
</target>
</configuration>
</execution>
</executions>
</plugin>

Resources