Maven profile not activated, though property has correct value - maven

I am trying to set-up conditional plugin execution via profiles. The idea is to have a compress/no compress HTML files:
<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>net</groupId>
<artifactId>mavenconditionalexecution</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Maven Conditional Execution</name>
<properties>
<DoCompress>true</DoCompress>
</properties>
<build>
<plugins>
<!-- Clean-up -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>clean</phase>
<configuration>
<target>
<echo message="DoCompress: ${DoCompress}"/>
<delete includeemptydirs="true">
<fileset dir="${basedir}/src/main/webapp/result/" includes="**/*"/>
</delete>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/main/webapp/html</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>With Compression</id>
<activation>
<property>
<name>DoCompress</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>html</goal>
</goals>
</execution>
</executions>
<configuration>
<goalPrefix>htmlcompressor</goalPrefix>
<srcFolder>${basedir}/src/main/webapp/html</srcFolder>
<targetFolder>${basedir}/src/main/webapp/result/html</targetFolder>
<removeIntertagSpaces>true</removeIntertagSpaces>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Without Compression</id>
<activation>
<property>
<name>DoCompress</name>
<value>false</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<echo message="Copying file"/>
<copy todir="${basedir}/src/main/webapp/result/">
<fileset dir="${basedir}/src/main/webapp/html/" >
<include name="angle.html"/>
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
It does not matter what value I assign to the DoCompress property, the corresponding profile are not executed. I check the value of the property with an echo. Why? What am I doing wrong?
Is it allowed to activate multiple profiles in a pom.xml using property values?
UPDATE
I have created an incident: I have created an incident: https://jira.codehaus.org/browse/MNG-5235.
If anyone has an operational example of maven profile activation by properties, I am interested. Moreover, does anyone know whether multiple profiles can be activated in the same run via properties? The documentation is not clear about it.

After opening an issue, it turns out this is not a bug, because properties in the section can only be system properties, not properties defined in the pom.xml itself.

Related

Maven - pom file - Artifact not being created

I have a pom file that is triggered by jenkins and is being used twice, every time on a different machine(docker container) with different compilers(to be built for different linux distributions).
In order to get those 2 different builds as artifacts, and with different names, I'm trying to use profiles and set the classifier of the artifact with different values.
It seems though that the artifacts are not being created for some reason, and I don't know why.
I'm not sure I configured the profiles correctly and I also have the 'attach-to-artifact' in an execution block of its own and I don't know if it's right.
Any help would be much appreciated.
my pom.xml:
<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>
<parent>
<groupId>XXXX</groupId>
<artifactId>XXXXX</artifactId>
<version>1-SNAPSHOT</version>
</parent>
<groupId>XXXXX</groupId>
<artifactId>XXXXXXX</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<scm>
<developerConnection>scm:git:ssh://XXXXXX</developerConnection>
</scm>
<properties>
<revision>1.0.0-1-SNAPSHOT</revision>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="sh" failonerror="true">
<arg line="build.sh"/>
</exec>
</target>
</configuration>
</execution>
<execution>
<id>prepare-test-package</id>
<phase>prepare-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${env.ESX_COMPILATION}</skip>
<target>
<exec executable="sh" failonerror="true">
<arg line="tests.sh"/>
</exec>
<attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
</target>
</configuration>
</execution>
<execution>
<id>attach-to-artifact</id>
<phase>attach-artifact</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<classifier>${envClassifier}</classifier>
<target>
<attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>esx</id>
<activation>
<property>
<name>env.ESX_COMPILATION</name>
<value>true</value>
</property>
</activation>
<properties>
<envClassifier>esx</envClassifier>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<property>
<name>env.ESX_COMPILATION</name>
<value>false</value>
</property>
</activation>
<properties>
<envClassifier>linux</envClassifier>
</properties>
</profile>
</profiles>
As can be seen I'm using the 'env.ESX_COMPILATION' variable to set the profile choice which sets the 'envClassifier' variable and in the final execution block, under and before i set the 'classifier'. and inside target i call 'attachtoartifact'
What am I doing wrong here?
Any help is much appreciated!
Thanks!

Using maven release plugin on multi-module project

