0

I need import my project's dependencies with maven.

But, I also need to compile the project with an ant script.

Before using maven, I had a lib folder with the jars. But now the jars are in a folder of maven which can be in multiple locations.

This is my target and path:

<path id="classpath.compilar">
    <pathelement path="${java.class.path}" />
    <fileset dir="${lib.dir}">
        <include name="**/*.jar" />
    </fileset>
</path>

<target name="compilar" depends="limpiar">
    <mkdir dir="${classes.dir}" />
    <javac destdir="${classes.dir}" srcdir="${src.dir}"
        classpathref="classpath.compilar" includeantruntime="false" />
</target>

I need to add these jars in the path, but I don't know how get it from maven.

Does anyone know how to do this? Any task to get a fileset with this jar files?

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
hlastras
  • 324
  • 5
  • 16
  • Not the same. I don't want convert ant project into maven project. I have a maven project whit a script ant. Maven project resolve the dependencies downloading needed jars in maven local repository, and I want use this jars in ant, to create a listset for a path. – hlastras Jan 03 '15 at 16:54
  • In that case read the antrun plugin documentation. It describes how to access the Maven managed classpaths. (http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html) another link explains how to use custom ANT tasks via plugin dependencies (http://maven.apache.org/plugins/maven-antrun-plugin/examples/customTasks.html) – Mark O'Connor Jan 03 '15 at 19:22
  • But I don't want use ant target in maven. I want use maven dependencies in ant, without maven(only for download this dependencies). I do not know if I'm explaining well. – hlastras Jan 04 '15 at 03:54
  • Your question was phrased in such a way that it appears you are using both Maven and ANT to compile your project... I would suggest checking out Apache ivy. It contains additional tasks for download dependencies from Maven. For example see: http://stackoverflow.com/questions/2609465/how-to-avoid-copying-dependencies-with-ivy/2611353#2611353 – Mark O'Connor Jan 04 '15 at 10:43
  • And another example: http://stackoverflow.com/questions/15979391/class-not-found-with-ant-ivy-and-junit-error-in-build-xml/15982144#15982144 – Mark O'Connor Jan 04 '15 at 11:20
  • I do not speak English very well, and maybe I have not expressed myself correctly. It's a practice of university and I only can use ant for management, and maven to resolve dependencies. I can't use Ivy. Thanks for you help. – hlastras Jan 04 '15 at 20:04
  • That makes absolutely no sense. Ivy is an ANT plugin that can download dependencies from Maven repositories. Try it and you'll discover how it works. – Mark O'Connor Jan 04 '15 at 22:19

0 Answers0