ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yoshimitsu, Stacy D." <>
Subject RE: File dependency
Date Wed, 12 Feb 2003 22:55:41 GMT
Hi Mike,

You know, I'd ran into the same problem and here's what I did.  I'm not sure
if that's the correct way thought (I'm new to Ant too :P), but it works.

Here is what my build.xml file will do:
1)  I need to built mission.jar which depends on some jar files in the libs
2)  I need to built textEditor.jar which depends on mission.jar

Here is my directory structures:  I copy all my dependency jar files to the
libs directory.
home.dir				./
src.dir				./src
build.dir				./build
libs.dir				./libs
dist.dir				./dist
mission.classes.dir		./build/Mission_classes
textEditor.classes.dir		./build/TextEditor_classes

home.dir	 	= "."
src.dir		= src
build.dir	 	= build
libs.dir	 	= Libs
dist.dir	 	= Dist
mission.classes.dir	= ${build.dir}/Mission_classes
textEditor.classes.dir  = ${build.dir}/TextEditor_Classes


<target name="init">

    <!-- Initializing the necessary variables to do the build. -->
    <property file="" />

    <!-- this is where I set up the path to point to my dependency jar files
    <path id="3rdParty_jars">
	<fileset dir="${libs.dir}">
	    <include name="*.jar" />



<!--   (1)  Build mission.jar -->
<target name="build_mission" depends="prepare">

    <javac srcdir="${src.dir}" 
	   excludes="${javac.mission.excludes}"  >

      <!-- this is where I point to to get my dependency jar files -->
	<classpath refid="3rdParty_jars" />

    <jar destfile="${dist.dir}/${}.jar"  

<!--  (2) built textEditor.jar  
	I need to make sure Mission.jar exist before building textEditor.jar

<!-- this sets Mission.jar.exist to true if it exist in the ./dist
directory.  -->
<target name="Mission.jar.exist" depends="init">
    <available property="Mission.jar.exist"
	file="${dist.dir}/${}.jar" />

<!-- If Mission.jar.exist is true, then execute the following target.  -->
<target name="build_textEditor" depends="Mission.jar.exist"
    <!-- copy if mission.jar exist in ./dist, copy it to ./libs directory.
    <copy file="${dist.dir}/${}.jar"  todir="${libs.dir}" />

    <javac srcdir="${src.dir}" 
	   includes="${javac.textEditor.includes}"  >
	<classpath refid="3rdParty_jars" />

    <jar destfile="${dist.dir}/${}.jar"  


If anyone thinks this is not a good method, please let me know.  Otherwise
I'll be in trouble.  :P


-----Original Message-----
From: Mike Ayers []
Sent: Wednesday, February 12, 2003 1:48 PM
Subject: File dependency


	I feel rather embarassed to be asking what I would expect to be a
trivial question, but I can't seem to figure out how to create a file
dependency.  There is an external jar file that needs to be built (it is the
product of another archive module) before my module can be built, and I want
to check if it exists before compiling, because things go quite badly if
it's not there, and the error messages thus generated aren't terribly
helpful.  I tried:


  <target name="test.compile"
          depends="init,${maindist}/hub.jar" >
    <javac srcdir="${src}" destdir="${classes}" deprecation="off" >
       <classpath refid="test.classpath" />


	...where init is an ant target (that works fine), maindist is a
property with the path to the jar, and hub.jar is its name.  I get:


Buildfile: build.xml

Target `${maindist}/hub.jar' does not exist in this project. It is used from
target `test.compile'.

Total time: 0 seconds


	...which is consistent with the ant documentation, which states that
dependencies are ant targets.  So, I think the question here is: how do I
get a file to be an ant target?

	Am I missing something here?



View raw message