部署多个maven配置文件

时间:2016-12-12 14:53:26

标签: maven tomcat weblogic cargo-maven2-plugin

我希望同时通过warcargo:deploy部署到Tomcat 7和Weblogic容器中。目前我只能让一个配置文件一次处于活动状态。

以下是我目前的情况:

<profiles>
    <!--  *********************************************************************
                          CARGO - FOR TOMCAT.
                          Activated when file ${env.USERPROFILE}/foo.bar exists (which should be there after successful Tomcat tookit install)
              ********************************************************************* -->
    <profile>
        <id>tomcat</id>
        <activation>
            <file><exists>${env.USERPROFILE}/foo.bar</exists></file>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>${cargo-maven2-plugin.version}</version>
                    <configuration>
                        <container>
                            <containerId>tomcat7x</containerId>
                            <type>installed</type>
                            <home>${env.USERPROFILE}/foo/apache-tomcat-7.0.57</home>
                            <timeout>180000</timeout>
                        </container>
                        <configuration>
                            <type>existing</type>
                            <home>${env.USERPROFILE}/foo/apache-tomcat-7.0.57</home>
                        </configuration>
                        <deployables>
                            <deployable>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>${project.artifactId}</artifactId>
                                <type>war</type>
                                <properties>
                                    <!--No slash needed before the context-->
                                    <context>sec-captc</context>
                                </properties>
                            </deployable>
                        </deployables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>


  <!--  *********************************************************************
                              CARGO - FOR WEBLOGIC
                    ********************************************************************* -->
    <profile>
        <id>weblogic</id>
        <activation>
            <file><exists>${env.USERPROFILE}/foo.bar</exists></file>
        </activation>
        <build><plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>${cargo-maven2-plugin.version}</version>
                <configuration>
                    <container>
                        <containerId>weblogic12x</containerId>
                        <type>installed</type>
                        <home>${installed-weblogic.home}/foo</home>
                        <timeout>180000</timeout>
                    </container>
                    <configuration>
                        <type>existing</type>
                        <home>${installed-weblogic.domain}</home>
                    </configuration>
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <type>war</type>
                            <properties>
                                <context>/${installed-weblogic.war.contextpath}</context>
                            </properties>
                        </deployable>
                    </deployables>
                </configuration>
            </plugin>
        </plugins></build>
    </profile>
</profiles>

我需要添加/更改以便能够同时进行这些工作吗?

1 个答案:

答案 0 :(得分:0)

您确定只有一个个人资料有效吗?可能两者都是活动的,但cargo-maven2-plugin插件执行使用相同的ID,因此只执行一次。

在配置文件中,看起来您已为每个服务器配置,但没有插件执行。尝试将执行添加到未运行的配置文件中的cargo-maven2-plugin。将执行ID设置为“deploy-tomcat”。看看是否有帮助。

在调试模式下运行Maven(使用BUILD_WITH_INSTALL_RPATH)可能会帮助您了解正在发生的事情。

相关问题