What is the default phase for tomcat7 maven plugin?

I want my build process to deploy my war on a remote server. so far i have run mvn clean install tomcat7:deploy

This seems wrong to me, as it probably should be part of the deploy phase. But if I try to do mvn deploy , I get:

 Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter 

Since I did not define any repository for deployment (I really do not want to deploy to a remote repository, just using this phase to execute the tomcat maven plugin ...)

I want to be able to run the tomcat maven plugin without deploying to any remote repository. Is it possible?

+7
source share
3 answers

The plugin is not executed by default. You must add execution to it or call it like you do (fe Mvn clean install tomcat7: deploy).

Deploying to Tomcat has nothing to do with the Maven deployment phase / deployment to a remote repository.

To associate a Tomcat deployment with a specific phase, add something similar to the configuration of your tomcat maven module:

  <executions> <execution> <id>tomcat-deploy</id> <phase>pre-integration-test</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> 

In this configuration, deployment to Tomcat will occur in the pre-integration phase, which is the most common phase for this, I suppose.

+7
source

The solution is to associate this with the profile.

 <profile> <id>webapp-deploy</id> .. <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <executions> <execution> <id>tomcat-deploy</id> <phase>install</phase> <goals> <goal>deploy-only</goal> </goals> </execution> </executions> </plugin> .. </profile> 

And just run -Pwebapp-deploy

+1
source

This is because Maven (in an aggravating decision) decided to co-opt the word “expand”. In the Maven world, deployment means you just created your binary and upload it / save it to your local maven repository. DO NOT deploy your newly created war on your server.

The fact that most Java developers will consider “publishing” an artifact is actually a “deployment” for maven.

This helps if you think maven is only a concern for creating with dependency management. Anything outside the building's dependency management requires special calls (such as tomcat7: redeploy) or another scripting environment.

+1
source

All Articles