Reputation: 5915
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
Upvotes: 4
Views: 2408
Reputation: 11952
Use the delete
task before javac
to clean old compiled classes:
In general java classes should not be recompiled if the API of the dependent classes haven't changed.
Also I would suggest using maven as it handles dependencies more gracefully.
Upvotes: 2