You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Steve Allan <st...@wrq.com> on 2002/12/02 19:29:03 UTC

Best practice for numerous javac calls?

Hi,

I hava a java project where all the different components are under one
source root.  To accommodate the developers' request to be able to
build certain subsections of the code and their dependencies, there
are 10 different compile targets.  To avoid duplicating all the
<javac> calls, I wrote a single compile-java target with the idea that
a component's compile target could define the java source and classpath, and
then call the java-compile target.  Here's a typical example:

<target name = "utils" depends = "init">
 <!-- define classpath -->
 <path id = "compile.classpath">
   <pathelement location = "${jaas.jar}"/>
 </path>

 <!-- define source patternset -->
 <patternset id = "java.src">
   <include name = "${my.package.root}/util/**/*.java"/>
   <include name = "${my.package.root}/include/**/*.java"/>
 </patternset>

 <!-- compile classes -->
 <antcall target = "java-compile" inheritrefs = "true"/>
</target>

And the java-compile target looks like this:

<target name = "java-compile">
  <javac destdir     = "${build.classes.dir}"
         srcdir      = "${src.dir}"
	 ...
	 >
     <classpath refid = "compile.classpath"/>
     <patternset refid = "java.src"/>
  </javac>
</target>


This works, but if I build all my components in one call to ant, I
keep getting messages about redefining references:

Overriding previous definition of reference to compile.classpath
Overriding previous definition of reference to java.src

So I'm wondering

1) Is redefining a reference a 'bad thing'?
2) Is there a better way to achieve this type of granularity in the
   compile targets?

Thanks.

-- Steve
// WRQ has 21 years of experience providing integration software and
// services for host-intensive environments. To learn more about our
// Reflection and Verastream products, visit http://www.wrq.com/products/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Best practice for numerous javac calls?

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
I do this very thing in my sample project:

	http://www.ehatchersolutions.com/downloads/

(get the latest version, whatever that happens to be at the time)

Look at my build.xml and how I use <antcall>.  I do not override 
references, I just create a new reference for that particular call.

	Erik


Steve Allan wrote:
> Hi,
> 
> I hava a java project where all the different components are under one
> source root.  To accommodate the developers' request to be able to
> build certain subsections of the code and their dependencies, there
> are 10 different compile targets.  To avoid duplicating all the
> <javac> calls, I wrote a single compile-java target with the idea that
> a component's compile target could define the java source and classpath, and
> then call the java-compile target.  Here's a typical example:
> 
> <target name = "utils" depends = "init">
>  <!-- define classpath -->
>  <path id = "compile.classpath">
>    <pathelement location = "${jaas.jar}"/>
>  </path>
> 
>  <!-- define source patternset -->
>  <patternset id = "java.src">
>    <include name = "${my.package.root}/util/**/*.java"/>
>    <include name = "${my.package.root}/include/**/*.java"/>
>  </patternset>
> 
>  <!-- compile classes -->
>  <antcall target = "java-compile" inheritrefs = "true"/>
> </target>
> 
> And the java-compile target looks like this:
> 
> <target name = "java-compile">
>   <javac destdir     = "${build.classes.dir}"
>          srcdir      = "${src.dir}"
> 	 ...
> 	 >
>      <classpath refid = "compile.classpath"/>
>      <patternset refid = "java.src"/>
>   </javac>
> </target>
> 
> 
> This works, but if I build all my components in one call to ant, I
> keep getting messages about redefining references:
> 
> Overriding previous definition of reference to compile.classpath
> Overriding previous definition of reference to java.src
> 
> So I'm wondering
> 
> 1) Is redefining a reference a 'bad thing'?
> 2) Is there a better way to achieve this type of granularity in the
>    compile targets?
> 
> Thanks.
> 
> -- Steve
> // WRQ has 21 years of experience providing integration software and
> // services for host-intensive environments. To learn more about our
> // Reflection and Verastream products, visit http://www.wrq.com/products/
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>