2
votes

I'm a java-greenhorn trying to compile my project via ant, but nothing's working. So, in my class I'm using log4j.jar and import junit. Everything's in Eclipse, either Ant. Here is the build.xml file:

    <path id="master-classpath">
    <pathelement path="D:\.a lot of folders..\junit.jar"/>
    <!--<pathelement path="D:\...\log4j-1.2.17.jar"/>    --> 
    <fileset dir="D:\apache-log4j-1.2.17">
            <include name="log4j-1.2.17.jar"/>
    </fileset>
    <pathelement path="${buildSrc}"/>
</path>

And compile block:

<target name="compile" depends="init">
        <javac includeantruntime="false" srcdir="${src1}" destdir="${buildSrc}"/>
        <javac includeantruntime="false" srcdir="${src2}" destdir="${buildSrc}"/>
        <javac includeantruntime="false" srcdir="${test}" destdir="${buildTest}">
            <classpath refid="master-classpath"/>
        </javac>
        <javac includeantruntime="false" srcdir="src" destdir="build/classes" classpath="${buildSrc}"/>
    </target>

I've also tried some different approaches, like making the same in the javac-task, using property, etc, to no success. Could you please, identify my mistake and help deal with it? Thanks in advance.

1

1 Answers

0
votes
 <javac includeantruntime="false" srcdir="${test}" destdir="${buildTest}">
    <classpath refid="master-classpath"/>
 </javac>

should work. As should "classpathref" as an attribute on javac itself.

Possibilities:

  1. Typo in folder name
  2. Typo in file name
  3. D drive isn't mapped