5 Replies Latest reply on Jan 18, 2010 3:18 AM by kapitanpetko

    exploded EAR with Maven 2

    asookazian

      We're using Maven 2 as our build tool for the current Seam 2.x project at my new job.  A packaged EAR is the deployable artifact result when we exec mvn clean install.  I'd like to deploy an exploded EAR to take advantage of Seam's hot incremental deployment via the special Seam classloader.


      This was very easy to achieve for a seam-gen'd project via Ant build.xml script (simply exec ant explode).  After reading about the default Maven build lifecycle, I'm not sure how to achieve the equivalent using Maven 2.


      I'm pretty new to Maven but I think that when you exec mvn install, the phases in the build lifecycle prior to install are executed first (this is similar to the depends attribute of a target in an Ant build.xml).  So how can I prevent the package phase from occurring?


      I guess the question is more generally: how do I achieve fine-grained control of the build lifecycle in Maven 2?  This is very easy to achieve in Ant build scripts by changing the prerequisite targets in the depends attribute for a target.


      Any ideas would be appreciated.  thx.

        • 1. Re: exploded EAR with Maven 2
          asookazian

          I decided to write a build.xml Ant script (based on a seamg-gen'd version first) that will be a refactor of the Maven parent and module pom.xml files.


          Problems are the slowness of the builds in Maven, lack of exploded EAR/WAR option and the lack of fine-grained control.  We're not using the site generation or report generation features of Maven.  Maven life cycle is not configurable AFAIK (i.e. 'mvn install' execs all phases prior to and including install) unless you specify a sequence of plugin goals:


          mvn resources:resources \
          compiler:compile \
          resources:testResources \
          compiler:testCompile \
          surefire:test \
          jar:jar \
          install:install



          Also, in our project, only a local repo is used so if I want to do a mvn deploy then I have to download the maven-deploy-plugin and install it into the local repo (which is a PITA).


          For dependency management, we can use Ivy with Ant from what I've read.


          So what's the best plan of attack for refactoring a Maven build to Ant build?


          • 2. Re: exploded EAR with Maven 2
            kapitanpetko

            Arbi Sookazian wrote on Jan 15, 2010 06:45:


            So what's the best plan of attack for refactoring a Maven build to Ant build?



            Before you go there, spend a little more time learning Maven. You can use profiles to customize your build,
            you can also you use the antrun plugin to have bits of your build specified in Ant.


            If you say this in your profile, you get exploded archives. You can use antrun after that to copy them to
            your deploy dir.


            ...
            <build>
              <plugins>
                <plugin>
                  <artifactId>maven-ear-plugin</artifactId>
                   <configuration>
                     <unpackTypes>ejb,war</unpackTypes>
                   </confugration>
                 </plugin>
                </plugins>
            </build>
            



            HTH

            • 3. Re: exploded EAR with Maven 2
              lvdberg

              Hi Arbi,


              I completely agree with Nikolay; Don't downgrade your builds from Maven to Ant. It takes some time, especially to configure things withing Eclipse, but's worth the effort. Esapecially the reporting plug-ins are a must-have. Because Jboss tools is not (yet) nicely integrated with maven, you could split the development and deployment phase of your project. All development under Eclipse and when you're ready to run, do the Maven build with different profiles.


              Leo  

              • 4. Re: exploded EAR with Maven 2
                asookazian

                Isn't the project directory structure different with Maven vs. Ant projects?  So I'm not sure how I'd be able to maintain a dev build for Ant and a prod build for Maven simultaneously for the same project.


                There are profiles in the parent pom.xml, so maybe I can use that with the <unpackTypes>.  Unfortunately, our project is an EAR so we can't do hot incremental deployment of EJBs (which there are many!).  Thx for the input.

                • 5. Re: exploded EAR with Maven 2
                  kapitanpetko

                  Arbi Sookazian wrote on Jan 15, 2010 19:44:


                  Isn't the project directory structure different with Maven vs. Ant projects?  So I'm not sure how I'd be able to maintain a dev build for Ant and a prod build for Maven simultaneously for the same project.



                  Why do you want an Ant dev build? If you decide to use Maven, you should use it for all profiles. I don't know what the exact differences
                  between your dev and prod setups are, but with some filters and different profiles, you should be able to set it up in Maven.