3

Forewarning: I'm not very bright so the question may seem extremely idiotic.

I need to make an ant file that will compile my source files to a target directory. In addition, it needs to test all the JUnit files in my project.

However, I understand next to nothing in a build.xml. At the moment I have my project folder in eclipse contain two separate package folders that hold all my java files.

Would the following be along the right path?

<project name="PersonPersistence" default="compile" basedir=".">

    <target name="compile" description="Compiles java source files.">
        <mkdir dir="target"/>
        <javac srcdir="src" destdir="target"/>
    </target>

    <target name="test" depends="compile" description="Tests JUnit files.>
        <java jar="src/packOne/Test1.java"/>
    </target>

</project>

Or do I need to do something else for the "test" portion? Such as putting all my test files into a jar file?

Runner
  • 79
  • 6
  • 1
    `` is wrong. You should use the `JUnit` task instead of the `java` task. BTW: why don't you just try it and see where it takes you? – Andy Jul 29 '14 at 16:11
  • And reading the ant docu may help as well. – Henry Jul 29 '14 at 17:08
  • I know, it's bit offtopic, but if you don't know anything about ant - consider using maven - it has good defaults for things like compiling and testing code and you need to write almost no config for that – Konstantin V. Salikhov Jul 29 '14 at 17:32
  • Example ANT build. http://stackoverflow.com/questions/15979391/class-not-found-with-ant-ivy-and-junit-error-in-build-xml/15982144#15982144 (Warning it does contain some advanced dependency management stuff courtesy of the ivy plugin, but this kind of feature would plague you if you switched to Maven) – Mark O'Connor Jul 29 '14 at 17:45
  • To get a working ant file, let Eclipse generate a build.xml for you =>Export / General / Ant Buildfiles / choose Project from workspace => the generated file is far away from a world class build file (using antcall f.e.) but it's working and might be sufficient to get you going.. – Rebse Jul 29 '14 at 21:37
  • Possible duplicate of [Where are classpath, path and pathelement documented in Ant version 1.8.0?](https://stackoverflow.com/questions/2526826/where-are-classpath-path-and-pathelement-documented-in-ant-version-1-8-0) – Paul Sweatte Jun 20 '17 at 18:18

0 Answers0