Hi,

Stefan Prange schrieb:
Hi all,

I'm building an artifact with a mixture of ANT and Maven. The artifact has
the packaging type "war" but I need to have it wrapped also in an EAR file.
Instead of creating a second EAR-Maven-Module I decided to have only one
module with an additional ANT build.xml file. The ANT file should let Maven
build the WAR and after that do the EAR wrapping.

Now my question is: How can I use the maven-ant-tasks-2.0.7 to package the war, i.e. to say the
equivalent of "mvn package" ?

You can't.

The maven ant tasks enable you to use the maven dependency management
features from ant, nothing more.

I tried the <artifact:install ..> task of the maven-ant-tasks-2.0.7 but this
task doesn't process the maven build phases that precede the phase
"install". This means that it does not compile and package my artifact
before it tries to install it to the local repo.

The install task is roughly equivalent to the maven install:install-file
mojo. It will just install the given artifact to your local repository.

Unfortunately, there is neither a <artifact:compile ..> nor a
<artifact:package ..> task in the maven-ant-tasks-2.0.7.

Why should there be? You have the standard ant tasks to do that.

If you want to use ant to build your war, do that, but don't expect
maven to magically do all the work for you. You will have to write your
ant build files like for any other ant based project.

Here is my preliminary solution: I had to call "mvn clean package" via the
command line i.e. via the <exec> ANT task.

<!-- This doesn't process all build phases before install. So the artifact
doesn't get compiled and packaged :-(
<artifact:install file="${outWar}">
        <pom refid="pom.webapp" />
</artifact:install>
-->
<exec executable="cmd">
    <arg value="/c"/>
    <arg value="mvn"/>
    <arg value="clean"/>
    <arg value="package"/>
</exec>

Any suggestions for a better solution?

Yes. Decide on the build tool you want to use.

If it's ant, write your build.xml and possibly use the maven ant tasks
to do the dependency management for you. If you decide you want to use
maven, set up your project the maven way and create distinct modules for
the war and the ear.

Bye, Stefan

-Tim

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to