Alexander,

We sometimes do something like your Ant script but with batch/script files.
Its not cross-platform between Windows and Linux but each one is so simple
it doesn't matter much.

-- Lee

On 9/14/07, Alexander Sack <[EMAIL PROTECTED]> wrote:
>
> Hi Everybody:
>
> You know Eclipse/Maven2 integration at this point can be very confusing.
> You have three plugins, two of which are ECLIPSE plugins that integrate
> Maven2 while the other is a Maven2 plugin that happens to auto-generate
> files for Eclipse.  I wrote this below and I figured I would share to see
> if
> it helps anyone else.
>
> The main advantages of Codehaus and Q4E (which I plan to try very soon but
> I
> will assume it does similar things that Codehaus does) is that they
> integrate the POM dependency graph as part of your Eclipse project's Build
> Path, i.e. it autoupdates dependencies as you add them to the POM.  The
> maven-eclipse-plugin relies on creating a separate CLASSPATH CONTAINER
> variable referenced in your .classpath file to use your local maven2
> repository (the M2_REPO variable in the directions - btw this is typical
> for
> other plugins like the JBoss tools).  Unfortunately the latter is not as
> dynamic when it comes to adding and deleting dependencies in your project.
>
> Codehaus installs on 3.1.x and up (I've used it with 3.1.1 specifically
> and
> with 3.3 though for some reason its buggy under 3.3).
>
> What I do to setup a project is the following:
>
> - Use mvn archetype to setup the basic structure
> - Create a new Java project with Maven2 nature enabled
> - Import archetype directory structure into this project
> - Edit the Build Path within Eclipse
> - Use ant build file to execute mvn from within Eclipse
>
> Here is an example (I'm using Eclipse 3.1.1 w/Codehaus m2eclipse plugin):
>
> 1) In some temporary directory
> mvn archetype:create -DgroupId=com.example.project -DartifactId=MyProject
> 2) Edit pom.xml to packaging is pom, rm -rf the src directory
> 3) Within MyProject use archetype plugin to create other modules which
> adds
> them to parent module, e.g.
>
> mvn archetype create -DgroupId=com.example.project -DartifactId=ejb3
> mvn archetype create -DgroupId=com.example.project -DartifactId=war
>
> This will create two sub modules, one for war, one for ejb3.  You can
> change
> the packaging to war and jar (or ejb) respectively.
>
> 4) Now go into Eclipse and do a new project MyProject and import the
> MyProject you created above via Filesystem
> 5) Enable Maven2 nature, now Maven2 dependencies will show up and
> dynamically change as you edit your POM hierarchy
> 6) Edit Build Path in Project's properties and remove MyProject.  Instead
> add the ejb3/src/main/java and war/src/main/java source folders.
> 7) Check "Allow output folders for source folders"
> 8) Now I use a generic build.xml ANT file to execute Maven2 such as this:
>
> <project name="MyProject" default="all">
>     <property environment="env"/>
>     <property file=" build.properties"/>
>
>     <!-- Feel free to conditional this to execute the bat or shell
> depending
> on OS -->
>     <property name="mvn" value="${env.MAVEN_HOME}\bin\mvn.bat"/>
>
>     <target name="mvn">
>         <exec dir="${basedir}" executable="${mvn}">
>             <arg line="-P${maven.profile.list} -
> Dmaven.test.skip=true${goal}"/>
>         </exec>
>     </target>
>
>     <target name="clean">
>         <antcall target="mvn">
>             <param name="goal" value="clean"/>
>         </antcall>
>     </target>
>
>     <target name="process-resources">
>       <antcall target="mvn">
>         <param name="goal" value="process-resources"/>
>        </antcall>
>     </target>
>
>     <target name="compile">
>         <antcall target="mvn">
>             <param name="goal" value="compile"/>
>         </antcall>
>     </target>
>
>     <target name="site">
>         <antcall target="mvn">
>             <param name="goal" value="site"/>
>         </antcall>
>     </target>
>
>     <target name="all">
>         <antcall target="package"/>
>     </target>
>
>     <target name="package">
>         <antcall target="mvn">
>             <param name="goal" value="package"/>
>         </antcall>
>     </target>
>
>     <target name="install">
>         <antcall target="mvn">
>             <param name="goal" value="install"/>
>         </antcall>
>     </target>
> </project>
>
> Mine has some more stuff in it but you get the idea.
>
> 9)  Now copy build.xml to Ant View and execute targets
> 10) Remove the old MyProject you imported as now its part of your
> workspace
> (I guess you could have not imported it originally which is an extra step)
>
> I have NO idea if this is what others do but this works great for my
> builds.  I can build from the command line using ant (as well as allow ant
> to do some preprocessing that Maven2 might or might not be able to
> accomplish as easy) as well as build from Eclipse.  I have built several
> products this way without any issue (nightly builds use the command line,
> developers such as myself use Eclipse).
>
> Try it....hope this helps a little....I will play with Q4E with Europa
> (which I want for just for the server instances stuff).
>
> Thanks!
>
> -aps
>
> --
> "What lies behind us and what lies in front of us is of little concern to
> what lies within us." -Ralph Waldo Emerson
>



-- 
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com

Reply via email to