Maven exec plugin execution conundrum - maven

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.

Related

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>

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

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.

Maven runs profile executions only after the build executions

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.

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>

Resources