5 Replies Latest reply on Mar 3, 2011 12:11 PM by Snjezana Peco

    Maven + m2eclipse + WTP

    Leandro Iriarte Newbie

      I had a project working without maven and now I'm trying to add it. There are some tutorials around but I couldn't find a complete one.

       

      I could handle the dependencies stuff (specially the transitive ones) with exclusions. I also could handle the WTP integration with m2eclipse.

       

      However, I would like to know the correct way to integrate the server handler from jboss studio to maven build/package, because I' doing something wrong.

       

      For instance, maven will generate a folder like /target/myProject-1.0 with the compiled code, and depending the project type:

       

      *) WAR project: generates  /target/myProject-1.0/WEB-INF/lib/*.jar   (therefore no more jars inside lib folder in the source code)

      *) EAR project: generates /target/myProject-1.0/ with WAR, EJB and *.jars files inside. (therefore no more jars in EarContent folder in the source code)

       

      My questions are:

       

      1) How should I configure eclipse to synchronize the code that maven generates and the jars that maven move to the appropriate place with the runtime environment, in order to run the server correctly?

       

      2) Should I change the assembly point in all the projects? For instance:

       

         A) Change "/ <-- WebContent" for "/ <-- /target/myProject-1.0/"  (WAR project)

         B) Change "/ <-- EarContent" for "/ <-- /target/myProject-1.0-ear/"  (EAR project)

         C) What about the EJB ?

       

      3) Should I do anything else?

       

      Many thanks, Leandro.

        • 1. Maven + m2eclipse + WTP
          Snjezana Peco Master

          When you use JBoss Tools, you can ignore the target directory. JBoss Tools AS server adapter deploys a project based on the WTP structure and doesn't use the target directory. You can create a mavenized Seam EAR project and use it as a template.

          The target directory is used only if you call Maven build lifecycle using the m2eclipse's Maven content menu or command line.

          • 2. Maven + m2eclipse + WTP
            Leandro Iriarte Newbie

            Thanks Snjezana.

             

            But what happen with all the jar files? Because they will be only in the target folder and not with the source code.

            • 3. Maven + m2eclipse + WTP
              Snjezana Peco Master

              JBoss Tools doesn't use the target directory. The JBoss AS adapter copies jars from your local Maven repository to the deploy folder using the Maven classpath container.

              You can see that although they don't exist in the source code, they are in the deploy directory after deploying the application.

              • 4. Maven + m2eclipse + WTP
                Leandro Iriarte Newbie

                I think I'm doing something wrong.

                 

                If I remove the jars from the source code of the war project (ande keep all the M2_REPO/...jar in the buildpath), when I republish from jboss studio and I check the temporary folder (on Servers tab-> explore), there is no any jar in the war file inside the ear. Therefore, the jar were not copied to the deploy directory.

                 

                What I am doing wrong?

                • 5. Maven + m2eclipse + WTP
                  Snjezana Peco Master

                  You shouldn't use the M2_REPO variable. You should define jars using the pom.xml file. The dependencies of the type compile, runtime will be deployed.

                  Don't forget to install m2eclipse-core, m2eclipse-wtp and the JBoss Maven Tools feature.