Compiled classes are not included in generated Jar - ant

I am creating a jar bundle using ant build script. The problem is that the .class files are not included in the generated .jar file. I have also tried the {build.dest} in making the jar, but with no effect.
remaining all the files i require are in .jar file.
Here is my build script
<?xml version="1.0"?>
<project name="TaskNodeBundle" default="all" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="bundlename" value="task-node-bundle" />
<property name="src.dir" location="../src" />
<property name="lib.dir" location="../lib" />
<property name="build.dir" location="/buildoutput" />
<property name="build.dest" location="../build/dest" />
<!--
Create a classpath container which can be later used in the ant task
-->
<path id="classpath">
<fileset dir="${lib.dir}/">
<include name="*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${build.dest}" />
</target>
<!-- Deletes the existing build directory -->
<target name="mkdir" depends="clean">
<mkdir dir="${build.dest}"/>
</target>
<!-- Compiles the java code -->
<target name="compile" depends="mkdir">
<javac srcdir="${src.dir}" destdir="${build.dest}" classpathref="classpath" />
</target>
<target name="package-bundle" depends="compile" description="Generates the bundle" >
<jar destfile="${build.dest}/${bundlename}.jar" manifest="${src.dir}/META-INF/MANIFEST.MF">
<fileset dir="${src.dir}">
<include name="**/**.class" />
<include name="**/**.properties"/>
<include name="/META-INF/**.*" />
<include name="/META-INF/spring/**.*" />
</fileset>
</jar>
</target>
<target name="all" depends="package-bundle">
</target>
</project>

Firstly, what do you mean by "tried {build.dest} in making the jar"?
Whatever, you need to take a look at this part of your build:
<jar destfile="${build.dest}/${bundlename}.jar" manifest="${src.dir}/META-INF/MANIFEST.MF">
<fileset dir="${src.dir}">
<include name="**/**.class" />
<include name="**/**.properties"/>
<include name="/META-INF/**.*" />
<include name="/META-INF/spring/**.*" />
</fileset>
</jar>
You compiled class files are in ${build.dest}, so you should use ${build.dest} as the root dir for the nested <fileset> of the <jar> task. But now you are pointing the <fileset> to your source code folder.
You should avoid putting the generated jar file in the same directory where the class files are. For example, you can put the jar in ${dist.dir}, which is another directory.
So try this:
You have a property:
<property name="dist.dir" value="../build/dist" />
And then,
<jar destfile="${dist.dir}/${bundlename}.jar" manifest="${src.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dest}">
<include name="**/*.class" />
</fileset>
<fileset dir="${src.dir}">
<include name="**/*.properties"/>
<include name="/META-INF/**/*.*" />
<include name="/META-INF/spring/**/*.*" />
</fileset>
</jar>

Related

How to deploy configuration files,jars and ear files in remote weblogic server using ant script

