ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniels, Doug" <Doug.Dani...@gdc4s.com>
Subject RE: how can i find out about out of date non-java files?
Date Fri, 09 Apr 2004 13:40:33 GMT
The <dependset> task lets you compare a set of files to see if they're out of date with
another set of files. (dependset http://ant.apache.org/manual/CoreTasks/dependset.html)


You can also use the <uptodate> (http://ant.apache.org/manual/CoreTasks/uptodate.html)
task to perform slightly more complex dependency checking such as, seeing if a jar file is
out of date with multiple class files. Or seeing if a set of generated java files are out
of date with an IDL file. What uptodate does is it sets a property if the files are uptodate,
you can then use that property as a condition (<target name="foo" unless="condition">,
or <target name="foo" if="conditon">, or the <if><then> ant-contrib tasks
http://ant-contrib.sourceforge.net/) for a target to perform a certain action for example:

An example of uptodate with a JAR file:

  <target name="depcheckProjectJar" >
    <description>
    Checks if generated Project jar file is up to date, with compiled *.class
    files.
    </description>

    	<!-- Check if generated jar file is up to date with .class files -->
    <uptodate property="Project.jarbuild.isnotrequired">

      <srcfiles dir="${ProjectPackageRoot}" includes="**/*.class"/>

	<mapper type="merge" to="${ProjectJarPath}" />

    </uptodate>

  </target>

  <target name="jarNetmaps" depends="depcheckNetmapsJar, compileNetmaps">

    <description>
    Creates Netmaps jar file.
    </description>
   <if> <not> <isset property="Project.jarbuild.isnotrequired" /> </not>
<then>

    <echo> Deleting then building jar file: ${ProjectJarPath} </echo>

    <!-- quiet=true to allow build to continue if file doesn't exist -->
    <delete file="${ProjectJarPath}" quiet="true"/>

    <jar jarfile="${ProjectJarPath}" basedir="${ProjectPackageRoot}">
      <!--exclude all use Zipfileset to create proper jar-->
      <exclude name="**/*" />
      <!-- add package prefix because to make valid package -->
      <Zipfileset prefix="${ProjectPackageStructure}" dir="${ProjectPackageRoot}">
        <include name="**/*.class"/>
	<!-- include source for debugging, in future perhaps use conditional includeSource==true
switch -->
	<include name="**/*.java"/>
	<!-- Project Look and feel gif's -->
	<include name="**/*.gif" />
        <exclude name="**/bsm/**"/>
      </Zipfileset>
    </jar>

    </then>
    </if>

  </target>


An example of dependency checks against IDL files:

  <target name="depcheckIDL" >

    <description>
     Check if generated .java files are up to date with .idl
     if they are its not necessary to generate them.
    </description>

    <uptodate property="idlgenerate.notrequired">
       <srcfiles dir="${PackageRoot}" includes="**/*Ifc/**/*.idl" excludes="**/bsm/**"/>

       <!-- All IDL's in Project at least generate a *Helper.java so use this
            to check if the generated java is up to date with the corresponding
            idl file -->

       <mapper type="glob" from="*.idl" to="*Helper.java"/>

    </uptodate>

  </target>

  <target name="generateIDL" depends="depcheckIDL" unless="idlgenerate.notrequired">

    <description>
    Generate JAVA files from IDL files.
    </description>

    <echo message="----- IDL Compiliation beginning ------" />
<!-- iterate through IDL files compiling with OpenOrb IDL compiler -->

    <property name="IDLFiles" refid="ProjectIDLFiles" />

    <echo level="verbose" message="IDLFiles = ${IDLFiles}" />

    <foreach target="IDLCompiler" param="idl.file" parallel="false">
	<path refid="IDLFiles"/>
    </foreach>

  </target>





~ Doug Daniels


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message