You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Tom Maccariella <tm...@sengen.com> on 2000/10/31 23:07:50 UTC

JAVAC task

Here's a really simple question, that perhaps someone could help me with:

I am using the <javac> task to compile files in a source directory to a
destination directory (which is in my classpath).  The documentation for the
<javac> task indicates that it will only compile files which "have no
corresponding class file or where the class file is older than the java
file."  However, each time I run my build, *all* java files are re-compiled
to the destination directory.

The only way that I have been able to prevent the compilation is to make the
source and destination directories the same.  (i.e. the .java file is in the
same directory as the .class file)

Any help would be appreciated.  I'm trying to make my build a little faster.

Thanks,
-Tom
tmacc@sengen.com


RE: Conditionalizing an exec task on something changed.

Posted by Conor MacNeill <co...@ebinteractive.com.au>.
Robert,

Have you tried the uptodate task? Checkout the doc for it here
http://jakarta.apache.org/ant/jakarta-ant/docs/#uptodate

You may be able to setup something with it.

--
Conor MacNeill
conor@cortexebusiness.com.au
Cortex eBusiness 
http://www.cortexebusiness.com.au

> -----Original Message-----
> From: robert@elastica.com [mailto:robert@elastica.com]
> Sent: Wednesday, 1 November 2000 12:13
> To: ant-user@jakarta.apache.org
> Subject: Conditionalizing an exec task on something changed.
> 
> 
> I'm guessing you cannot do this but I'd like to be able to only
> execute my exec tasks if rule the determined it was necessary 
> to compile something.
> 
> so
> 
> How can I not do the exec task if no .java files changed.
> 
> <target name="compile" depends="init,prepare">
> 	<mkdir dir="${outputDir}"/>
> 	<javac 
> srcdir="${sourceDir}" destdir="${outputDir}" includes="**/*.java" 
> verbose="true">
> 
> 	<classpath>
> 		<pathelement
> location="third_party/sun/servlet.jar"/>
> 		<pathelement
> location="third_party/sun/jndi.jar"/>
> 		<pathelement
> location="third_party/oracle/classes12_01.zip"/>
> 		<pathelement
> location="third_party/oracle/ojsp.jar"/>
> 		<pathelement
> location="third_party/cybersource/cdkjava3300.jar"/>
> 	</classpath>
> 	</javac>
> 		
> 	<exec executable="net" os="Windows NT">
> 		<arg value="stop"/>
> 		<arg value="JRun Default Server"/>
> 	</exec>
> 	<exec executable="net" os="Windows NT">
> 		<arg value="start"/>
> 		<arg value="JRun Default Server"/>
> 	</exec>
> </target>
> 
> 
> 

Conditionalizing an exec task on something changed.

Posted by ro...@elastica.com.
I'm guessing you cannot do this but I'd like to be able to only
execute my exec tasks if rule the determined it was necessary 
to compile something.

so

How can I not do the exec task if no .java files changed.

<target name="compile" depends="init,prepare">
	<mkdir dir="${outputDir}"/>
	<javac 
srcdir="${sourceDir}" destdir="${outputDir}" includes="**/*.java" verbose="true">

	<classpath>
		<pathelement
location="third_party/sun/servlet.jar"/>
		<pathelement
location="third_party/sun/jndi.jar"/>
		<pathelement
location="third_party/oracle/classes12_01.zip"/>
		<pathelement
location="third_party/oracle/ojsp.jar"/>
		<pathelement
location="third_party/cybersource/cdkjava3300.jar"/>
	</classpath>
	</javac>
		
	<exec executable="net" os="Windows NT">
		<arg value="stop"/>
		<arg value="JRun Default Server"/>
	</exec>
	<exec executable="net" os="Windows NT">
		<arg value="start"/>
		<arg value="JRun Default Server"/>
	</exec>
</target>



Re: make -D in ant?

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "r" == robert  <ro...@elastica.com> writes:

 r> Can I parse in parameters from the command line?  Why can't I do
 r> this

 r> <project name="plymedia" basedir="${rootDir}">

 r> and

 r> ant -DrootDir=C:\plymediadev

