I am working on a POM.xml to deploy WAR files to a Wildfly server depending on what apps that environment has installed. The project I work with has 3 different applications, and an environment could have between 1 and 3 of these apps installed.
So, I've made profiles for each of the apps -- If app A is installed, run the app A profile to deploy the A app to the server. If B is installed, run the app B profile, etc.
The problem is that when I run my Maven build with more than one app, (eg app A and app B), it only deploys one of them. If I run separate Maven builds on each profile individually, it deploys fine. I think my problem is with the maven-wildfly-plugin itself, as when running with multiple profiles, they show as active when using the Maven help:active-profiles
option:
[INFO]
Active Profiles for Project 'com.foo.bar:auto-deploy:pom:1.0.0-SNAPSHOT':
The following profiles are active:
- wildfly-deploy-a (source: com.foo.bar:auto-deploy:1.0.0-SNAPSHOT)
- wildfly-deploy-b (source: com.foo.bar:auto-deploy:1.0.0-SNAPSHOT)
The output of the build itself is as follows:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Auto-Deploy Wildfly 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ auto-deploy ---
[INFO] Installing C:\..........\AutoDeploy\pom.xml to C:\.....\.m2\repository\com\foo\bar\auto-deploy\1.0.0-SNAPSHOT\auto-deploy-1.0.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ auto-deploy ---
[INFO] Skipping artifact deployment
[INFO]
[INFO] --- wildfly-maven-plugin:1.1.0.Alpha11:deploy-artifact (deploy-a) @ auto-deploy ---
Apr 03, 2017 5:31:52 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.1.Final
Apr 03, 2017 5:31:52 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.1.Final
Apr 03, 2017 5:31:53 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.9.Final
[INFO] Authenticating against security realm: ManagementRealm
[INFO]
[INFO] --- wildfly-maven-plugin:1.1.0.Alpha11:deploy-artifact (deploy-b) @ auto-deploy ---
[INFO] Authenticating against security realm: ManagementRealm
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.615 s
[INFO] Finished at: 2017-04-03T17:32:06-04:00
[INFO] Final Memory: 20M/210M
[INFO] ------------------------------------------------------------------------
In this case, both the deploy-a
and deploy-b
profiles appear to run, but only the app for deploy-b
is successfully deployed. My POM.xml is below:
<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>auto-deploy</artifactId>
<packaging>pom</packaging>
<name>Auto-Deploy Wildfly</name>
<parent>
<groupId>com.foo.bar</groupId>
<artifactId>parent-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties>
<wildfly.deploy.version>1.0.2.Final</wildfly.deploy.version>
<wildfly.hostname>localhost</wildfly.hostname>
<wildfly.mgmt.native.port>9999</wildfly.mgmt.native.port>
</properties>
<dependencies>
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>app-a</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>app-b</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.1.0.Alpha11</version>
<configuration>
<force>true</force>
<protocol>remote</protocol>
<hostname>${wildfly.hostname}</hostname>
<port>${wildfly.mgmt.native.port}</port>
<username>${wildfly.mgmt.username}</username>
<password>${wildfly.mgmt.password}</password>
<timeout>120</timeout>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>wildfly-deploy-a</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<groupId>com.foo.bar</groupId>
<artifactId>app-a</artifactId>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>deploy-a</id>
<phase>deploy</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
</execution>
...
</profile>
<profile>
<id>wildfly-deploy-b</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<groupId>com.foo.bar</groupId>
<artifactId>app-b</artifactId>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>deploy-b</id>
<phase>deploy</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
</execution>
...
</profile>
</profiles>
</project>
And I am executing it using mvn deploy -Pwildfly-deploy-a,wildfly-deploy-b
. The order in which I pass the profiles to Maven does not seem to matter -- it always deploys the app defined in the last profile in the POM (so app b). I have also tried mvn deploy -Pwildfly-deploy-a -Pwildfly-deploy-b
and that does not work either.
Am I violating some Maven best practices or something here? Everything I've researched today indicates that this should work, which is why I have an inkling that the plugin is causing this behavior.
EDIT -- I've also tried mixing it up by making one of the profiles use the deploy
goal and the other use the deploy-artifact
goal but I get the same behavior. Could this be some network or threading issue?
EDIT 2 -- Other weird behavior: when both profiles use the deploy
goal as opposed to deploy-artifact
, neither of the apps gets deployed...when run individually using deploy
they will deploy fine.
Your plugin configuration cannot be merged; the second will always override the first.
The trick is to move the configuration into the execution section:
<profiles>
<profile>
<id>wildfly-deploy-a</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-a</id>
<phase>deploy</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
<configuration>
<groupId>com.foo.bar</groupId>
<artifactId>app-a</artifactId>
<skip>false</skip>
</configuration>
</execution>
...
</profile>
<profile>
<id>wildfly-deploy-b</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-b</id>
<phase>deploy</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
<configuration>
<groupId>com.foo.bar</groupId>
<artifactId>app-b</artifactId>
<skip>false</skip>
</configuration>
</execution>
...
</profile>
</profiles>
Now each execution has it's own configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.