Reputation: 21654
My project was constructed using Maven. I was happily building it with Maven. Now, I need to build it with Ant (which I wish I needn't!!!). I wish to use existing maven dependencies - i.e., wish to retain the pom for dependency management.
So, I wrote this task:
<target name="java.compile">
<artifact:pom id="mypom" file="pom.xml" />
<artifact:dependencies filesetId="mypomdeps" pomRefId="mypom" />
<mkdir dir="build/classes" />
<javac
srcdir="${src.java.dir}"
destdir="build/classes"
includeantruntime="no">
<classpath>
<fileset refid="mypomdeps"/>
</classpath>
</javac>
</target>
However, the ant compilation output complains the libraries(in the jars) pointed to by mypomdeps are missing.
What are the reasons that javac was unable to see the classpath that I intended?
Am I using the filesetId generated by artifact:dependencies correctly?
My ant project defn:
I placed maven-ant-tasks-2.1.3.jar in the project basedir.
<project name="why-does-the-sun-go-on-shining"
default="java.compile"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1.3.jar" />
<typedef
resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
Further Clarification
The gist of the question is ... how to use my pom dependencies in my Ant javac task?
Upvotes: 0
Views: 1469
Reputation: 21654
Would like to answer my own question to say that
My ant targets and definition were correct. The refid to artefact dependencies are properly referenced.
However, there were some system scope dependencies defined in the pom.
antlib:org.apache.maven.artifact.ant would not resolve system scoped transitive dependencies. e.g.,
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>tools</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
Thanks to Oers' getting me to debug the ant script by issuing echo elements.
Upvotes: 1