Reputation: 1088
am working on a java project where am using ant as build tool.
Suppose I have two projects X and Y and both are interdependent. Am looking for some thing where I can exclude some jars during the build i.e, when I build the project A it should exclude some jars during the build and while creating the war.
I know that if we want to include and exclude jars from the classpath we give
<include> and <exclude>
in build.xml file. But how do we do it when we want to include or exclude the jars which are outside the project.
Any help is appreciated.
I referred to the below one, but could not get any idea. Excluding jars from dynamically generated classpaths?
Upvotes: 1
Views: 2595
Reputation: 1088
Finally I was able to find a solution to my question. Am posting the answer thinking it might be useful for someone in the future.
I was able to make it work using the <exclude>
task. Below is the code snippet.
<target>
<delete dir="${dest.dir}" failonerror="false" />
<mkdir dir="${dest.dir}" />
<war destfile="${package.file}" webxml="${temp.dir.web-inf}/web.xml" basedir="${temp.dir}">
<fileset dir="${pages.dir}"/>
<lib dir="${lib.dir}">
<exclude name="servlet-api.jar"/>
<include name="de.vogella.build.test.ant.jar"/>
</lib>
<classes dir="${temp.dir.classes}" />
</war>
</target>
The reason it did not work for me in the beginning was i did not include any <delete>
task which would delete the war file each time the project is built. So the old war file was not replaced and it was not showing me any changes. Once I included the delete it started deleting the previous build war file and updating with a new one which worked extremely fine.
Upvotes: 1