Go to the Ant website and download. This way, you have a copy of Ant outside of Eclipse. I recommend to put it under the C:\ant
directory. This way, it doesn't have any spaces in the directory names. In your System Control Panel, set the Environment Variable ANT_HOME
to this directory, then pre-pend to the System PATH
variable, %ANT_HOME%\bin
. This way, you don't have to put in the whole directory name.
Assuming you did the above, try this:
C:\> cd \Silk4J\Automation\iControlSilk4J
C:\Silk4J\Automation\iControlSilk4J> ant -d build
This will do several things:
build.xml
in the directory where it exists, you don't end up with the possibility that your Ant build can't locate a particular directory.The -d
will print out a lot of output, so you might want to capture it, or set your terminal buffer to something like 99999
, and run cls
first to clear out the buffer. This way, you'll capture all of the output from the beginning in the terminal buffer.
Let's see how Ant should be executing. You didn't specify any targets to execute, so Ant should be taking the default build
target. Here it is:
<target depends="build-subprojects,build-project" name="build"/>
The build
target does nothing itself. However, it depends upon two other targets, so these will be called first:
The first target is build-subprojects
:
<target name="build-subprojects"/>
This does nothing at all. It doesn't even have a dependency.
The next target specified is build-project
does have code:
<target depends="init" name="build-project">
This target does contain tasks, and some dependent targets. Before build-project
executes, it will first run the init
target:
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
This target creates a directory called bin
, then copies all files under the src
tree with the suffix *.java
over to the bin
directory. The includeemptydirs
mean that directories without non-java code will not be created.
Ant uses a scheme to do minimal work. For example, if the bin
directory is created, the <mkdir/>
task is not executed. Also, if a file was previously copied, or there are no non-Java files in your src
directory tree, the <copy/>
task won't run. However, the init
target will still be executed.
Next, we go back to our previous build-project
target:
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="iControlSilk4J.classpath"/>
</javac>
</target>
Look at this line:
<echo message="${ant.project.name}: ${ant.file}"/>
That should have always executed. Did your output print:
[echo] iControlSilk4J: C:\Silk4J\Automation\iControlSilk4J\build.xml
Maybe you didn't realize that was from your build.
After that, it runs the <javac/>
task. That is, if there's any files to actually compile. Again, Ant tries to avoid work it doesn't have to do. If all of the *.java
files have previously been compiled, the <javac/>
task won't execute.
And, that's the end of the build. Your build might not have done anything simply because there was nothing to do. You can try running the clean
task, and then build
:
C:\Silk4J\Automation\iControlSilk4J> ant -d clean build
However, Ant usually prints the target being executed. You should have seen this:
init:
build-subprojects:
build-projects:
[echo] iControlSilk4J: C:\Silk4J\Automation\iControlSilk4J\build.xml
build:
Build Successful
Note that the targets are all printed out in order they're executed, and the tasks are printed out as they are executed. However, if there's nothing to compile, or nothing to copy, then you won't see these tasks being executed. Does this look like your output? If so, it could be there's nothing to do.
bin
directory already exists, <mkdir/>
isn't going to execute.src
, or they have already been copied into bin
, the <copy/>
task won't execute.src
directory, or they have already been compiled, the <java/>
task won't run.If you look at the output from the -d
debug, you'll see Ant looking at a task, then explaining why a particular task wasn't executed. Plus, the debug option will explain how Ant decides what tasks to execute.
See if that helps.