Ant: How to force java compilation if classpath jars have changed but sources have not

Posted by Ittai on Stack Overflow See other posts from Stack Overflow or by Ittai
Published on 2010-12-26T09:41:11Z Indexed on 2010/12/26 9:54 UTC
Read the original article Hit count: 340

Filed under:
|
|
|
|

Hi,
I have the following usecase:
I have a java project (myProj) which uses a common.jar from a different project(common). I want the javac ant task to work even if the sources of myProj have not changed if the common.jar has changed (as the sources of myProj depend of it and might be invalid now).
I have a task which copies the common.jar from a central location to the myProj lib if it has changed and I can use it to set a property whether or not to "force" compilation so that end is taken care of.
I'm not sure how (or if) I can tell the javac task to try and compile anyway? I don't want to change myProj's sources (or timestamps) so that the task will start.
Excerpt from the ant build.xml file:

<path id="project.class.path">  
<pathelement location... />  
...  
<fileset dir="lib" includes="**/*.jar" />  
</path>  
<target name="copyLibs" >  
<copy file="${central.loc}/common.jar" todir="lib" />  
...  
</target>  
<target name="javac" >  
<javac srcdir="src" includes="**" excludes=... >  
<classpath refid="project.class.path"/>  
</javac>  
</target>  

Thanks in advance,
Ittai

© Stack Overflow or respective owner

Related posts about java

Related posts about ant