I want to deploy the jar files,configuration files and generated ear file on remote weblogic server using ant script.
I have created ant script that stop the weblogic server,delete old files(jar,config xml files,ear) copy the given source to destination,this script is work when source and destination both are having on same machine.
<project name="Svn" default="startserver">
<property name="bea.home" value="C:/Oracle/Middleware/Oracle_Home" />
<property name="weblogic.home" value="${bea.home}/wlserver" />
<property name="domain.home" value="${bea.home}/user_projects/domains" />
<property name="domain.name" value="NAPF_domain" />
<property name="host" value="10.254.5.191" />
<property name="port" value="7001" />
<property name="username" value="weblogic" />
<property name="password" value="weblogic" />
<property name="admin.server.name" value="AdminServer" />
<property name="libdeploy.dir" value="${domain.home}/${domain.name}/lib/" />
<property name="configdeploy.dir" value="${domain.home}/${domain.name}/pf-appl/config/" />
<property name="eardeploy.dir" value="${domain.home}/${domain.name}/servers/AdminServer/upload/" />
<property name="libsource.dir" value="napf-main/napf-build/release/target/Release/lib/" />
<property name="configsource.dir" value="napf-main/napf-build/release/target/Release/config/" />
<property name="earsource.dir" value="napf-main/napf-build/release/target/Release/dist/" />
<property name="napfscutitysource.dir" value="napf-main/napf-security-lib" />
<property name="sourceMonitorHome" location="NAPF_SERVER_SOURCE/SourceMonitor"/>
<path id="wls.classpath">
<fileset dir="${weblogic.home}/server/lib">
<include name="web*.jar" />
</fileset>
</path>
<taskdef name="wlserver" classname="weblogic.ant.taskdefs.management.WLServer" classpathref="wls.classpath" />
<target name="start-server">
<wlserver dir="${domain.home}/${domain.name}" host="${host}" port="${port}" domainname="${domain.name}" servername="${admin.server.name}" action="start" username="${username}" password="${password}" beahome="${bea.home}" weblogichome="${weblogic.home}" verbose="true" noexit="true" protocol="t3" classpath="${weblogic.home}/server/lib/weblogic.jar">
<jvmarg value="-server" />
<jvmarg value="-Xms256m" />
<jvmarg value="-Xmx512m" />
<jvmarg value="-XX:PermSize=128m" />
<jvmarg value="-XX:MaxPermSize=256m" />
</wlserver>
<sleep seconds="2" />
</target>
<target name="stop-server">
<wlserver dir="${domain.home}/${domain.name}" host="${host}" port="${port}" servername="${admin.server.name}" username="${username}" password="${password}" action="shutdown" beahome="${bea.home}" weblogichome="${weblogic.home}" forceshutdown="true" />
</target>
<target name="purge-deploy" description="Delete old deploy files.">
<echo message="Deleting old deploy files..." />
<delete includeEmptyDirs="true">
<!-- Delete all jar files -->
<fileset dir="${libdeploy.dir}" includes="**/*" />
<!-- Delete all config files -->
<fileset dir="${configdeploy.dir}" includes="**/*" />
</delete>
</target>
<target name="copyToSecurityLib" description="Copy files to napf security folder.">
<copy todir="${libdeploy.dir}">
<fileset dir="${napfscutitysource.dir}">
<include name="**" />
<!-- ignore files/folders starting with svn -->
<exclude name="**/.svn" />
</fileset>
</copy>
</target>
<target name="copyToDeploy" description="Copy files to deploy folder.">
<copy todir="${libdeploy.dir}">
<fileset dir="${libsource.dir}">
<include name="**" />
<!-- ignore files/folders starting with svn -->
<exclude name="**/.svn" />
</fileset>
</copy>
<copy todir="${configdeploy.dir}">
<fileset dir="${configsource.dir}">
<include name="**" />
<!-- ignore files/folders starting with svn -->
<exclude name="**/.svn" />
</fileset>
</copy>
<copy todir="${eardeploy.dir}">
<fileset dir="${earsource.dir}">
<include name="**" />
<!-- ignore files/folders starting with svn -->
<exclude name="**/.svn" />
</fileset>
</copy>
</target>
<target name="purgeReport" description="Delete old report files.">
<echo message="Deleting old report files..." />
<delete includeEmptyDirs="true">
<fileset dir="${sourceMonitorHome}" includes="**/*.csv,*.jpeg,*.smp" />
</delete>
</target>
<target name="startSourceMonitor">
<exec dir="${sourceMonitorHome}" executable="cmd" failonerror="true" spawn="false">
<arg value="/c"/>
<arg value="sourcemonitor.bat"/>
</exec>
</target>
<target name="copyReportFiles" description="Copy files to napf source directory to slave workspace directory.">
<delete includeEmptyDirs="true">
<fileset dir="${sourceMonitorWorkSpace}"/>
</delete>
<mkdir dir="${sourceMonitorWorkSpace}"/>
<sleep seconds="1" />
<copy todir="${sourceMonitorWorkSpace}">
<fileset dir="${sourceMonitorHome}">
<include name="**/*.csv" />
<include name="**/*.jpeg" />
<exclude name="**/.svn" />
</fileset>
</copy>
</target>
Please suggest.
You can try wldeploy Ant task.
First, add task definition.
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="${weblogic.home}/server/lib/weblogic.jar"/>
</classpath>
</taskdef>
Next, configure each action of wldeploy task, such as deploy, redeploy, or undeploy specifically.
Example,
<!-- The deployment name for the deployed application.
If you do not specify this attribute, WebLogic Server assigns a deployment name to the application, based on its archive file or exploded directory. -->
<property name="deploy.name" value="MyApp"/>
<!-- The archive file or exploded directory to deploy. -->
<property name="deploy.source" value="MyApp.ear"/>
<!-- The list of target servers to which the application is deployed.
The value of this attribute is a comma-separated list of the target servers, clusters, or virtual hosts.
If you do not specify a target list when deploying an application, the target defaults to the Administration Server instance. -->
<property name="deploy.targets" value="MyCluster"/>
<!-- Deploying Applications -->
<target name="deploy">
<wldeploy action="deploy"
name="${deploy.name}"
user="${username}"
password="${password}"
remote="true"
adminurl="t3://${host}:${port}"
source="${deploy.source}"
targets="${deploy.targets}"/>
</target>
<!-- Redeploying Applications -->
<target name="redeploy">
<wldeploy action="redeploy"
name="${deploy.name}"
user="${username}"
password="${password}"
remote="true"
adminurl="t3://${host}:${port}"
targets="${deploy.targets}"/>
</target>
<!-- Undeploying Applications -->
<target name="undeploy">
<wldeploy action="undeploy"
name="${deploy.name}"
failonerror="false"
user="${username}"
password="${password}"
remote="true"
adminurl="t3://${host}:${port}"
targets="${deploy.targets}"/>
</target>
Please note that if we want to deploy the JAR or EAR to remote WebLogic server, we must explicitly set the remote attribute in wldeploy tag to true, since the default value is false.
More complete reference regarding the task can be found on https://docs.oracle.com/cd/E12839_01/web.1111/e13706/wldeploy.htm
The above task would work if you are just specifying the remote server file path. Essentially you would need two parameters one is remote and other being upload.
The same would work but i see an parameter is missing for the task if you are deploying from a remote server
<target name="deploy1">
<wldeploy action="deploy"
upload="true"
remote="true"
name="${deploy.name.1}"
source="${deploy.source.1}"
user="${wls.username}"
password="${wls.password}"
verbose="true"
adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