Because Ant doesn't evaluate ${} constructs in attributes of project
and target. At least not in Ant 1.2.

The simple workaround, don't specify a basedir in you build file at
all:

<project name="plymedia">

and

ant -Dbasedir=C:\plymediadev

Stefan

RE: make -D in ant?

Posted by ro...@elastica.com.
What can we expect? It would definately be nice to be able to pass in 
properties from the command line especially for baseDir or for that
matter anything else. I don't want to keep these references in the 
.xml file.

On Wed, 1 Nov 2000, Samuel R Listopad II wrote:

> > <project name="plymedia" basedir="${rootDir}">
> >
> > and
> >
> > ant -DrootDir=C:\plymediadev
> >
> > I want to hide all references to absolute paths outside of
> > the build file.
> >
> > when I do this it doesn't evaluate $rootDir as I would expect.
> 
> Ok this is what I was getting at with my last post (albeit poorly).  Ant 1.2
> only seems
> to evaluate properties at creation time.  However I would propose a more
> dynamic system
> where properties were recursively evaluated whenever used.
> 
> i.e. in this case when ${basedir} used it would lookup basedir in the hash,
> get the value
> of ${rootDir},  and the try to extract rootDir from the hashmap and find
> C:\plymediadev.
> 
> Its a simple change,  I was just wondering if it had already been thought of
> and done/shot down
> for some glaring reason I could not see.
> 
> Sam
> 


RE: make -D in ant?

Posted by Samuel R Listopad II <sl...@intercapsystems.com>.
> <project name="plymedia" basedir="${rootDir}">
>
> and
>
> ant -DrootDir=C:\plymediadev
>
> I want to hide all references to absolute paths outside of
> the build file.
>
> when I do this it doesn't evaluate $rootDir as I would expect.

Ok this is what I was getting at with my last post (albeit poorly).  Ant 1.2
only seems
to evaluate properties at creation time.  However I would propose a more
dynamic system
where properties were recursively evaluated whenever used.

i.e. in this case when ${basedir} used it would lookup basedir in the hash,
get the value
of ${rootDir},  and the try to extract rootDir from the hashmap and find
C:\plymediadev.

Its a simple change,  I was just wondering if it had already been thought of
and done/shot down
for some glaring reason I could not see.

Sam


make -D in ant?

Posted by ro...@elastica.com.
Can I parse in parameters from the command line?

Why can't I do this

<project name="plymedia" basedir="${rootDir}">

and 

ant -DrootDir=C:\plymediadev

I want to hide all references to absolute paths outside of the build file.

when I do this it doesn't evaluate $rootDir as I would expect.


RE: JAVAC task

Posted by Conor MacNeill <co...@ebinteractive.com.au>.
Tom,

Point your javac source attribute at the root of your package hierarchy. Use
an include element if you want to select which files in the tree to compile.

Use ant -debug (in ant 1.2) to see where the javac task is looking for class
files. It should explain why it is recompiling each file.

Conor


--
Conor MacNeill
conor@cortexebusiness.com.au
Cortex eBusiness
http://www.cortexebusiness.com.au

> -----Original Message-----
> From: Tom Maccariella [mailto:tmacc@sengen.com]
> Sent: Wednesday, 1 November 2000 9:08
> To: ant-user@jakarta.apache.org
> Subject: JAVAC task
>
>
> Here's a really simple question, that perhaps someone could help me with:
>
> I am using the <javac> task to compile files in a source directory to a
> destination directory (which is in my classpath).  The
> documentation for the
> <javac> task indicates that it will only compile files which "have no
> corresponding class file or where the class file is older than the java
> file."  However, each time I run my build, *all* java files are
> re-compiled
> to the destination directory.
>
> The only way that I have been able to prevent the compilation is
> to make the
> source and destination directories the same.  (i.e. the .java
> file is in the
> same directory as the .class file)
>
> Any help would be appreciated.  I'm trying to make my build a
> little faster.
>
> Thanks,
> -Tom
> tmacc@sengen.com
>
>