I have a folder structure like this,
samples/soap-client/target/layout/srcdist/etc/wsdl/v1/...
samples/soap-client/target/layout/srcdist/etc/wsdl/v2
samples/soap-client/target/layout/war/.....
i want to copy the all content of layout folder to another location except wsdl folder. my code is like this
<copy todir="${pse-layout.dir}/sdk/partnersdk/new-soap-client">
<fileset dir="samples/soap-client/target/layout">
<exclude name="**/**/wsdl/"/>
<include name="**/*"/>
</fileset>
</copy>
but this is not working.this copies the whole content of layout folder including wsdl folder. please help me.
Try to change your copy task to:
<copy todir="${pse-layout.dir}/sdk/partnersdk/new-soap-client">
<fileset dir="samples/soap-client/target/layout">
<include name="**/*"/>
<exclude name="**/wsdl/**"/>
</fileset>
</copy>
This will exclude all the wsdl folders you have in your layout folder.
Related
I am working on an open source project that uses ANT which can perform all kind of useful targets.
One of them generate an executable jar and a webapp directory in the same directory. I tried to find ways to package that webapp directory with the jar, there is tons of information out there but non of them provide a example that fits my problem.
Open Refine is a great data cleansing tool, you can start it using a script that takes different start up arguments.
It is built using jetty Web server and Web app for UI. Architecture here.
It uses ANT for deployment management, where there is a task that create the Linux kit:
<target name="linux" depends="jar, prepare_webapp">
<mkdir dir="${linux.dir}"/>
<copy todir="${linux.dir}/server/lib">
<fileset dir="${server.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<copy file="${build.dir}/${fullname}-server.jar" tofile="${linux.dir}/server/lib/${fullname}-server.jar"/>
<copy todir="${linux.dir}/webapp">
<fileset dir="${built.webapp.dir}">
<include name="**"/>
</fileset>
</copy>
<mkdir dir="${linux.dir}/licenses"/>
<fixcrlf srcDir="${basedir}/licenses" destDir="${linux.dir}/licenses" eol="lf"/>
<fixcrlf srcDir="${basedir}" destDir="${linux.dir}" eol="lf">
<include name="refine"/>
<include name="refine.ini"/>
<include name="README.txt"/>
<include name="LICENSE.txt"/>
</fixcrlf>
<mkdir dir="${dist.dir}"/>
<tar longfile="gnu" compression="gzip" destfile="${dist.dir}/openrefine-linux-${version}.tar.gz">
<tarfileset dir="${linux.dir}/.." filemode="755">
<include name="${release.name}/refine"/>
</tarfileset>
<tarfileset dir="${linux.dir}/..">
<include name="${release.name}/**"/>
<exclude name="${release.name}/refine"/>
</tarfileset>
</tar>
</target>
This task creates a web directory, which is used in the previous task:
<target name="prepare_webapp" depends="jar_webapp, build">
<mkdir dir="${built.webapp.dir}" />
<copy todir="${built.webapp.dir}">
<fileset dir="${webapp.dir}">
<include name="**/*"/>
<exclude name="WEB-INF/classes/**"/>
<exclude name="WEB-INF/lib-src/**"/>
<exclude name="WEB-INF/lib/icu4j*.jar"/>
</fileset>
</copy>
and the Jar are prepared using another ANT target as following:
<target name="jar_webapp" depends="prepare_jar, build_webapp">
<jar destfile="${build.dir}/${fullname}.jar" basedir="${webapp.classes.dir}"/>
</target>
The result of running ant linux is an executable jar and a webapp directory, Is it possible to package the entire thing as one fat jar?
i'm generating a war with an Ant script but i noticed that the Ant's war size is almost double the size of the war created by Eclipse. And now i'm want to know if it's possible to reduce this size.
This is the war script:
<war destfile="${docflow4-web-home}/deploy/docflow.war" webxml="${docflow4-web-home}/web/WEB-INF/web.xml">
<classes dir="${docflow4-web-home}/web/WEB-INF/classes" />
<lib dir="${docflow4-web-home}/web/WEB-INF/lib"/>
<fileset dir="${docflow4-web-home}/web">
<include name="**/*.*"/>
</fileset>
</war>
My answer to my problem was to remove the "class" and the "lib" tag from the script, they were duplicating the files
<war destfile="${docflow4-web-home}/deploy/docflow.war" webxml="${docflow4-web-home}/web/WEB-INF/web.xml">
<fileset dir="${docflow4-web-home}/web">
<include name="**/*.*"/>
</fileset>
</war>
I am making a war of a project but i want that classes within that war be picked from specified location and also a jar file A.jar to be picked from custom location i am doing something like this ....
<target name="war" depends="a-jar">
<war destfile="D:/JBOSSHOME/project.war" webxml="${project-location}/web/WEB-INF/web.xml">
<fileset dir="${project-location}/web" >
<exclude name="${project-location}/web/WEB-INF/lib/A.jar"/>
<exclude name="${project-location}/web/WEB-INF/classes/**/*.class"/>
</fileset>
<lib dir="${jarsLocation}"></lib>
<classes dir="D:/JBOSSHOME/project/build/classes"/>
</war>
</target>
but in the resultant war i am getting 2 A.jar files and also classes are getting copied from ${project-location}/web/WEB-INF/classes instead of the classes dir that i have provided...
Any help would be much appreciated...
The exclude shouldn't include the root directory of your file set:
<fileset dir="${project-location}/web" >
<exclude name="WEB-INF/lib/A.jar"/>
<exclude name="WEB-INF/classes/**/*.class"/>
</fileset>
I'm starting with Ant. I created a build.xml to generate a WAR file of a Web Project and it worked OK.
Then, I made some change to exclude all *.jar from WEB-INF/lib Folder and also works OK.
Now I need to make the changes to exclude all JARs files, but leave some especial JARs in WEB-INF/lib Folder. This JARs are from other project created by me.
The idea es exclude all third parties JARs and only leave my own JARs inside WEB-INF/lib folder.
There is some way to do that?
All my Jars start with "fnet" so maybe I can use that to create some rule, but I don't know how to do that
This is my Build.xml:
<?xml version="1.0" ?>
<project name="warConLibs" default="build-war">
<target name="clean">
<delete file="c:/projweb.war"/>
<delete file="c:/projweb_sl.war"/>
</target>
<target name="build-war">
<war destfile="c:/projweb.war" webxml="./WebContent/WEB-INF/web.xml">
<fileset dir="./WebContent">
<include name="**/*.*"/>
</fileset>
<classes dir="./bin"/>
</war>
</target>
<target name="build-war-sin-libs">
<war destfile="c:/projweb_sl.war" webxml="./WebContent/WEB-INF/web.xml">
<fileset dir="./WebContent">
<include name="**/*.*"/>
<exclude name="**/*.jar"/>
</fileset>
<classes dir="./bin"/>
</war>
</target>
</project>
The correct way to exclude a jar file is given in the documentation. If anyone face same issue, they can refer to this link.
This example is taken from the documentation, here we are removing jdbc1.jar from lib
Assume the following structure in the project's base directory:
thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<fileset dir="src/jsp/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
<zipfileset dir="src/graphics/images/gifs"
prefix="images"/>
</war>
will consist of
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif
You may want to read again about the war Ant task: https://ant.apache.org/manual/Tasks/war.html
The correct syntax would be:
<war destfile="..." webxml="...">
<lib dir="WebContent/WEB-INF/lib">
<include name="fnet*.jar"/>
</lib>
<classes dir="bin"/>
</war>
Consider the following directory structure:
./source/com/mypackage/../A.java
./extensions/extension1/source/com/mypackage/../T.java
./extensions/extension2/source/com/mypackage/../U.java
...
./extensions/extensionN/source/com/mypackage/../Z.java
I want to produce a source jar with the following contents:
com/mypackage/../A.java
com/mypackage/../T.java
com/mypackage/../U.java
...
com/mypackage/../Z.java
I know I could use a fileset for each source directory.
But is there an easy solution using ANT without having to refer to all extensions explicitly?
How about flattening all the files to be included in the archive into a single directory structure, then archiving from there?
Use a regexpmapper to do the flatten during copy, something like this:
<delete dir="merged" />
<mkdir dir="merged" />
<copy todir="${basedir}/merged">
<fileset dir="${basedir}">
<include name="source/**"/>
<include name="extension*/**"/>
</fileset>
<regexpmapper from=".*source/(.*)" to="\1" />
</copy>
<jar destfile="mypackage.jar" filesonly="yes">
<fileset dir="merged">
<include name="**" />
</fileset>
</jar>