mardi 23 juin 2015

Run Maven goal for only one module in multi module project

I have a project which has 4 modules. That said, I have a parent project with a parent POM.xml specifying theses modules.

<modules>
        <module>Module1-Desktop</module>
        <module>Module2-Core</module>
        <module>Module3-Web</module>
        <module>Module4-EAR</module>
</modules>

The Module4-EAR has Module3-Web and Module2-Core as dependencies (not as modules) and generates an EAR to be deployed to JBoss.

I want to be able to build the Module4-EAR, but building Module3-Web and Module2-Core before it, so it is up-to-date and also deploy it to JBoss. So I'm running the following Maven command in the parent project:

mvn --projects Module2-Core,Module3-Web,Module4-EAR clean install jboss:hard-undeploy jboss:hard-deploy

In the parent POM I've set the jboss-maven-plugin like this:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jboss-maven-plugin</artifactId>             
                <configuration>
                    <skip>true</skip>                   
                </configuration>
            </plugin>

In the Module4-EAR's pom.xml I've set the jboss-maven-plugin this way:

<plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>jboss-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <jbossHome>${env.JBOSS_HOME}</jbossHome>
                            <serverName>default</serverName>
                            <unpack>true</unpack>
                            <fileNames>
                                <fileName>build/Module4-EAR.ear</fileName>
                            </fileNames>                            
                        </configuration>
                    </plugin>

The problem is that I want only the Module4-EAR.ear to be deployed with to the server, but the Module3-Web.war and Module2-Core are deployed as well. I want to do it in a single command, instead of running 2 mvn commands, one to "clean install" the projects and another to deploy only the EAR. How can I achieve that?

Aucun commentaire:

Enregistrer un commentaire