Maven pom.xml with more than one jar with version - maven

Here is 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<url>http://maven.apache.org</url>
<name>SomeProject</name>
<groupId>com.test.te</groupId>
<artifactId>testjar</artifactId>
<version>1.1.6</version>
<packaging>jar</packaging>
<dependencies>
....
....
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.conf</include>
<include>**/*.java</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<id>drive</id>
<goals><goal>jar</goal></goals>
<phase>install</phase>
<configuration>
<finalName>driver</finalName>
<includes>
<include>com/test/te/p1/*.java<include>
<include>com/test/te/p1/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is how I am executing this
mvn clean install
Here is the build output's last few lines.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: /home/mycp/workspace/SomeProject/target/testjar-1.1.6.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/mycp/workspace/SomeProject/target/testjar-1.1.6.jar to /home/mycp/.m2/repository/com/test/te/testjar/1.1.6/testjar-1.1.6.jar
[INFO] [jar:jar {execution: driver}]
[INFO] Building jar: /home/mycp/workspace/TestProject/target/driver.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11 seconds
[INFO] Finished at: Wed Oct 28 17:27:10 IST 2015
[INFO] Final Memory: 129M/888M
[INFO] ------------------------------------------------------------------------
Why the 2nd jar (driver.jar) is not versioned (driver-1.1.6.jar) ?
Why the 2nd jar not installed in local repo?
How to do this?
My requirement is create two jars testjar-${project.version}.jar driver-${project.version}.jar and install those two in two different artifact
/home/mycp/.m2/repossitory/com/test/te/testjar/${project-version}/testjar-${project.version}.jar
/home/mycp/.m2/repossitory/com/test/te/driver/${project-version}/driver-${project.version}.jar

Why the 2nd jar (driver.jar) is not versioned (driver-1.1.6.jar) ?
That is because you explicitely told the maven-jar-plugin that its name should be driver with <finalName>driver</finalName>. If you want to the version to be appended, you will need to have the following configuration: <finalName>driver-${project.version}</finalName>.
Why the 2nd jar not installed in local repo?
That is because you have specified a phase of <phase>install</phase>, so it will executed after the default-install execution, which is the execution that installs artefact to the local repository. Instead, you should bind that execution to the package phase.
This is the configuration you should have for the maven-jar-plugin. A classifier is needed to create another jar.
<execution>
<id>drive</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<finalName>driver-${project.version}</finalName>
<classifier>classifier</classifier>
<includes>
<include>com/test/te/p1/*.java</include>
<include>com/test/te/p1/*.class</include>
</includes>
</configuration>
</execution>
As a side note, I noticed that you also configured a <resources> element in your POM including Java and conf files. You should not have that. More specifically: all the resources should be placed under src/main/resources and all Java files under src/main/java. Then there is no need for that configuration.
Following from the comments, if you can't add a classifier, then you have to drop maven-jar-plugin and use maven-assembly-plugin instead. This is a simple assembly descriptor that will get you started. Place this file under src/main/assembly/assembly.xml.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>driver</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<unpackOptions>
<includes>
<include>com/test/te/p1/*.class</include>
</includes>
</unpackOptions>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</assembly>
with the following configuration in the POM:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor> <!-- point to the location of the assembly.xml file in your project structure -->
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<finalName>driver-${project.version}</finalName>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

Related

Maven War Plugin: Copy webResources after resources

I am using the maven-war-plugin to copy the webapp resources and a few external resources to the target directory and then build the war file.
Here is the plugin configuration,
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- Importing React App which is not in the build path -->
<webResources>
<resource>
<directory>react/build</directory>
<targetPath>ui/build</targetPath>
</resource>
</webResources>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
This configuration works well, but the external resources (webResources) are copied first and then the build path content is copied.
Build steps,
Copy external resources (webResources)
Copy resources from build path (warSourceDirectory)
Build War file.
This is an extract from the maven build logs,
[INFO] --- maven-war-plugin:2.2:war (default-war) # ReactProject ---
...
[INFO] Copying webapp webResources [...\react\build] to [...\target\ReactProject-0.0.1]
[DEBUG] + \ui\build\app.js has been copied.
...
[INFO] Copying webapp resources [...\ReactProject\src\main\webapp]
[DEBUG] + \ui\html\index.html has been copied.
...
[INFO] Building war: ...\ReactProject\target\ReactProject-0.0.1.war
Due to this behavior if similar content is present in the build path it overwrites the content copied from the react folder. Also, it would be more intuitive if the external content is copied after the build path resources are configured.
Is there a way to configure the webResources to be copied after the main resources?
Complete pom file
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>ReactProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ReactProject</name>
<description>React Project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- Importing React App which is not in the build path -->
<webResources>
<resource>
<directory>react/build</directory>
<targetPath>ui/build</targetPath>
</resource>
</webResources>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Maven deploying twice

I am having an issue where my artifact is deploying twice when I run
mvn deploy
[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (deploy-file) # 1.0 ---
Uploading to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/https/1.0-https.zip
Uploaded to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/https/1.0-https.zip (334 MB at 8.1 MB/s)
Uploading to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/https/1.0-https.pom
Uploaded to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/https/1.0-https.pom (423 B at 795 B/s)
Downloading from ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/maven-metadata.xml
Downloaded from ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/maven-metadata.xml (310 B at 1.5 kB/s)
Uploading to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/maven-metadata.xml
Uploaded to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/maven-metadata.xml (336 B at 614 B/s)
Uploading to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/https/1.0-https.zip
Uploaded to ProductSuite: http://abc.123:8081/nexus/repository/ProductSuite/Dev/Release/webUI/1.0/https/1.0-https.zip (334 MB at 7.2 MB/s)
After looking up some fixes for this I came across a potential fix:
I would simply have to added the following to the maven-assembly-plugin
<attach>false</attach>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:04 min
[INFO] Finished at: 2021-01-05T16:10:44-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project 11.8: The packaging for this project did not assign a file to the build artifact -> [Help 1]
[ERROR]
Below is what I'm currently working with. It works without the attach configuration but fails with it in there.
Any help is greatly appreciated. Thanks!
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Dev.Release.productA</groupId>
<artifactId>11.8</artifactId>
<version>https</version>
<url>https://maven.apache.org</url>
<properties>
<COMPANYRepositoryUrl>http://abc.123:8081/nexus</COMPANYRepositoryUrl>
<product>productA</product>
</properties>
<distributionManagement>
<repository>
<id>PROD</id>
<url>${PRODRepositoryUrl}/repository/PROD/</url>
</repository>
</distributionManagement>
<!--
| Where to deploy our built artifacts.
+ -->
<build>
<!--
| Define versions of plugins to ensure stable builds.
+
-->
<plugins>
<!--
| Standard maven plugins.
| Note: enforcer plugin is used (initialize) to ensure all plugins are versioned
| Or use $ mvn enforcer:enforce" to check
| Note: to check on the latest version of plugins available do:
| $ mvn versions:display-plugin-updates
+ -->
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
<configuration>
<file>${basedir}/target/${project.artifactId}-${project.version}.zip</file>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<!-- disable standard deploy -->
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
<execution>
<phase>deploy</phase>
<configuration>
<file>${basedir}/target/${project.artifactId}-${project.version}.zip</file>
<repositoryId>TEST</repositoryId>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<url>${COMPANYRepositoryUrl}/repository/TEST/</url>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>C:\PATH\to\webui.exe</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>
I had to add a section to the default execution of the maven-install-plugin. I can run mvn deploy without duplicate uploads which saves a minute in deployment time. (I also updated some of the plugins to newer versions)
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
<configuration>
<file>${basedir}/target/${project.artifactId}-${project.version}.zip</file>
</configuration>
</execution>
</executions>
</plugin>

maven assembly plugin tgz - no such archiver

I need to do a really simple tar action using the maven-assembly-plugin.
My file extension must be .tgz not tar.gz
Here is my pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>default-cli</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}</finalName>
<descriptors>
<descriptor>dist-all.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
and here is my assembly description file
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>default-cli</id>
<formats>
<format>tgz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/app</directory>
<outputDirectory>target</outputDirectory>
</fileSet>
</fileSets>
</assembly>
when I run mvn clean install it generates the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:single (default-cli) on project my-app: Failed to create assembly: Unable to obtain archiver for extension 'tgz', for assembly: 'default-cli': No such archiver: 'tgz'. -> [Help 1]
[ERROR]
According to the maven page I am allowed 'tgz' format.
https://maven.apache.org/plugins/maven-assembly-plugin/assembly.html
What have I missed?
I'd be grateful for any help,

How to skip Maven plugin parent pom execution?

I have a parent aggregator POM with multiple modules. I have a build/pluginManagement in the parent since plugin execution is the same for each sub module.
If I execute in each sub module (mvn package) it works fine. If I execute in the parent: mvn package -Pmytest, I want to skip plugin execution in the parent module, so I added:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
However, it's not working.
Parent 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xyz.jboss.config</groupId>
<artifactId>jboss-config</artifactId>
<packaging>pom</packaging>
<version>1.2-SNAPSHOT</version>
<name>jboss-config</name>
<url>http://maven.apache.org</url>
<profiles>
<profile>
<id>mytest</id>
<modules>
<module>jboss-system-properties</module>
<module>jboss-security</module>
</modules>
</profile>
</profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>process-package</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/processed/scripts</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources/scripts</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>process-clean</id>
<phase>clean</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/processed/scripts</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources/scripts</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>add-${project.artifactId}</id>
<phase>package</phase>
<goals>
<goal>execute-commands</goal>
</goals>
<configuration>
<execute-commands>
<scripts>
<script>${basedir}/processed/scripts/add-${project.artifactId}.cli</script>
</scripts>
</execute-commands>
</configuration>
</execution>
<execution>
<id>remove-${project.artifactId}</id>
<phase>clean</phase>
<goals>
<goal>execute-commands</goal>
</goals>
<configuration>
<execute-commands>
<scripts>
<script>${basedir}/processed/scripts/remove-${project.artifactId}.cli</script>
</scripts>
</execute-commands>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Child 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xyz.jboss.config</groupId>
<artifactId>jboss-config</artifactId>
<version>1.2-SNAPSHOT</version>
</parent>
<artifactId>jboss-system-properties</artifactId>
<packaging>ear</packaging>
<name>jboss-system-properties</name>
<url>http://maven.apache.org</url>
</project>
I'm getting a file not found error. The file is not supposed to exists here. The issue is why it's not skipping parent module execution.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] jboss-config ....................................... FAILURE [ 20.238 s]
[INFO] jboss-system-properties ............................ SKIPPED
[INFO] jboss-security ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:
execute-commands (add-jboss-config) on project jboss-config:
Execution add-jboss-config of goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:execute-commands failed:
Failed to process file 'H:\projects\xyz\jboss\trunk\jboss-configuration\processed\scripts\add-jboss-config.cli':
H:\projects\xyz\jboss\trunk\jboss-configuration\processed\scripts\add-jboss-config.cli
(The system cannot find the path specified)
I found the issue. If the execution id is parameterized, in my case:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>add-${project.artifactId}</id>
...
...
<executions>
<execution>
<id>remove-${project.artifactId}</id>
...
...
to skip plugin execution, you'd have to explicitly specify the execution id and phase:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>add-jboss-config</id>
<phase/>
</execution>
<execution>
<id>remove-jboss-config</id>
<phase/>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Now, it skips the parent, executes in all the children modules, and I only have one place for plugin configuration.
Note: I tried using static execution ids, but it has the side effect of skipping execution in the children modules as well. Also, I'm not sure if all of these issues are just in wildfly-maven-plugin.

Maven exec plugin execution conundrum

Sample maven build file:
<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>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>my-validation-one</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>echo</executable>
<arguments>
<argument>"My validation one"</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>my-validation-two</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>echo</executable>
<arguments>
<argument>"My validation two"</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>
</project>
Sample maven output:
$ mvn install
/cygdrive/c/Program Files/Java/jdk1.5.0_20/bin/java -classpath C:\Program Files\Apache Software Foundation\apache-maven-2.2.1/boot/classworlds-1.1.jar -Dclassworlds.conf=C:\Program Files\Apache Software Foundation\apache-maven-2.2.1/bin/m2.conf -Dmaven.home=C:\Program Files\Apache Software Foundation\apache-maven-2.2.1 org.codehaus.classworlds.Launcher "install"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - test:test:jar:1.0.0
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [exec:exec {execution: my-validation-one}]
[INFO] "My validation two"
[INFO] [exec:exec {execution: my-validation-two}]
[INFO] "My validation two"
[INFO] [resources:resources {execution: default-resources}]
<snip>
Shouldn't my-validation-one echo "My validation one" to the console? Why does it seem like maven is getting its wires crossed?
Thanks,
Steven
You should put the configuration specific to the execution within the execution block. Then it should work correctly.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>my-validation-two</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>echo</executable>
<arguments>
<argument>"My validation two"</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Also, if both the executions are bound to same phase and goal, you can combine then within executions block instead of declaring the plugin twice.

Resources