You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lorenzo Thurman <lo...@thethurmans.com> on 2010/04/26 23:41:41 UTC
Help with Ant task
I'm just learning both Maven and Ant. I have a couple of weeks of working with Maven, but not I need to get it execute and Ant task. I know nothing about Ant, but using the antrun plugin for Maven, I've got things to the point where the task attempts to execute, but fails because it can't find a class which is contained within a jar file. The jar containing the class is actually referenced in the build.xml via classpath and classname tags. It seems to follow that if the Ant task can find the jar when running under Ant, it should do so when running via Maven, but that's not the case. So, my question is how do I pass a classpath variable to an Ant task from Maven? I case there are fundamental flaws in my approach, I've included both my pom.xml and the build.xml that should be executed.
Here is my pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>acquitygroup.AMA</groupId>
<artifactId>AMA</artifactId>
<version>1</version>
<profiles>
<profile>
<id>primary</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks>
<ant antfile="src/AMA/modules/build.xml" />
</tasks>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Here is the build.xml that's being called:
<?xml version="1.0" encoding="UTF-8"?>
<project name="modules" default="all" basedir=".">
<property environment="env" />
<!-- global.dir is used to resolve dev environment resources such as
checkstyle libraries, custom ant tasks, etc.. Essentially stuff
we don't want to stick directly into our module structure. -->
<property name="global.dir" value="."/>
<!-- Common dir identifies the location of common ant tasks that all
submodules import for use or overriding -->
<property name="common.dir" value="${global.dir}"/>
<property file="${common.dir}/${user.name}.properties" />
<property file="${common.dir}/common.properties" />
<!--
The modules in order of dependency, i.e. the most dependant module is
built last.
-->
<filelist id="module.files" dir="${basedir}" files="${modules.build.order}" />
<taskdef name="foreach"
classname="net.sf.antcontrib.logic.ForEach"
classpath="${global.dir}/../lib/ant-contrib.jar"/>
<!-- The dynamo class path -->
<path id="dynamo.classpath">
<fileset dir="${dynamo.home}/../DAS/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${dynamo.home}/../DAS-UI/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${dynamo.home}/../DPS/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${dynamo.home}/../DSS/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${dynamo.home}/../DCS/lib">
<include name="**/*.jar" />
</fileset>
</path>
<target name="-init" description="displays initialization info">
<!-- Create a text list that shows us which modules we are building. -->
<pathconvert pathsep=" " dirsep="/" property="module.files.string" refid="module.files">
<map from="${basedir}" to="."/>
</pathconvert>
<echo>Module Build Order: ${module.files.string}</echo>
</target>
<!--
Create a quick macro to call all the sub projects so we don't have to
repeat ourselves...
-->
<macrodef name="call-subant">
<!-- target is the ant target we want to invoke in the subant task -->
<attribute name="target"/>
<sequential>
<subant target="@{target}">
<!-- The tasks within the deploy-jboss.xml check for a parameter named
'skip.run.assembler'. This tells the task invoked at the
sub module level to assemble the application for a third party
application server. When calling the sub modules from here
we want them to skip that step cause we'll call it when
we are done calling all the submodules. So we tell the
sub module invoked deployment tasks to skip assembly.
-->
<property name="skip.run.assembler" value="true" />
<filelist refid="module.files"/>
</subant>
</sequential>
</macrodef>
<!-- TASKS COMMON TO ALL SUBMODULES -->
<target name="all" depends="-init" description="Runs all projects.">
<call-subant target="all"/>
<!-- Install any servers -->
<antcall target="install-servers"/>
</target>
<target name="clean" depends="-init" description="Cleans all projects.">
<call-subant target="clean"/>
</target>
<target name="update" depends="-init" description="Developer centric task that calls build, install, and devdeploy.">
<call-subant target="update"/>
</target>
<target name="build" depends="-init" description="Builds all projects.">
<call-subant target="build"/>
</target>
<target name="install" depends="-init" description="Installs all projects.">
<call-subant target="install"/>
<!-- Install any server specific configs -->
<antcall target="install-servers"/>
</target>
<target name="deploy" depends="-init" description="Deploys all projects.">
<call-subant target="deploy"/>
</target>
<target name="devdeploy" depends="-init" description="Deploys all projects in development mode.">
<call-subant target="devdeploy"/>
</target>
<target name="junit" depends="-init" description="Compiles and runs JUnits">
<call-subant target="junit"/>
</target>
<target name="junit-report" depends="-init" description="Generated JUnit Report">
<call-subant target="junit-report"/>
</target>
<!-- TASKS SPECIFIC TO THE ENTIRE ENVIRONMENT -->
<target name="-check-server-dir">
<available file="${global.server.dir}" property="server.configs.exist"/>
</target>
<target name="install-servers"
depends="-check-server-dir"
description="Installs any server specific configurations"
if="server.configs.exist">
<echo>Copying server configs from ${global.server.dir} to ${dynamo.home}/servers</echo>
<copy todir="${dynamo.home}/servers" verbose="true">
<fileset dir="${global.server.dir}" >
<exclude name="**/_jboss-resources/**" />
</fileset>
</copy>
</target>
<!--
Looks at all of the source directories at once and creates a javadoc for
the projects.
-->
<target name="javadoc" depends="-init" description="Creates javadoc for all the modules.">
<defaultexcludes add="**/*.html"/>
<defaultexcludes add="**/*.classpath"/>
<defaultexcludes add="**/*.project"/>
<defaultexcludes add="**/*.checkclipse"/>
<defaultexcludes add="**/*.properties"/>
<javadoc destdir="${global.javadoc.dir}"
author="true"
version="true"
use="true">
<fileset dir="${basedir}/estore/src" defaultexcludes="yes">
<include name="**" />
</fileset>
<classpath refid="dynamo.classpath" />
<link offline="true"
href="http://java.sun.com/j2se/1.4.2/docs/api/"
packagelistLoc="${jdk.docs.dir}"/>
<link offline="true"
href="http://www.atg.com/repositories/ContentCatalogRepository_en/manuals/ATG7.1/apidoc/"
packagelistLoc="${dynamo.docs.dir}"/>
</javadoc>
</target>
</project>
"There are 10 types of people in this world: those who understand binary, those who don't"
--Unknown
Lorenzo Thurman
lorenzo@thethurmans.com
Re: Help with Ant task
Posted by Eduardo M KALINOWSKI <ed...@kalinowski.com.br>.
On 04/26/2010 06:41 PM, Lorenzo Thurman wrote:
> I'm just learning both Maven and Ant. I have a couple of weeks of working with Maven, but not I need to get it execute and Ant task. I know nothing about Ant, but using the antrun plugin for Maven, I've got things to the point where the task attempts to execute, but fails because it can't find a class which is contained within a jar file. The jar containing the class is actually referenced in the build.xml via classpath and classname tags. It seems to follow that if the Ant task can find the jar when running under Ant, it should do so when running via Maven, but that's not the case. So, my question is how do I pass a classpath variable to an Ant task from Maven? I case there are fundamental flaws in my approach, I've included both my pom.xml and the build.xml that should be executed.
>
List the jar file with the custom task as a dependency of the plugin:
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>acquitygroup.AMA</groupId>
> <artifactId>AMA</artifactId>
> <version>1</version>
> <profiles>
> <profile>
> <id>primary</id>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-antrun-plugin</artifactId>
> <configuration>
> <tasks>
> <ant antfile="src/AMA/modules/build.xml" />
> </tasks>
> </configuration>
>
<dependencies>
<dependency>
<artifactId>...
...
</dependency>
</dependencies>
> </plugin>
> </plugins>
> </build>
> </profile>
> </profiles>
> </project>
>
--
Someday we'll look back on this moment and plow into a parked car.
-- Evan Davis
Eduardo M KALINOWSKI
eduardo@kalinowski.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org