2017-04-03 3 views
0

Ich arbeite an einer POM.xml, um WAR-Dateien auf einem Wildfly-Server bereitzustellen, abhängig davon, welche Apps in dieser Umgebung installiert sind. Das Projekt, mit dem ich arbeite, hat 3 verschiedene Anwendungen, und in einer Umgebung könnten zwischen 1 und 3 dieser Apps installiert sein.wildfly-maven-plugin wird nicht bereitgestellt, wenn mehrere Profile ausgewählt wurden

Also habe ich Profile für jede der Apps erstellt - Wenn App A installiert ist, führe die App Ein Profil aus, um die A-App auf dem Server bereitzustellen. Wenn B installiert ist, führe das App-B-Profil usw. aus.

Das Problem ist, dass wenn ich meinen Maven-Build mit mehr als einer App (z. B. App A und App B) starte, nur einen von ihnen implementiert. Wenn ich separate Maven-Builds für jedes Profil einzeln ausführe, wird es in Ordnung gebracht. Ich denken mein Problem mit dem Maven-Wildfly-Plugin selbst ist, als wenn sie mit mehreren Profilen ausgeführt wird, zeigen sie als aktiv, wenn die 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) 

Der Ausgang des Build sich wie folgt :

[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 diesem Fall sind sowohl die deploy-a und deploy-b Profile erscheinen zu laufen, aber nur die App für deploy-b ist erfolgreich im Einsatz. Mein pom.xml ist unten:

<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> 

Und ich bin Ausführung es mvn deploy -Pwildfly-deploy-a,wildfly-deploy-b verwenden. Die Reihenfolge, in der ich die Profile an Maven übergebe, scheint keine Rolle zu spielen - es wird immer die im letzten Profil im POM definierte App eingesetzt (also App b). Ich habe auch versucht mvn deploy -Pwildfly-deploy-a -Pwildfly-deploy-b und das funktioniert auch nicht.

Verstoße ich gegen einige Maven Best Practices oder etwas hier? Alles, was ich heute erforscht habe, deutet darauf hin, dass dies funktionieren sollte, weshalb ich eine Ahnung habe, dass das Plugin dieses Verhalten verursacht.

EDIT - Ich habe auch versucht es, indem sie eines der Profile der deploy Ziel verwenden Vermischung und die andere Verwendung der deploy-artifact Ziel, aber ich das gleiche Verhalten zu bekommen. Könnte dies ein Netzwerk- oder Threading-Problem sein?

EDIT 2 - andere seltsame Verhalten: wenn beide Profile die deploy Ziel verwenden, wie zum deploy-artifact, im Gegensatz weder der Anwendungen eingesetzt wird ... wenn sie einzeln mit deploy laufen sie fein verteilen.

Antwort

1

Ihre Plugin-Konfiguration kann nicht zusammengeführt werden; Die zweite überschreibt immer die erste.

Der Trick ist, die Konfiguration in den Ausführungsabschnitt zu bewegen:

<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> 

Jetzt jede Ausführung verfügt über eine eigene Konfiguration ist.

+0

Danke, das hat es für mich behoben! Verschieben Sie jetzt die Konfiguration in den Ausführungsblock-Standard für jedes Maven-Plugin (bei Verwendung von Profilen)? – SourMonk

+0

Es ist unabhängig von Profilen. Sie können die Konfiguration tatsächlich aufteilen und den statischen Abschnitt (z. B. "" false ') dort ablegen, wo Sie ihn zuvor hatten und einfach die ausführungsspezifische Konfiguration am neuen Speicherort haben. Mit einigen Plugins können Sie eine Sequenz von Ausführungen ausführen, möglicherweise in verschiedenen Phasen. –

Verwandte Themen