选择多个配置文件时,wildfly-maven-plugin无法部署 [英] wildfly-maven-plugin not deploying when multiple profiles selected

查看:79
本文介绍了选择多个配置文件时,wildfly-maven-plugin无法部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究POM.xml,以根据环境已安装的应用程序将WAR文件部署到Wildfly服务器.我合作的项目有3个不同的应用程序,并且环境中可能安装了这些应用程序中的1-3个.

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.

因此,我已经为每个应用程序创建了配置文件-如果已安装应用程序A,请运行应用程序A配置文件以将A应用程序部署到服务器.如果安装了B,请运行应用B的配置文件,等等.

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.

问题是,当我使用多个应用程序(例如,应用程序A和应用程序B)运行Maven构建时,它只会部署其中一个.如果我在每个配置文件上分别运行单独的Maven构建,则部署会很好.我认为我的问题是maven-wildfly-plugin本身,因为当使用多个配置文件运行时,使用Maven help:active-profiles 选项时它们显示为活动状态:

The problem is that when I run my Maven build with more than one app, (e.g. 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)

构建本身的输出如下:

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

在这种情况下, deploy-a deploy-b 配置文件似乎都可以运行,但是只有 deploy-b 的应用程序可以运行已成功部署.我的POM.xml如下:

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>

我正在使用 mvn deploy -Pwildfly-deploy-a,wildfly-deploy-b 执行它.我将配置文件传递给Maven的顺序似乎无关紧要-它始终部署在POM中最后一个配置文件中定义的应用程序(因此,应用程序b).我还尝试了 mvn deploy -Pwildfly-deploy-a -Pwildfly-deploy-b ,但这也不起作用.

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.

我违反一些Maven最佳做法或此处的某些规定吗?我今天研究的所有内容都表明这应该可行,这就是为什么我有点怀疑插件会导致此行为的原因.

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.

编辑-我还尝试通过使其中一个配置文件使用 deploy 目标而另一个配置文件使用 deploy-artifact 目标,但我得到相同的行为.这可能是网络或线程问题吗?

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?

编辑2 -其他奇怪的行为:当两个配置文件都使用 deploy 目标而不是 deploy-artifact 的应用程序已部署...使用 deploy 单独运行时,它们会很好地部署.

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.

这篇关于选择多个配置文件时,wildfly-maven-plugin无法部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