Thiago Padilha
Thiago Padilha

Reputation: 4650

In Maven, how do I customize lifecycle phases?

I have separated a Java EE project in the following submodules:

I also have a root pom which includes the above modules. Since I have tests in a separate project, theres no point in running the test phases in the 3 first modules, as theres no point in compiling or packaging the last module since it only contains tests for the other 3 modules. My question is : How can I remove the test phases from the first 3 modules and how can I remove the other phases from the test project?

Upvotes: 1

Views: 796

Answers (1)

wajiw
wajiw

Reputation: 12269

You can do that by setting up different profiles: http://maven.apache.org/guides/introduction/introduction-to-profiles.html

exp:

    <profile>
        <id>deploywar</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>net.fpic</groupId>
                    <artifactId>tomcat-deployer-plugin</artifactId>
                    <version>1.0-SNAPSHOT</version>
                    <executions>
                        <execution>
                            <id>pos</id>
                            <phase>install</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                            <configuration>
                                <host>${deploymentManagerRestHost}</host>
                                <port>${deploymentManagerRestPort}</port>
                                <username>${deploymentManagerRestUsername}</username>
                                <password>${deploymentManagerRestPassword}</password>
                                <artifactSource>
                                  address/target/addressservice.war
                                </artifactSource>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

    <!-- Defines the QA deployment information -->
    <profile>
        <id>qa</id>
        <activation>
            <property>
                <name>env</name>
                <value>qa</value>
            </property>
        </activation>
        <properties>
            <deploymentManagerRestHost>10.50.50.50</deploymentManagerRestHost>
            <deploymentManagerRestPort>58090</deploymentManagerRestPort>
            <deploymentManagerRestUsername>
              myotherusername
            </deploymentManagerRestUsername>
            <deploymentManagerRestPassword>
              myotherpassword
            </deploymentManagerRestPassword>
        </properties>
    </profile>

Which you would call the deploywar profile in a cli with mvn -Pdeploywar -Denv=dev clean install

Upvotes: 2

Related Questions