Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.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?

like image 342
Dónal Avatar asked Jun 29 '11 09:06

Dónal


People also ask

What is the final phase for the default life cycle in Maven?

Now, let's try a "mvn deploy" on the project containing the above pom. xml file. The deploy phase is the last phase of the default lifecycle. Since it is the last phase, all phases of the lifecycle will be executed.

What are the 3 build lifecycle of Maven?

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.

How many phases are there in default lifecycle of Maven?

Maven Lifecycle: Below is a representation of the default Maven lifecycle and its 8 steps: Validate, Compile, Test, Package, Integration test, Verify, Install and Deploy.


3 Answers

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.

like image 73
artbristol Avatar answered Oct 06 '22 05:10

artbristol


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>
like image 20
Esteve Avatar answered Oct 06 '22 05:10

Esteve


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>
like image 22
Benjyyyyy Avatar answered Oct 06 '22 06:10

Benjyyyyy