Maven runs profile executions only after the build executions - maven

Given a following maven pom.xml development profile
<profiles>
<profile>
<id>development</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.4</version>
<executions>
<execution>
<id>01-liquibase.dropAll</id>
<phase>process-resources</phase>
<configuration>
[...skip...]
</configuration>
<goals>
<goal>dropAll</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
and main section of pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<includes>package/pm/entity/**/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<persistenceXmlFile>${project.parent.basedir}/forms-webapp/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
</configuration>
<executions>
<execution>
<id>02-enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.4</version>
<executions>
<execution>
<id>03-liquibase.update</id>
<phase>process-resources</phase>
<configuration>
[...skipped...]
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
<!-- for tests -->
<execution>
<id>04-liquibase-test.dropAll</id>
<phase>process-test-resources</phase>
<configuration>
[...skipped...]
</configuration>
<goals>
<goal>dropAll</goal>
</goals>
</execution>
<execution>
<id>05-liquibase-test.update</id>
<phase>process-test-resources</phase>
<configuration>
[...skipped...]
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I expect that executions will run in the following order:
....
01-liquibase.dropAll
03-liquibase.update
....
But in build log I see:
[INFO] --- liquibase-maven-plugin:3.0.4:update (03-liquibase.update) # forms-entity ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost/pman_trunk
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO]
[INFO] --- liquibase-maven-plugin:3.0.4:dropAll (01-liquibase.dropAll) # forms-entity ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost/pman_trunk
[INFO] ------------------------------------------------------------------------
Is there any way to fix this wrong execution order?

The executions for id 01-liquibase.dropAll and 03-liquibase.update are executing on the same phase.
You could always move the execution with id 01-liquibase.dropAll to an earlier phase such as generate-resources
<id>01-liquibase.dropAll</id>
<phase>process-resources</phase>
See the Default Lifecycle section in Maven Lifecycle Reference.

Related

How to profile JavaFX maven project in NetBeans

When I try to profile JavaFX project in Netbeans 8.2 I get following build error:
cd C:\Users\David\Documents\NetBeansProjects\FxClock; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_101" cmd /c "\"\"C:\\Program Files\\NetBeans 8.2\\java\\maven\\bin\\mvn.bat\" -Dexec.args.merged=true -Dexec.args=\"-agentpath:\\\"C:/Program Files/NetBeans 8.2/profiler/lib/deployed/jdk16/windows-amd64/profilerinterface.dll\\\"=\\\"C:\\Program Files\\NetBeans 8.2\\profiler\\lib\\\",5140,10 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\\Users\\David\\AppData\\Local\\NetBeans\\Cache\\8.2\\mavencachedirs\\521057086\\org-netbeans-modules-profiler -createjar -nocss2bin -appclass com.upce.fxclock.MainApp -srcdir C:\\Users\\David\\Documents\\NetBeansProjects\\FxClock\\target/classes -outdir C:\\Users\\David\\Documents\\NetBeansProjects\\FxClock\\target -outfile FxClock-1.0-SNAPSHOT.jar\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_101\\bin\\java.exe\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Default 'profile' action exec.args merged with maven-exec-plugin arguments declared in pom.xml.
Scanning for projects...
------------------------------------------------------------------------
Building FxClock 1.0-SNAPSHOT
------------------------------------------------------------------------
--- maven-resources-plugin:2.5:resources (default-resources) # FxClock ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 5 resources
--- maven-compiler-plugin:3.1:compile (default-compile) # FxClock ---
Nothing to compile - all classes are up to date
--- exec-maven-plugin:1.2.1:exec (default-cli) # FxClock ---
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: -createjar
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.158s
Finished at: Sun May 14 23:35:56 CEST 2017
Final Memory: 7M/155M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project FxClock: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
when I open the nbactions.xml, the profile action is not set, so it uses default one which fails to build.
nbactions.xml:
<actions>
<action>
<actionName>run</actionName>
<goals>
<goal>clean</goal>
<goal>package</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<runfx.args>-jar "${project.build.directory}/${project.build.finalName}.jar"</runfx.args>
</properties>
</action>
<action>
<actionName>debug</actionName>
<goals>
<goal>clean</goal>
<goal>package</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<runfx.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dglass.disableGrab=true -jar "${project.build.directory}/${project.build.finalName}.jar"</runfx.args>
<jpda.listen>true</jpda.listen>
</properties>
</action>
</actions>
Is there a way to setup profiling with that <runfx.args> tag.
Here is pom.xml, I only changed the <target> & <source> to 1.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.upce</groupId>
<artifactId>FxClock</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FxClock</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.upce.fxclock.MainApp</mainClass>
</properties>
<organization>
<!-- Used as the 'Vendor' for JNLP generation -->
<name>Your Organisation</name>
</organization>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/../bin/javafxpackager</executable>
<arguments>
<argument>-createjar</argument>
<argument>-nocss2bin</argument>
<argument>-appclass</argument>
<argument>${mainClass}</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}/classes</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}</argument>
<argument>-outfile</argument>
<argument>${project.build.finalName}.jar</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>${runfx.args}</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.gavaghan</groupId>
<artifactId>geodesy</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.9</version>
</dependency>
</dependencies>
</project>
Workaround: Use external profiling
In NetBeans:
Run project normaly
Profile -> Attach to external process
Press Attach
Select the running java process to profile
This might not work when you need to profile startup of the application

How to generate Jacoco integration test report using offline instrumentation?

Build tool: Maven
Reason to use offline instrumentation: Removing Powermock is not an option
Problem:
Both failsafe and surefire are run and reports are generated. However, jacoco.exec is generate but jacoco-it.exec is not. Apart from IT , offline instrumentation, coverage and reporting works fine.
This is the maven plugin configuration I use:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
To run the test i use maven clean install.
At the end of the test execution I get the following output:
[INFO]
[INFO] --- maven-failsafe-plugin:2.15:integration-test (integration-tests) # elune ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) # elune ---
[INFO] Loading execution data file C:\Projects\elune\target\jacoco.exec
[INFO] Analyzed bundle 'elune' with 4 classes
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report-integration (default-report-integration) # elune ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
Another possible pointer might be that the de-instrumentation of the classes happens after the unit tests are run but before the integration tests. But I don't know if this is right or wrong:
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:restore-instrumented-classes (default-restore-instrumented-classes) # elune ---
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) # elune ---
[INFO] Building jar: C:\Projects\elune\target\elune-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) # elune ---
[INFO]
[INFO] --- maven-failsafe-plugin:2.15:integration-test (default) # elune ---
[INFO] Failsafe report directory: C:\Projects\elune\target\failsafe-reports
Any idea why the jacoco-it.exec is not showing up?
I think the instrumentation of Integration Tests with the failsafe plugin are just not baked in. The restore-instrumented-classes goal defaults to the prepare-package phase which runs before the integration test phase: http://maven.apache.org/ref/3.3.9/maven-core/lifecycles.html - so it may be enough to move that goal into the post-integration-test phase:
<execution>
<id>default-restore-instrumented-classes</id>
<phase>post-integration-test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
that may be enough. Otherwise you may be able to change the includes pattern of the surefire plugin to also include the integration tests (if that seems suitable in your case).
#rhinoceros.xn this is the plugin configuration that did the trick for me. But I use mvn clean install to run this
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<phase>post-integration-test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
</executions>
</plugin>
The jacoco-it.exec is not showing up after I set the phrase.
command line is:
mvn clean install -Djacoco.version=0.7.8 -DfailOnError=false -Dmaven.test.failure.ignore=true
I finally found the problem was that I didn't add configuration jacoco-agent.destfile in maven-failsafe-plugin.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco-it.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<phase>post-integration-test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

Maven plugin execution order

I have problem with ordering Maven plugin executions.
I would like to execute the plugins in declaration order:
<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>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>task-1</id>
<goals>
<goal>run</goal>
</goals>
<phase>initialize</phase>
<configuration>
<target>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>task-2</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/c</argument>
<argument>rem</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>task-3</id>
<goals>
<goal>run</goal>
</goals>
<phase>initialize</phase>
<configuration>
<target>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I expected the execution order: task-1, task-2, task-3
But after executing mvn initialize, the actual order is task-1, task-3, task-2:
[INFO] --- maven-antrun-plugin:1.3:run (task-1) # test ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (task-3) # test ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (task-2) # test ---
What should I change to execute the plugins in the order I want?
I expect that Maven warned about a duplicate plugin, i.e. maven-antrun-plugin. Maven cannot have duplicate plugins, so the result is that the executionblock of task-3 is merged into the first maven-antrun-plugin.
And now Maven will go through all plugins, top-down and look for execution blocks bound to the validate-phase.
This explains the result.
Is there an option to control the order in this case? No, not within the same phase.

All maven flyway plugins are executed with the last user

I have two oracle users and I am creating different schema for them. I mean each schema has different tables, types etc.
I wanted to create both schemas by flyway maven plugin, first I had two maven plugins, but then I tried also to have two separate profiles:
<profiles>
<profile>
<id>database</id>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<configuration>
<url>jdbc:oracle:thin:#devdb2:1521:ZOOMUTF</url>
<table>SCHEMA_UPDATES</table>
<outOfOrder>true</outOfOrder>
<locations>
<location>db/callrec</location>
</locations>
<user>cr_5199_mensik_mvn</user>
<password>callrec</password>
<serverId>callrec</serverId>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>database_wbsc</id>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<configuration>
<url>jdbc:oracle:thin:#devdb2:1521:ZOOMUTF</url>
<table>SCHEMA_UPDATES</table>
<outOfOrder>true</outOfOrder>
<locations>
<location>db/wbsc</location>
</locations>
<user>sc_5199_mensik_mvn</user>
<password>wbsc</password>
<serverId>wbsc</serverId>
</configuration>
<executions>
<execution>
<id>wbsc_compile</id>
<phase>compile</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
<execution>
<id>wbsc_clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Then I execute:
mvn clean -Pdatabase,database_wbsc
But result is that only second profile is executed twice:
[INFO] [clean:clean {execution: default-clean}]
[INFO] [flyway:clean {execution: clean}]
[INFO] Cleaned schema "sc_5199_mensik_mvn" (execution time 00:00.023s)
[INFO] [flyway:clean {execution: wbsc_clean}]
[INFO] Cleaned schema "sc_5199_mensik_mvn" (execution time 00:00.018s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
If I switch order of profiles in xml (not in maven execution command) then the second user is used.
How can I execute both profiles but with their configuration?
try providing the configuration at the execution level rather than the plugin level.
<plugin>
<executions>
<execution>
<id>execution1</id>
<configuration>
</configuration>
</execution>
<execution>
<id>execution2</id>
<configuration>
</configuration>
</execution>
</executions>
</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