Search code examples
mavenwarear

war deployment sequence under ear


I'm new to this concept.

I'm having two wars under ear. War-1 is consisitng of one servlet with load on startup parameter, which I want to deploy first and after this is completed, War-2 should be deployed.How this can be done?

I'm using maven with Jboss7.1.1.Final.

Please help


Solution

  • You can use modules. Assuming your project looks like this :

    • Ear (pom.xml)
      • War-1
      • War-2

    Add pom files in War-1 and War-2 directories. The pom file in ear directory will be the parent, where you declare modules to be processed :

    <modules>
        <module>War-1</module>
        <module>War-2</module>
    </modules>
    

    Maven will look-up for poms in War-1 and War-2 directories. Create a new pom in each one :

    • Ear (pom.xml)
      • War-1 (pom.xml)
      • War-2 (pom.xml)

    There, an abstract of pom.xml in each sub-module. Your have to declare the parent :

    <parent>
        <artifactId>yourArtifact</artifactId>
        <groupId>yourGroup</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    
    <!-- Name your package as you like -->
    <groupId>${project.parent.groupId}</groupId>
    <artifactId>${project.parent.artifactId}-War1</artifactId>
    <name>${project.parent.artifactId}-War1</name>
    <description>
        War of project ${project.parent.artifactId}
    </description>
    
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    

    Is that what you were looking for ? You will find more information on modules at http://www.sonatype.com/books/mvnex-book/reference/multimodule.html

    @+