I have a multi-module project with two modules: war and ear module. I'm trying to use Maven release plugin to manage releases.
My config so far...
parent pom:
<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.example</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>Test-WAR</module>
<module>Test-EAR</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- some other properties -->
</properties>
<dependencyManagement>
<dependencies>
<!-- some dependencies -->
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>nexus-snapshots</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
</repository>
<repository>
<id>nexus-releases</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>nexus-releases</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
</repository>
</distributionManagement>
<scm>
<connection>scm:git:http://gitlab.example.com/test/Test.git</connection>
<developerConnection>scm:git:http://gitlab.example.com/test/Test.git</developerConnection>
<url>http://gitlab.example.com/test/Test</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v#{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.8</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-parent</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
war module pom:
<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>
<parent>
<groupId>com.example</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Test-WAR</artifactId>
<packaging>war</packaging>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<!-- some dependencies -->
</dependencies>
<profiles>
<!-- dev -->
<profile>
<id>dev</id>
<properties>
<CREATE_EJB_STUBS_SCRIPT_FILE>createEJBStubs.bat</CREATE_EJB_STUBS_SCRIPT_FILE>
<APP_CLASSES_DIR>${basedir}/target/classes</APP_CLASSES_DIR>
<EJB_LOCATION>src/test/resources/build/${project.parent.artifactId}.jar</EJB_LOCATION>
<EJB_CLIENT_LOCATION>src/test/resources/build/${project.parent.artifactId}-${project.parent.version}.jar</EJB_CLIENT_LOCATION>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-ejb-client</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-snapshots</repositoryId>
<file>${EJB_CLIENT_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB-CLIENT</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>deploy-ejb</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-snapshots</repositoryId>
<file>${EJB_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- release -->
<profile>
<id>release</id>
<properties>
<CREATE_EJB_STUBS_SCRIPT_FILE>createEJBStubs.bat</CREATE_EJB_STUBS_SCRIPT_FILE>
<APP_CLASSES_DIR>../../../Test-WAR/target/classes</APP_CLASSES_DIR>
<EJB_LOCATION>../../../Test-WAR/src/test/resources/build/${project.parent.artifactId}.jar</EJB_LOCATION>
<EJB_CLIENT_LOCATION>../../../Test-WAR/src/test/resources/build/${project.parent.artifactId}-${project.parent.version}.jar</EJB_CLIENT_LOCATION>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-build</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="server.dir" value="${SERVER_DIR}" />
<property name="createEjbStubsScriptFile" value="${CREATE_EJB_STUBS_SCRIPT_FILE}" />
<property name="appClassesDir" value="${APP_CLASSES_DIR}" />
<property name="author" value="${project.organization.name}" />
<property name="maven.root" value="${project.parent.artifactId}" />
<property name="maven.war.artifactId" value="${project.artifactId}" />
<property name="maven.war.version" value="${project.parent.version}" />
<ant antfile="${basedir}/src/test/resources/ant/build.xml">
<target name="run" />
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-ejb-client</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-releases</repositoryId>
<file>${EJB_CLIENT_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB-CLIENT</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>deploy-ejb</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-releases</repositoryId>
<file>${EJB_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<packagingExcludes>WEB-INF/classes/rebel.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>package</phase>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/test/resources</directory>
<includes>
<include>log4j2.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-build</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="server.dir" value="${SERVER_DIR}" />
<property name="createEjbStubsScriptFile" value="${CREATE_EJB_STUBS_SCRIPT_FILE}" />
<property name="appClassesDir" value="${APP_CLASSES_DIR}" />
<property name="author" value="${project.organization.name}" />
<property name="maven.root" value="${project.parent.artifactId}" />
<property name="maven.war.artifactId" value="${project.artifactId}" />
<property name="maven.war.version" value="${project.parent.version}" />
<ant antfile="${basedir}/src/test/resources/ant/build.xml">
<target name="run" />
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<verbose>true</verbose>
<fork>true</fork>
<executable>${IBM_JDK_1_8}/bin/javac</executable>
<compilerVersion>1.6</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- some config -->
</configuration>
</plugin>
</plugins>
</build>
</project>
ear module pom:
<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>
<parent>
<groupId>com.example</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Test-EAR</artifactId>
<packaging>ear</packaging>
<dependencies>
<!-- WAR -->
<dependency>
<groupId>com.example</groupId>
<artifactId>Test-WAR</artifactId>
<version>${project.parent.version}</version>
<type>war</type>
</dependency>
<!-- some other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9</version>
<configuration>
<modules>
<!-- some jar modules -->
<webModule>
<groupId>com.example</groupId>
<artifactId>Test-WAR</artifactId>
<contextRoot>/Test</contextRoot>
</webModule>
</modules>
<version>6</version>
<finalName>${project.parent.artifactId}-${project.parent.version}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-ear</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-snapshots</repositoryId>
<file>target/${project.parent.artifactId}-${project.parent.version}.ear</file>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>ear</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have two profiles - dev (which is active by default) and release (which is activated by release plugin). First, I had some problems with ant run (file paths) when releasing version, so I've used two profiles with some properties defined, that are used in ant run. Ant script is now executed properly, but I have another problem: plugin attempts to upload some release files twice which causes error:
executing mvn release:prepare "-Darguments=-Dmaven.test.skip=true": log
executing mvn release:perform "-Darguments=-Dmaven.test.skip=true": log
As you can see form logs, Test-WAR-0.0.1-sources.jar is uploading twice. Why is that? How can I edit my configuration to upload it only once?
It is quite possible that you suffer from the same bug as I did some years ago:
Maven deploy-file goal: Why does the first execution interfere with the second one?
Try to update the Maven deploy plugin to version 3.0.0-M1.

Maven: how to exec a pom twice with different profiles?

I want to make a build with Maven within a pom which can be built with two different profiles.
In other words, my task is to force the build in order that the build produces two different builds in the target folder as like I will execute "maven install -P" two times.
So, to be more clear:
one single invocation
two different results based on the profile associated in that time
I've tried the exec-maven-plugin but I'm not sure if is the correct way, because it's not doing what I desire.
How can I perform that?
Here's the pom I'm trying.
The tasks are:
copy resources from another project
replace content based on the profile
Build both profiles.
pom.xml
<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>
<artifactId>MavenDoubleInstallation</artifactId>
<profiles>
<profile>
<id>profileA</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>profileA</env>
<token>/path/for/profileA</token>
</properties>
</profile>
<profile>
<id>profileB</id>
<properties>
<env>profileB</env>
<token>/path/for/profileB</token>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/${env}/result</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../SourceProject/resources/result</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${basedir}/target/classes/${env}/result</basedir>
<includes>
<include>**/*.sh</include>
</includes>
<replacements>
<replacement>
<token>%%TOKEN%%</token>
<value>${token}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>build-profileA</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>maven</executable>
<arguments>
<argument>-P profileA -X</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build-profileB</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>maven</executable>
<arguments>
<argument>-P profileB -X</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Maven property not set when using profile

The filtering via maven package -Pexplode is not working. "${ds.xml}" is not being replaced with "openmind-ds.xml". The value "openmind-ds.xml" and key "ds.xml" are in the filter.properties. Also ${as.deploy}.
Error Message
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (package) on project openmind-ear: An Ant BuildException has occured: Warning: Could not find file /home/localhost/workspaceOM/openmind/openmind-ear/target/${ds.xml} to copy. -> [Help 1]
Mode Debug
[INFO] Executing tasks
[DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
[DEBUG] getProperty(ns=null, name=as.deploy, user=false)
Property "as.deploy" has not been set
Setting project property: deploy-path -> ${as.deploy}/openmind-ear.ear
[DEBUG] getProperty(ns=null, name=deploy-path, user=false)
[echo] Exploding to ${as.deploy}/openmind-ear.ear
[DEBUG] getProperty(ns=null, name=deploy-path, user=false)
[delete] Directory /home/localhost/workspaceOM/openmind/openmind-ear/${as.deploy}/openmind-ear.ear cannot be removed using the file attribute. Use dir instead.
[DEBUG] getProperty(ns=null, name=deploy-path, user=false)
[mkdir] Skipping /home/localhost/workspaceOM/openmind/openmind-ear/${as.deploy}/openmind-ear.ear because it already exists.
[DEBUG] getProperty(ns=null, name=deploy-path, user=false)
[sync] PASS#1: Copying files to /home/argonist/om-umgebung/workspaceOM/openmind/openmind-ear/${as.deploy}/openmind-ear.ear
pom.xml in ear-project
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.openmind</groupId>
<artifactId>openmind</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>openmind-ear</artifactId>
<packaging>ear</packaging>
<name>${project.artifactId} : ${project.version} EAR</name>
<profiles>
<profile>
<id>env-dev</id>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>env-prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
<profile>
<id>explode</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>package</id>
<phase>package</phase>
<configuration>
<tasks>
<property name="deploy-path" value="${as.deploy}/${app.context}-ear.ear" />
<echo>Exploding to ${deploy-path}</echo>
<delete file="${deploy-path}" quiet="true" />
<mkdir dir="${deploy-path}" />
<sync todir="${deploy-path}" verbose="true">
<fileset
dir="${project.build.directory}/${project.build.finalName}" />
</sync>
<copy todir="${as.deploy}" file="${project.build.directory}/${ds.xml}"
verbose="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>unexplode</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
<property name="deploy-path" value="${as.deploy}/${app.context}-ear.ear" />
<echo>Unexploding: ${deploy-path}</echo>
<delete file="${deploy-path}" quiet="true" />
<delete dir="${deploy-path}" quiet="true" />
<delete file="${as.deploy}/${ds.xml}" quiet="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
.....
</dependencies>
<build>
<finalName>${app.context}-ear</finalName>
<filters>
<filter>../src/main/filters/filter-${env}.properties</filter>
</filters>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
<version>6</version>
<archive>
<manifestEntries>
<Build-Date>${timestamp}</Build-Date>
<Build-Revision>${buildNumber}</Build-Revision>
<Mode>${env}</Mode>
</manifestEntries>
</archive>
<modules>
<jarModule>
<groupId>org.jboss.el</groupId>
<artifactId>jboss-el</artifactId>
<includeInApplicationXml>false</includeInApplicationXml>
<bundleDir>lib</bundleDir>
</jarModule>
<jarModule>
<groupId>${project.groupId}</groupId>
<artifactId>${app.context}-datamodel</artifactId>
<includeInApplicationXml>false</includeInApplicationXml>
<bundleDir>lib</bundleDir>
</jarModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>${app.context}-war</artifactId>
<contextRoot>/${app.web.context}</contextRoot>
<unpack>${app.unpack.modules}</unpack>
<bundleFileName>${app.context}-war.war</bundleFileName>
</webModule>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>${app.context}-bootstrap</artifactId>
<excluded>${exclude.bootstrap}</excluded>
<bundleFileName>${app.context}-bootstrap.jar</bundleFileName>
<unpack>${app.unpack.modules}</unpack>
</ejbModule>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>${app.context}-ejb</artifactId>
<bundleFileName>${app.context}-ejb.jar</bundleFileName>
<unpack>${app.unpack.modules}</unpack>
</ejbModule>
<ejbModule>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<files>
<file>${basedir}/../src/main/filters/filter-${env}.properties</file>
</files>
</configuration>
</execution>
<execution>
<!-- Properties needed by unexplode profile -->
<id>pre-clean</id>
<phase>pre-clean</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/../src/main/filters/filter-${env}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- <outputDirectory>${env.JBOSS_HOME}/server/default/deploy</outputDirectory> -->
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>${ds.xml}</include>
</includes>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>copy-app-ds-xml</id>
<goals>
<goal>copy-resources</goal>
</goals>
</execution>
</executions>
<!-- <execution> <id>copy-mysql-driver</id> <phase>install</phase> <goals>
<goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${env.JBOSS_HOME}/server/default/lib</outputDirectory>
<resources> <resource> <directory>${settings.localRepository}/mysql/mysql-connector-java/5.1.6</directory>
<includes> <include>mysql-connector-java-5.1.6.jar</include> </includes>
</resource> </resources> </configuration> </execution> -->
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
Your filter properties rely on the ${env} parameter:
<filter>../src/main/filters/filter-${env}.properties</filter>
This parameter has no value in your "explode" profile. So Maven must be looking for:
../src/main/filters/filter-.properties
I suspect you were hoping it would be filter.properties and not filter-.properties.

Maven Wagon plugin: Can wagon:upload upload to multiple locations?

I'm looking into the Maven Wagon Plugin to attempt uploading some artifacts to remote UNC Server shares (\\servername\share\directory\to\put\to), and I have gotten it configured to work like so in the POM:
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-jar-to-folder</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
<configuration>
<fromDir>${project.build.directory}</fromDir>
<includes>*</includes>
<url>file://localhost///${servername}/${sharename}</url>
<toDir>directory/to/put/artifact</toDir>
</configuration>
</plugin>
...
</build>
This works great for one server when I pass in -Dservername=x -Dsharename=y, but how can I scale it out so I can run a deploy for QA or Prod where I have multiple servers to deploy to?
I've considered (and written) a script to run mvn wagon:upload -Penvironment# multiple times--once for each server--but this seems flawed to me. If I'm shelling out to a script to handle this process, I could just as well script out the entire deploy, too. However, this takes away from the usefulness of Wagon (and Maven)...
Is there a way to run multiple <executions> for one goal? For instance, running multiple profile configured wagon:upload tasks when I just run mvn deploy -Pqa?
If you want to use multiple profiles you could just use: mvn deploy -Denv=qa and trigger some profiles on this property and define the configuration for your severs in the profiles. For this kind of profile activation look at
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
and search for
-Denvironment=test
Here's an example POM which does two executions of the maven-antrun-plugin in one build:
<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.stackoverflow</groupId>
<artifactId>q5328617</artifactId>
<version>0.0.1-SNAPSHOT</version>
<profiles>
<profile>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<id>qa1</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>qa1</id>
<phase>test</phase>
<configuration>
<tasks>
<echo level="info">Executing qa1</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<id>qa2</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>qa2</id>
<phase>test</phase>
<configuration>
<tasks>
<echo level="info">Executing qa2</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

Resources