ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerry Odenwelder <Jerry.Odenwel...@Mentisys.com>
Subject RE: Another Neophyte Question
Date Tue, 26 Jun 2001 21:02:29 GMT
First Thanks for the quick reply this morning.  I read the FAQ (Which I had
not done :-o Doh ) and then I created this simple example:

<begin file hello.java>
package test;

public class Hello
{
  public static void main(String[] argv)
  {
    System.out.println("Hello");
  }
}
<End file hello.java>

<begin file build.xml>
<project name="Test" default="build">

<patternset id="cleanup.files">
   <include name="**/test/*.class"/>
</patternset>

<!-- 
    Properties
-->
<property environment="env"/>
<property name="outputDir"     value="${user.dir}"/>

<!-- 
    Initial target
-->
   <target name="init">
      <tstamp/>
   </target>

<!-- 
    Build Target 
-->

   <target name="build" depends="init">
      <echo> classfiles written to ${outputDir} </echo>
      <javac srcdir="." 
             destdir="${outputDir}"
             includes="*.java">
      </javac>
   </target>

<!-- 
    Clean Target 
-->
   <target name="clean">
      <echo> Cleaning ${outputDir} </echo>
      <delete includeEmptyDirs="true" >
         <fileset dir="${outputDir}">
            <patternset refid="cleanup.files"/> 
         </fileset>
      </delete>
   </target>


</project>
<end file build.xml>

<begin test results>

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\projects\Java\test>dir
 Volume in drive C has no label.
 Volume Serial Number is 07D1-030F

 Directory of C:\projects\Java\test

06/26/2001  11:09a      <DIR>          .
06/26/2001  11:09a      <DIR>          ..
06/26/2001  11:10a                 120 Hello.java
06/26/2001  11:12a                 892 build.xml
               2 File(s)          1,012 bytes
               2 Dir(s)  13,868,417,024 bytes free

C:\projects\Java\test>ant
Buildfile: build.xml

init:

build:
     [echo]  classfiles written to C:\projects\Java\test
    [javac] Compiling 1 source file to C:\projects\Java\test

BUILD SUCCESSFUL

Total time: 1 second
C:\projects\Java\test>dir /s
 Volume in drive C has no label.
 Volume Serial Number is 07D1-030F

 Directory of C:\projects\Java\test

06/26/2001  11:09a      <DIR>          .
06/26/2001  11:09a      <DIR>          ..
06/26/2001  11:10a                 120 Hello.java
06/26/2001  11:12a                 892 build.xml
06/26/2001  04:47p      <DIR>          test
               2 File(s)          1,012 bytes

 Directory of C:\projects\Java\test\test

06/26/2001  04:47p      <DIR>          .
06/26/2001  04:47p      <DIR>          ..
06/26/2001  04:47p                 414 Hello.class
               1 File(s)            414 bytes

     Total Files Listed:
               3 File(s)          1,426 bytes
               5 Dir(s)  13,868,384,256 bytes free

C:\projects\Java\test>ant
Buildfile: build.xml

init:

build:
     [echo]  classfiles written to C:\projects\Java\test
    [javac] Compiling 1 source file to C:\projects\Java\test

BUILD SUCCESSFUL

Total time: 1 second
C:\projects\Java\test>dir /s
 Volume in drive C has no label.
 Volume Serial Number is 07D1-030F

 Directory of C:\projects\Java\test

06/26/2001  11:09a      <DIR>          .
06/26/2001  11:09a      <DIR>          ..
06/26/2001  11:10a                 120 Hello.java
06/26/2001  11:12a                 892 build.xml
06/26/2001  04:47p      <DIR>          test
               2 File(s)          1,012 bytes

 Directory of C:\projects\Java\test\test

06/26/2001  04:47p      <DIR>          .
06/26/2001  04:47p      <DIR>          ..
06/26/2001  04:48p                 414 Hello.class
               1 File(s)            414 bytes

     Total Files Listed:
               3 File(s)          1,426 bytes
               5 Dir(s)  13,868,384,256 bytes free

C:\projects\Java\test>
<end test results>

After the first build Hello.java has a timestamp of 11:10a and Hello.class
has a timestamp of 4:47p (I started this test in the AM and did not have a
chance to finish it until the PM).  After my second build the timestamp of
Hello.java remains the same and the timestamp of Hello.class has changed.
As you can see Ant has rebuilt my .java file that did not change.  

Now, just in case I read the FAQ incorrectly I made the following changes
<file build.xml>
<project name="Test" default="build">

<patternset id="cleanup.files">
   <include name="**/test/*.class"/>
</patternset>

<!-- 
    Properties
