You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jesse Tilly <JT...@hoteltools.com> on 2000/10/20 20:41:08 UTC

RE: Javac

Dan,

I'm not sure what you're trying to achieve, but this isn't an ANT
limitation, this is a result of object definitions within Java and thus
within Java compilers.

Even if you explicitly stated taht file1.java must be compiled, unless the
class file already existed, any code module file1.java referred to would be
compiled as well.  The compilers perform of sort of automatic dependency
checking.  It isn't smart and it isn't all inclusive.  javac only goes one
deep, but that is per file, so that usually catches a lot of files without
you knowing.  For example, file1.java has a field file2, file2.java has a
field file3 and file3.java has a field file1.  Compiling any one of these
files will cause the other two to be compiled.  

Could you expound on your goal?

Jesse

-----Original Message-----
From: Dan MacKay [mailto:dan.mackay@KINGSTON.HUMMINGBIRD.COM]
Sent: Friday, October 20, 2000 2:43 PM
To: ant-user@jakarta.apache.org
Subject: Javac


Hi all,

Is it possible to have javac not compile a whole tree. I have to control the
the order of compilation. My directory structure is as follows:

root directory:
               file1.java
               file2.java

               sub_dir1:
                        many files *.java

               sub_dir2:
                        many files *.java

               sub_dir3:
                        many files *.java

I have to compile and stage these files at different points through the
build process. I have to start at the root and compile the two files there
to the exclusion of the rest of the files in the resident sub-directories.
My initial niave attempt was as follows:

  <target name="compile"  depends="getSource" >
  <!-- Build the root -->
    <echo message="Building the root"/>
    <javac optimize="${optimize}"
           srcdir="${srcDir}\com\hcl\dal\"
           destdir="${outDir}"
           classpath="${cdkDir}\lib/nova.jar;${outDir}"
           debug="${debug}"/>
  <!target>

This blithly motors along and compiles the whole shebang, sub-directories
included and eventually fails in the sub_dir1 build when it cannot find
dependancies for resources have not been found because they have not been
staged yet. Could someone give me an example of the includes/exclude
directives that would be necessary to ensure that only file1.java and
file2.java are compiled?

Thanks

Dan

RE: Javac

Posted by Alan Gerhard <AG...@E-SyncNet.Com>.
Dan 

I think I understand what you want to do. I had a similar problem in which was set with multiple targets, a classlist file and restrictions to the includes list. Don't think you need to implement the full build as I but the following might work (based on your given data)

<target name="root">
	<javac srcdir="${root}" destdir="${build}" includes="file1.java, file2.java" />
</target>

<target name="sub-dir1" depends="root">
	<javac srcdir="${sub-dir1}" destdir="${build}" />
		or
	<javac srcdir="${root}" destdir="${build} includes="sub-dir1/**.java" />
</target>

<target name="sub-dir2" depends="sub-dir1">
	<javac srcdir="${sub-dir2}" destdir="${build}" />
</target>

<target name="make" depends="sub-dir2">
	<echo message="This will force javac to start with root and then work it's way through"/>
	<echo message="provided the time comparisons generate the desired response"/>
</target>


The above should produce the effect you're after...

alan

	
-----Original Message-----
From: Dan MacKay [mailto:dan.mackay@KINGSTON.HUMMINGBIRD.COM]
Sent: Friday, October 20, 2000 2:43 PM
To: ant-user@jakarta.apache.org
Subject: Javac


Hi all,

Is it possible to have javac not compile a whole tree. I have to control the
the order of compilation. My directory structure is as follows:

root directory:
               file1.java
               file2.java

               sub_dir1:
                        many files *.java

               sub_dir2:
                        many files *.java

               sub_dir3:
                        many files *.java

I have to compile and stage these files at different points through the
build process. I have to start at the root and compile the two files there
to the exclusion of the rest of the files in the resident sub-directories.
My initial niave attempt was as follows:

  <target name="compile"  depends="getSource" >
  <!-- Build the root -->
    <echo message="Building the root"/>
    <javac optimize="${optimize}"
           srcdir="${srcDir}\com\hcl\dal\"
           destdir="${outDir}"
           classpath="${cdkDir}\lib/nova.jar;${outDir}"
           debug="${debug}"/>
  <!target>

This blithly motors along and compiles the whole shebang, sub-directories
included and eventually fails in the sub_dir1 build when it cannot find
dependancies for resources have not been found because they have not been
staged yet. Could someone give me an example of the includes/exclude
directives that would be necessary to ensure that only file1.java and
file2.java are compiled?

Thanks

Dan