pyrrhic
pyrrhic

Reputation: 1897

Compiles via command line but not in ant

My Java project compiles via Terminal (using Mac OSX 10.8), but not in Ant 1.9.1. I've been trying to distill these three lines of code into a valid Ant build script. The line is:

javac -cp "./:./ij.jar:ij-ImageIO_.jar:flanagan.jar" org/rhwlab/image/ImageWindow.java

However, I have been trying to write an Ant build script that can perform this process efficiently (the following):

    <target name="compile">
    <mkdir dir="${classes.dir}"/>
        <javac includeantruntime="false" srcdir="${src.dir}" destdir="${build.dir}"
        compiler="javac1.6" classpathref="classpath">
         <include name="org/rhwlab/image/ImageWindow.java"/>
         </javac>
     </target>  

But errors arise as follows:

 Image3D2Z.java:9: package gov.noaa.pmel.sgt does not exist
 Analysis2.java:11: package gov.noaa.pmel.sgt.dm does not exist

How can I get my project to compile via Ant?

Upvotes: 2

Views: 92

Answers (1)

Chris
Chris

Reputation: 5654

Seems to be a classpath problem. Try something like:

<path id="myclasspath">
  <fileset dir="${dir.path}">
    <include name="*.jar"/>
  </fileset>
</path>
...

<javac destdir="${build.dir}">
  <src path="${src.dir}"/>
  <classpath refid="myclasspath"/>
</javac>

Upvotes: 1

Related Questions