ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy Lambert <anto...@gmx.de>
Subject Re: [Personnal task] Executing javac from a task container
Date Fri, 06 Mar 2009 22:27:13 GMT

Hello Gervais,

out of my head I do not see anything specific about the javac task which 
would restrict its usage. Maybe you are just not passing to it the 
location of a directory containing source files due to a scripting 
error, or a mis-assumption about where the source directories are.

What I do not understand clearly from your email is how do your custom 
task and your build file interact ?

To find out in detail what is happening with javac, you could run your 
build in verbose mode.  (ant -v)


The classical way to compile and package many jars would be to :

- either create one build file per source folder,

- have these folder specific build files import  a generic build file in 
one location which can work for each source folder,

- then use the <subant/> task to iterate through the source folders


Regards,

Antoine


Gervais wrote:
> Hi everybody,
>
> I need to compile and package many jars (one jar per source folder). Because
> I haven't found any task to do that, I have writing my own who extends
> org.apache.tools.ant.Task and implements org.apache.tools.ant.TaskContainer.
>
> She work great with tasks like "echo", "mkdir", "copy" but the "javac" task
> is never executed. How can I run the "javac" task from a TaskContainer ?
>
> Here is the main code and you can found the full class as attachment.
> public void execute() throws BuildException {
> 	if ( baseDir.isDirectory() ) {
> 		for (File subdir : baseDir.listFiles(new DirectoryFilter()))
> {
> 			if ( getProject().getProperty(identifier)==null ) {
> 				getProject().setNewProperty(identifier,
> subdir.getName());
> 			} else {
> 				getProject().setProperty(identifier,
> subdir.getName());
> 			}
> 	
> 			for (Task subtask : tasks) {
> 				log("> Run task "+subtask.getTaskName());
> 				subtask.perform();
> 			}
> 		}
> 	} else {
> 		log("Base directory \""+baseDir+"\". isn't a directory.",
> 0);
> 	}
> }
>
> And finally the task content :
> <foreach
> basedir="${manager.location}${file.separator}${manager.moddir}" 
> 					identifier="modulename">
> 			<echo level="info">Building module
> ${modulename}</echo>
> 			<mkdir
> dir="${modsdir}${file.separator}sicsmod-${modulename}"/>
> 			<javac
> srcdir="${manager.location}${file.separator}${manager.moddir}${file.separato
> r}${modulename}" 
> 	
> destdir="${modsdir}${file.separator}sicsmod-${modulename}" 
> 	
> classpathref="manager.modules.classpath" 
> 	
> classpath="${build}${file.separator}${manager.jarname}"
> 					includes="${manager.modules}/**" 
> 					debug="on" />
> 			<!-- Copy each properties files (resources) and
> images -->
> 			<copy
> todir="${modsdir}${file.separator}sicsmod-${modulename}">
> 				<fileset
> dir="${manager.location}${file.separator}${manager.moddir}${file.separator}$
> {modulename}" 
> 						includes="**/*.properties,
> **/*.png" />
> 			</copy>
> 		</foreach>
>
> Thanks
>  
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature
> database 3912 (20090306) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>  
>
>   
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message