ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Viraj Purang <viraj_pur...@spincircuit.com>
Subject Urgent : Error , Exception handling
Date Wed, 27 Jun 2001 01:19:26 GMT
Hi Diane,
   I am pretty much done with the build scripts conbversion at my company
thanks largely due to your help.There is one small thing about which I have
been thinking and that is about error handling.
   Do we have IF THEN ELSE kind of options anywhere in Ant ? Or any other
exception catching routines ?  How did you do them in your projects ? What
if an error happens during a build ? what do you do after that ? Do you have
some examples on teh same ?

Also, I just need this in order to start benchmarking my and my teams work.
 
WHat is the standard amount of time you would expect a neophyte to take to 
finish off a build subystem creation/conversion project for a multi-tiered 
application of say  2000 class files and a total of 6000 files ?

Regards,
Viraj Purang

  

-----Original Message-----
From: Diane Holt [mailto:holtdl@yahoo.com]
Sent: Tuesday, June 26, 2001 6:10 PM
To: ant-user@jakarta.apache.org
Subject: RE: Another Neophyte Question


Jerry,

In your first example, the problem is you need to have your Hello.java in
a "test" subdir, since you've declared it to be in package "test", so the
Java compiler will create a "test" subdir of the directory you've told it
to put classfiles into (ie., the dir pointed to with -d) and put the
classfile in that "test" subdirectory. That's why <javac> expects the
source-tree dir structure to match the package dir structure, because the
compiler outputs classfiles in subdirs based on the package.

In your second example, where you do have Hello.java living in a "test"
subdir, which is correct, you've changed srcdir to point to that subdir,
which is incorrect, since srcdir expects to be pointed up to, but not
including, the directory where the package structure begins -- and in your
case the "test" subdir is where your package structure begins, since
Hello.java is part of package "test". If a .java file isn't part of a
package, the compiler will simply put it into the dir pointed to by the -d
flag, in which case, <javac> needs to be given a path up to where the
.java files live -- in other words, if you didn't declare Hello.java
to be in package "test", you -would- need to point srcdir to the "test"
directory, since that's both where the .java file lives and where the
.class file will be output by the compiler.
 
Hope this helps,
Diane

--- Jerry Odenwelder <Jerry.Odenwelder@Mentisys.com> wrote:
> 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


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Mime
View raw message