Maven多个配置文件不起作用 [英] Maven multiple profile not working

查看:144
本文介绍了Maven多个配置文件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的战争上传到两个坟墓地点.为此,我在pom.xml中定义了以下配置文件;

I would like to upload my war onto two sepearet locations. For that I have defined following profile in my pom.xml;

   ........
    <profile>
    <id>deployPoc</id>
    <activation>
        <activeByDefault>false</activeByDefault>
    </activation>
    <properties>
        <jboss.host>POC_Deploy</jboss.host>
        <jboss.deployDir>/storage2/home/server1/</jboss.deployDir>
        <jboss.deployUrl>scp://server1.com</jboss.deployUrl>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-upload-plugin</artifactId>
                <version>1.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.wagon</groupId>
                        <artifactId>wagon-ssh</artifactId>
                        <version>2.4</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <resourceSrc>
                        ${project.build.directory}/${project.build.finalName}.${project.packaging}
                    </resourceSrc>
                    <resourceDest>${jboss.deployDir}</resourceDest>
                    <serverId>${jboss.host}</serverId>
                    <url>${jboss.deployUrl}</url>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
<profile>
    <id>uploadUpdate</id>
    <activation>
        <activeByDefault>false</activeByDefault>
    </activation>
    <properties>
        <updateReleaseHost>PluginReleaseSite</updateReleaseHost>
        <updateReleaseDir>/var/www/html/releases/Latest/</updateReleaseDir>
        <updateReleaseUrl>scp://server2.com</updateReleaseUrl>
    </properties>
    <build>
        <plugins>
            <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-upload-plugin</artifactId>
            <version>1.1</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.wagon</groupId>
                    <artifactId>wagon-ssh</artifactId>
                    <version>2.4</version>
                </dependency>
            </dependencies>
            <configuration>
                <resourceSrc>
                    ${project.build.directory}/${project.build.finalName}.${project.packaging}
                </resourceSrc>
                <resourceDest>${updateReleaseDir}</resourceDest>
                <serverId>${updateReleaseHost}</serverId>
                <url>${updateReleaseUrl}</url>
            </configuration>
          </plugin>
    </plugins>
  </build>
</profile>

我正在尝试使用以下命令执行它,并且只执行其中之一;

I am trying to execute both using following command and its only executing one of them;

mvn help:active-profiles upload:upload -PdeployPoc -PuploadUpdate

它仅执行'uploadUpdate',我尝试了所有操作,即-Pa,b; -P a,b等,等等.

Its only executing 'uploadUpdate', I have tried everything i.e. -Pa,b; -P a,b etc etc.

尽管maven显示以下内容,但似乎没有任何作用;

Nothing seems to be working though maven shows following;

The following profiles are active:

 - releaseRepository (source: external)
 - snapshotsRepository (source: external)
 - deployPoc (source: com.Project:1.0-SNAPSHOT)
 - uploadUpdate (source: com.Project:1.0-SNAPSHOT)

我想念什么吗?

谢谢

-

Junejo

推荐答案

基于配置文件,您使用的是相同的插件,这意味着您具有相同的执行方式,这意味着相同的执行ID(在您的情况下也相同).

Based on the profiles you are using the same plugin which means you have the same executions which means the same execution id which is the same in your case.

我建议对不同的ID使用显式执行.

I would suggest to use explicit executions with different Id's.

除上述内容外,我建议使用 jboss插件进行部署到不是Maven预期方法的应用程序服务器.

Apart from the above I would suggest to use the jboss plugin to deploy to an application server which is not the intended approach of Maven.

这篇关于Maven多个配置文件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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