简体   繁体   中英

What is the default phase for tomcat7 maven plugin?

I want my build process to deploy my war to a remote server. until now i have ran mvn clean install tomcat7:deploy

This seem wrong to me as it should probably be part of the deploy phase. But if I try to do a 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 haven't defined any repository to deploy to (I don't really 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 that possible ?

The plugin doesn't execute by default. You have to add an execution to it, or call it like you did(fe mvn clean install tomcat7:deploy).

The deploy on Tomcat has nothing to do with the Maven deploy phase/deploying to a remote repository.

To bind the Tomcat deployment to a certain phase, add something like this to your tomcat maven plugin configuration:

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

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

A solution is to bind that to a 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

This is because Maven (in a super aggravating decision) decided to co-opt the word "deploy." In the Maven world, deploy means take your binary you just built and upload it / store it in your local maven repository. NOT deploy your newly built war to your server.

What most java developers would consider "publishing" an artifact is actually a "deploy" to maven.

It helps if you consider maven as only caring about build with dependency management. Anything outside of building dependency management requires special calls (like tomcat7:redeploy) or a different scripting environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM