3

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

SJunejo
  • 1,316
  • 4
  • 23
  • 39

1 Answers1

5

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.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • I have tried with multiple executions with unique execution Id, hard coded all the configurations and remove the profiles altogether. The plugin throws following exception; [ERROR] Failed to execute goal com.atlassian.maven.plugins:maven-upload-plugin:1.1:upload (default-cli) on project Hothouse: The parameters 'serverId', 'url', 'resourceSrc' for goal com.atlassian.maven.plugins:maven-upload-plugin:1.1:upload are missing or invalid -> [Help 1] :-( – SJunejo May 23 '13 at 09:17
  • As above comment is right, I can not execute two execution in one go. I have broken the job into two parts and execute mvn upload:upload -PXXX twice for each upload. I have used technique described here http://stackoverflow.com/questions/4360958/maven-wagon-plugin-can-wagonupload-upload-to-multiple-locations – SJunejo May 24 '13 at 08:19