replace default Maven lifecycle goals
When I run mvn deploy
in my project which has <packaging>war</packaging>
I get the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project store-service-impl: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
It appears that by default, the deploy:deploy
goal is bound to the deploy
lifecycle phase. In other words, Maven will try to deploy the generated artefact (a .war file in this case) to a remote repository when the deploy
lifecycle phase is run.
In my case, I want to deploy the war to a remote Tomcat instance rather than a remote Maven repository. I've added the following to the pom.xml
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<!--
<executions>
<execution>
<id>deploy-tomcat</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
-->
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>http://10.60.60.60:8080/manager</cargo.remote.uri>
<cargo.remote.username>jack</cargo.remote.开发者_JAVA百科username>
<cargo.remote.password>secret</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
</deployer>
</configuration>
</plugin>
This successfully deploys the .war when I run mvn cargo:deploy
. However, if I then bind this goal to the deploy
phase of the Maven lifecycle by uncommenting the <executions>
element, I get the aforementioned error.
It seems that the cargo:deploy
goal has been added to the goals bound to the deploy
phase, but I want to replace the deploy:deploy
goal that is bound to the deploy
lifecycle phase (by default) with the cargo:deploy
goal, is this possible?
You should bind cargo to pre-integration-test
instead of deploy
- then your failsafe tests can run against the deployed war file during the integration-test
phase. You would run the tests using mvn verify
.
You can try disabling the deploy plugin before configuring cargo:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
You can disable default deploy goal with maven-deploy-plugin on execution id default-deploy. Old thread, I put it here in case for someone.
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
精彩评论