Maven multiple profile not working

江枫思渺然 提交于 2019-12-23 18:53:19

问题


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

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

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)

Am I missing something?

Thanks,

--

SJunejo


回答1:


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.

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

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.



来源:https://stackoverflow.com/questions/16697623/maven-multiple-profile-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!