Ant task "javac" was successful but doesn't produce any output

I'm trying to compile a project using ant. I guess the "javac" task was successful as i can see the following message on the console:
[javac] Compiling 151 source file to /var/lib/jenkins/jobs/project1/workspace/build
Here is the complete output of the command "ant compile"
clean:
[delete] Deleting directory /var/lib/jenkins/jobs/project1/workspace/build
[delete] Deleting directory /var/lib/jenkins/jobs/project1/workspace/docs
[delete] Deleting directory /var/lib/jenkins/jobs/project1/workspace/dist
makedir:
[mkdir] Created dir: /var/lib/jenkins/jobs/project1/workspace/build
[mkdir] Created dir: /var/lib/jenkins/jobs/project1/workspace/docs
[mkdir] Created dir: /var/lib/jenkins/jobs/project1/workspace/dist
compile:
[javac] /var/lib/jenkins/jobs/project1/workspace/build.xml:43: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 151 source file to /var/lib/jenkins/jobs/project1/workspace/build
BUILD SUCCESSFUL
Total time: 1 second
The problem is there is nothing produced in the folder "build" !
I'm using the same build.xml template file in other projects and it works very well, but here i can't understand why i can't find the compiled sources in the build folder.
Please help.
Here is my build.xml file:
<?xml version="1.0"?>
<project name="project1" default="main" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="src.dir" location="src" />
<property name="lib.dir" location="WebContent/WEB-INF/lib" />
<property name="server.common.lib.dir" location="/home/ghali/jboss-5.1.0.GA/common/lib" />
<property name="server.lib.dir" location="/home/ghali/jboss-5.1.0.GA/lib" />
<property name="build.dir" location="build" />
<property name="dist.dir" location="dist" />
<property name="docs.dir" location="docs" />
<!--
Create a classpath container which can be later used in the ant task
-->
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${server.common.lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${server.lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- Deletes the existing build, docs and dist directory-->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${docs.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Creates the build, docs and dist directory-->
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<!-- Compiles the java code -->
<target name="compile" depends="clean, makedir">
<javac destdir="${build.dir}" classpathref="build.classpath" debug="true">
<src path="${src.dir}" />
</javac>
</target>
<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc sourcepath="${src.dir}" destdir="${docs.dir}">
<!-- Define which files / directory should get included, we include all -->
<fileset dir="${src.dir}">
<include name="**" />
</fileset>
</javadoc>
</target>
<!--Creates the deployable jar file -->
<target name="package" depends="compile">
<war destfile="${dist.dir}/project1.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent" />
<lib dir="WebContent/WEB-INF/lib" />
<classes dir="${build.dir}" />
</war>
</target>
<target name="main" depends="compile, package, docs">
<description>Main target</description>
</target>
</project>

Generating MD5 for files in an ant-contrib for loop in ANT

I am selecting set of files using file set and then using them to generate the checksum of all the files in the selected fileset
here is my script
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="MyTask1" basedir="." default="jar">
<property name="cms.dir" value="D:\Test" />
<property name="comma" value="," />
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="A">
<fileset id="src.files" dir="${cms.dir}" casesensitive="yes">
<include name="**/*.uim"/>
<include name="**/*.properties"/>
<include name="**/*.txt"/>
</fileset>
<pathconvert pathsep="${line.separator}" property="sounds" refid="src.files">
<!-- To get the names of the files only then use mapper-->
<!-- <mapper type="flatten" />-->
</pathconvert>
<delete file="sounds.txt"/>
<for list="${sounds}" delimiter="${line.separator}" param="mod">
<sequential>
<checksum file="#{mod}" property="MD5_Value"/>
<echo file="sounds.txt" append="true">#{mod}${comma}${MD5_Value}${line.separator}</echo>
</sequential>
</for>
<!--<checksum file="Test.txt" property="foobarMD5"/>-->
<!--<echo file="sounds.txt">${foobarMD5}</echo>-->
</target>
</project>
However its failing and its generating duplicate MD5 value here is my output
D:\Test\Test1.txt,6d326741a99efbcda928e5096b43cb9a
D:\Test\Test2.txt,6d326741a99efbcda928e5096b43cb9a
Any help ...
The checksum task can process filesets...
<checksum>
<fileset dir=".">
<include name="foo*"/>
</fileset>
</checksum>
Lot simpler than using the for task, which is not part of standard ANT.

MANIFEST.MF is override after running build.xml using ant

have following directory structure
src/com
src/META-INF/MANIFEST.MF
src/META-INF/spring
src/META-INF/spring/context.xml
now when i run the script, my menifest file is override, i don't want that, because i have to add custom enteries in it and i want that to be adding in generated .jar file. THing is all other files are copied, but this one is override.
my build.xml is as follows
<project name="TaskNodeBundle" default="all" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="bundlename" value="tasknodebundle" />
<property name="src.dir" location="../src" />
<property name="lib.dir" location="../lib" />
<property name="build.dir" location="/buildoutput" />
<property name="build.dest" location="../build/dest" />
<!--
Create a classpath container which can be later used in the ant task
-->
<path id="classpath">
<fileset dir="${lib.dir}/">
<include name="*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${build.dest}" />
</target>
<!-- Deletes the existing build directory-->
<target name="mkdir" depends="clean">
<mkdir dir="${build.dest}"/>
</target>
<!-- Compiles the java code -->
<target name="compile" depends="mkdir">
<javac srcdir="${src.dir}" destdir="${build.dest}" classpathref="classpath" />
</target>
<target name="package-bundle" depends="compile" description="Generates the bundle">
<jar destfile="${build.dest}/${bundlename}.jar">
<fileset dir="${src.dir}">
<include name="**/**.class" />
<include name="**/**.properties"/>
<include name="/META-INF/**.*" />
<include name="/META-INF/spring/**.*" />
</fileset>
</jar>
</target>
<target name="all" depends="package-bundle">
</target>
</project>
See http://ant.apache.org/manual/Tasks/jar.html.
If the manifest is omitted, a simple one will be supplied by Apache
Ant.
Just add manifest attribute or use zip task.
Also ant path masks are used incorrectly. See http://en.wikibooks.org/wiki/Apache_Ant/Fileset.
Corrected version:
<zip destfile="${build.dest}/${bundlename}.jar">
<fileset dir="${src.dir}">
<include name="META-INF/**" />
<include name="**/*.class" />
<include name="**/*.properties"/>
</fileset>
</zip>

How to Obfuscate my web application project.war using Ant & YGuard?

We developed a web application (struts 1.x/Hibernate based) for which I built a
war file using ANT build script. Now, my company wants me to obfuscate the .classes files
before generating a war & distributing it to the client. When I googled, I came
across an example using YGuard library to accomplish this task. The link was pretty useful however, I only had a partial success, as it obfuscated all the java classes, leaving behind the hibernate mapping (*.hbm.xml) files un-obfuscated, which had references to these classes which were already obfuscated.
For example: After obfuscation, references to MenuGlobalBean.class would turn to something like say A.B.H.I.N(where A,B..are package names & N is the class name).
But my MenuGlobal.hbm.xml still refers to this as
<class name="com.mycompany.myproduct.bean.MenuGlobalBean" table="MENU_GLOBAL">
rather than
<class name="A.B.H.I.N" table="MENU_GLOBAL">
Now my question is how do I obfuscate my war file in such a way that
the obfuscated class references reflect in my *.hbm.xml & other config/property files if any.
Below is my complete ANT build script using YGuard library for obfuscation
<!-- Build MyProject.war section -->
<project name="MyProject" default="dist" basedir=".">
<property name="proj-home" value="/home/simba/tomcat-7.0.19/webapps/MyProject" />
<!-- set global properties for this build -->
<property name="src" location="WEB-INF/src"/>
<property name="build" location="build"/>
<property name="lib" location="WEB-INF/lib"/>
<property name="dist" location="dist"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<path id="project-classpath">
<fileset dir="${proj-home}/WEB-INF/lib" includes="*.jar" />
</path>
<target name="copy-non-java-files">
<copy todir="build" includeemptydirs="false">
<fileset dir=".">
<include name="*" />
<include name="css/**/*" />
<include name="help_files/**/*" />
<include name="images/**/*" />
<include name="js/**/*" />
<include name="jsp/**/*" />
<include name="schemas/**/*" />
<include name="Sounds/**/*" />
<include name="VideoImage/**/*" />
<exclude name="WEB-INF/src" />
<exclude name="yguard.jar" />
<exclude name="*.war" />
<exclude name="build.xml" />
</fileset>
<fileset dir=".">
<include name="WEB-INF/classes/**/*" />
<include name="WEB-INF/classes/*.xml" />
<include name="WEB-INF/lib/**/*" />
<include name="WEB-INF/*.xml" />
<include name="WEB-INF/*.properties"/>
<include name="WEB-INF/*.dtd" />
<include name="WEB-INF/*.tld" />
<include name="WEB-INF/*.txt" />
<include name="WEB-INF/*.ico" />
</fileset>
</copy>
</target>
<target name="compile" depends="clean,init,copy-non-java-files" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}/WEB-INF/classes" classpathref="project-classpath"/>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<war jarfile="${dist}/lib/MyProject.war" basedir="${build}"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
<!-- Using Yguard to obfuscate my .war file -->
<!-- prepare a temporary directory in which the war file is expanded and obfuscated -->
<tempfile property="unwar.dir" destdir="${java.io.tmpdir}" deleteonexit="no"/>
<mkdir dir="${unwar.dir}"/>
<unwar src="${dist}/lib/MyProject.war" dest="${unwar.dir}"/>
<!-- create a jar of webapp classes (required by yguard) for obfuscation -->
<jar destfile="${unwar.dir}/WEB-INF/lib/MyProject.jar" whenempty="fail">
<zipfileset dir="${unwar.dir}/WEB-INF/classes" excludes="*.xml,*.properties"/>
</jar>
<delete dir="${unwar.dir}/WEB-INF/classes/*" excludes="*.xml,*.properties"/>
<!-- create a fileset of internal libraries to be obfuscated -->
<fileset dir="${unwar.dir}/WEB-INF/lib" id="internal.lib.set">
<include name="MyProject.jar"/>
</fileset>
<!-- move the internal libraries to a temporary directory and make a fileset out of them -->
<tempfile property="obfuscation.dir" destDir="${java.io.tmpdir}" deleteonexit="yes"/>
<mkdir dir="${obfuscation.dir}"/>
<move todir="${obfuscation.dir}">
<fileset refid="internal.lib.set"/>
</move>
<!-- create a jar of web.xml (required by yguard) for obfuscation -->
<jar destfile="${obfuscation.dir}/web.xml.jar" whenempty="fail">
<zipfileset dir="${unwar.dir}/WEB-INF" includes="*.xml"/>
</jar>
<!--<delete file="${unwar.dir}/WEB-INF/web.xml"/> -->
<!-- make a fileset of all jars to be obfuscated -->
<fileset dir="${obfuscation.dir}" includes="*.jar" id="in-out.set"/>
<!-- make a fileset of the remaining libraries, these are not obfuscated -->
<path id="external.lib.path">
<fileset dir="${unwar.dir}/WEB-INF/lib" includes="*.jar"/>
</path>
<taskdef name="yguard"
classname="com.yworks.yguard.YGuardTask"
classpath="../ref/yguard.jar"/>
<yguard>
<inoutpairs>
<!-- these filesets are inputs to be obfuscated -->
<fileset refid="in-out.set"/>
</inoutpairs>
<externalclasses refid="external.lib.path"/> <!-- external libs, not obfuscated -->
<rename>
<adjust replaceContent="true">
<include name="web.xml"/> <!-- modified to reference the obfuscated Servlet -->
<include name="struts-config.xml"/>
<include name="*.hbm.xml"/>
</adjust>
<keep>
<!-- classes, packages, methods, and fields which should not obfuscated are specified here -->
</keep>
</rename>
</yguard>
<!-- move our newly obfuscated classes back into the lib area -->
<move todir="${unwar.dir}/WEB-INF/lib">
<fileset dir="${obfuscation.dir}" includes="*_obf.jar"/>
</move>
<!-- unjar the adjusted web.xml -->
<unzip dest="${unwar.dir}/WEB-INF/" src="${unwar.dir}/WEB-INF/lib/web.xml_obf.jar">
<patternset includes="*.xml"/>
</unzip>
<!-- <delete>
<fileset dir="${unwar.dir}/WEB-INF/lib" includes="web.xml*.jar"/>
</delete> -->
<!-- rebuild the war file -->
<war destfile="MyProject_obf.war" basedir="${unwar.dir}"/>
</project>
Use the same trick I used to encrypt the references in web.xml -- temporarily put the Hibernate .xml files into a jar. (See the section commented by "create a jar of web.xml (required by yguard) for obfuscation".)

Resources