Hello,
I am using WinXP and
Ant...
My project's folder consists of 3 sub-directories and my build.xml file:
<src>
<lib>
<xml>
build.xml
Everything works fine and dandy, but I want to be able to see if Ant really does append the xercesImpl.jar & xalan.jar (located in the lib directory) onto my CLASSPATH.
Before I run the build script, I did an echo %CLASSPATH% and came up with:
----------------------------------------------------------------------
F:\DevProjects\XML\JavaXML>echo %CLASSPATH%
.;F:\DevTools\Java\j2sdk1.4.2_04\lib\tools.jar;F:\DevTools\Java\j2sdk1.4.2_04\jre\lib\rt.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\servlet-api.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\jsp-api.jar;F:\DevTools\Java\j2sdkee1.3.1\lib\j2ee.jar;
----------------------------------------------------------------------
Now, when I ran the build script by doing this:
----------------------------------------------------------------------
F:\DevProjects\XML\JavaXML>ant compile
Buildfile: build.xml
init:
set.classpath:
[echo] Appending jar files to CLASSPATH.
compile:
[echo] Creating interpreted bytecode
[javac] Compiling 1 source file to F:\DevProjects\XML\JavaXML\build
BUILD SUCCESSFUL
Total time: 2 seconds
F:\DevProjects\XML\JavaXML>
---------------------------------------------------------------------------
Now, when I checked the CLASSPATH again, I didn't see the xerces.jar & xalanImpl.jar on my CLASSPATH (after the build script invocation)...
--------------------------------------------------------------------------
F:\DevProjects\XML\JavaXML>echo %CLASSPATH%
.;F:\DevTools\Java\j2sdk1.4.2_04\lib\tools.jar;F:\DevTools\Java\j2sdk1.4.2_04\jre\lib\rt.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\servlet-api.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\jsp-api.jar;F:\DevTools\Java\j2sdkee1.3.1\lib\j2ee.jar;
F:\DevProjects\XML\JavaXML>
--------------------------------------------------------------------------
Everything runs fine and dandy, my question is:
Doe the appropriate jars become appended to the CLASSPATH at compile time and afterwards they don't stay on the CLASSPATH?
Am I setting it right in my build script:
--------------------------------------------------------------------------
<?xml version="1.0"?>
<project name="Build SaxTreeViewer" default="compile" basedir=".">
<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="lib" value="lib"/>
<property name="xml" value="xml"/>
<target name="clean" description="Remove build directory.">
<delete dir="${build}"/>
</target>
<target name="init" description="Initializes the development environment.">
<exec executable="cmd.exe">
<arg line="cls.exe /c"/>
</exec>
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="set.classpath" depends="init" description="Appends jar files to CLASSPATH.">
<echo>Appending jar files to CLASSPATH.</echo>
<path id="classpath">
<fileset dir="${basedir}/{lib}">
<include name="${basedir}/{lib}/*.jar"/>
</fileset>
</path>
</target>
<target name="compile" depends="set.classpath"
description="Build the entire project.">
<echo>Creating interpreted bytecode</echo>
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="run" depends="compile" description="Run the main code.">
<echo>Starting main program.</echo>
<
java classname="javaxml2.SAXTreeViewer"
fork="true" dir="${basedir}">
<arg value="${xml}/contents.xml"/>
<classpath refid="classpath">
<path location="${basedir}/{lib}/*.jar"/>
<path refid="classpath"/>
</classpath>
<jvmarg value="-Xmx256m"/>
<jvmarg value="-Xms20m"/>
</java>
</target>
</project>
--------------------------------------------------------------------------
Also, how can I set the MS Dos command to use the "cls" (clear screen), whenever I run Ant?
With thanks,