-->
<property environment="env"/>
<property name="outputDir"     value="${user.dir}"/>

<!-- 
    Initial target
-->
   <target name="init">
      <tstamp/>
   </target>

<!-- 
    Build Target 
-->

   <target name="build" depends="init">
      <echo> classfiles written to ${outputDir} </echo>
      <javac srcdir="test" 
             destdir="${outputDir}"
             includes="*.java">
      </javac>
   </target>

<!-- 
    Clean Target 
-->
   <target name="clean">
      <echo> Cleaning ${outputDir} </echo>
      <delete includeEmptyDirs="true" >
         <fileset dir="${outputDir}">
            <patternset refid="cleanup.files"/> 
         </fileset>
      </delete>
   </target>


</project>
<end build.xml>


basically I added a directory called test and moved Hello.java into this
directory.  I then re-ran the test

<begin test results>

C:\projects\Java\test>dir /s
 Volume in drive C has no label.
 Volume Serial Number is 07D1-030F

 Directory of C:\projects\Java\test

06/26/2001  11:09a      <DIR>          .
06/26/2001  11:09a      <DIR>          ..
06/26/2001  04:47p      <DIR>          test
06/26/2001  05:03p                 897 build.xml
               1 File(s)            897 bytes

 Directory of C:\projects\Java\test\test

06/26/2001  04:47p      <DIR>          .
06/26/2001  04:47p      <DIR>          ..
06/26/2001  11:10a                 120 Hello.java
               1 File(s)            120 bytes

     Total Files Listed:
               2 File(s)          1,017 bytes
               5 Dir(s)  13,868,367,872 bytes free

C:\projects\Java\test>ant
Buildfile: build.xml

init:

build:
     [echo]  classfiles written to C:\projects\Java\test
    [javac] Compiling 1 source file to C:\projects\Java\test

BUILD SUCCESSFUL

Total time: 1 second
C:\projects\Java\test>dir /s
 Volume in drive C has no label.
 Volume Serial Number is 07D1-030F

 Directory of C:\projects\Java\test

06/26/2001  11:09a      <DIR>          .
06/26/2001  11:09a      <DIR>          ..
06/26/2001  04:47p      <DIR>          test
06/26/2001  05:03p                 897 build.xml
               1 File(s)            897 bytes

 Directory of C:\projects\Java\test\test

06/26/2001  04:47p      <DIR>          .
06/26/2001  04:47p      <DIR>          ..
06/26/2001  11:10a                 120 Hello.java
06/26/2001  05:03p                 414 Hello.class
               2 File(s)            534 bytes

     Total Files Listed:
               3 File(s)          1,431 bytes
               5 Dir(s)  13,868,351,488 bytes free

C:\projects\Java\test>ant
Buildfile: build.xml

init:

build:
     [echo]  classfiles written to C:\projects\Java\test
    [javac] Compiling 1 source file to C:\projects\Java\test

BUILD SUCCESSFUL

Total time: 1 second
C:\projects\Java\test>dir /s
 Volume in drive C has no label.
 Volume Serial Number is 07D1-030F

 Directory of C:\projects\Java\test

06/26/2001  11:09a      <DIR>          .
06/26/2001  11:09a      <DIR>          ..
06/26/2001  04:47p      <DIR>          test
06/26/2001  05:03p                 897 build.xml
               1 File(s)            897 bytes

 Directory of C:\projects\Java\test\test

06/26/2001  04:47p      <DIR>          .
06/26/2001  04:47p      <DIR>          ..
06/26/2001  11:10a                 120 Hello.java
06/26/2001  05:04p                 414 Hello.class
               2 File(s)            534 bytes

     Total Files Listed:
               3 File(s)          1,431 bytes
               5 Dir(s)  13,868,351,488 bytes free

C:\projects\Java\test>

<end test results>


And I have the same result.

So can another set of {more experienced} eyes help me understand why this
occurs, and what I need to do to fix this?




C:\projects\Java\test>-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org]
Sent: Tuesday, June 26, 2001 9:47 AM
To: ant-user@jakarta.apache.org
Subject: Re: Another Neophyte Question


Jerry Odenwelder <Jerry.Odenwelder@Mentisys.com> wrote:

> But it always compiles all of by java files whether they need it or
> not.

Does <http://jakarta.apache.org/ant/faq.html#always-recompiles> help?

>    <target name="buildFiles" if="build.required">
>       <javac srcdir="." 
>              destdir="${outputDir}"
>              includes="*.java">
>          <classpath refid="classpath" />
>       </javac>
>    </target>

Where do your source files live, could you give us the location of a
single example file?

Stefan

Mime
View raw message