I have several external jar files in /lib directory
like
/lib
/lib/A.jar
/lib/B.jar
/lib/C.jar
and each JAR file has same named file in their jar file. the path is META-INF/license.txt
so if I use zipgroupfileset task with dir attibute like dir="/lib/" include *.jar in jar task
META-INF/license.txt file is duplicated
XML code is below
<jar jarfile="${dest}/merged_jar.jar">
<zipgroupfileset dir="${basedir}/lib" />
<include name="**/*.jar"/>
</zipgroupfileset>
</jar>
after this works, merged_jar.jar is created but in this file, /META-INF/license.txt is duplicated
I don't want to exclude license.txt file but want to move each file's license.txt file to another folder to gather and add suffix or prefix(eg. /license/license_A.txt) during merging task
thanks to your help.
Use the prefix attribute to put some prefix path on the destination directory.
<zipfileset dir="license" includes="*.txt" prefix="license/licence"/>
This will copy all text files inside license directory to the license/licence directory
Related
I have a directory called config under each of the subfolders of a parent directory lets x. I want copy all the config directories from each of the sub directories of x into a new directory. I want to do through Ant since i dont want to introduce a new technology into build script. Looks foreach and for does the operation at the file level but not the directory level. Any help is appreciated.
If I understood correctly, using copy task should solve your problem:
<copy todir="${dst.dir}">
<fileset dir="${src.dir}">
<include name="**/config/**"/>
</fileset>
</copy>
I have a java project (MyProject) with the below mentioned structure
src->package1(read as com.test.Atrribute)->File1.java,File2.java
src->package2(read as com.test.Objects)->obj1.java,obj2.java
src->directory(read as Webcontent.Objects)-> Folder1 -> application.properties file and some more files
Currently the build.xml creates a jar for the above project and copies the class files from package1 and package2.
However, my jar should also include the folder(Webcontent.Objects) with all the content's within it (i.e folders and files).
How can I do this in the build.xml ?
I have never created a build.xml before and pretty much new to all this.
Following is the jar task in the build.xml to include the class file's in the jar.
<target name="MyProject-jar" depends="compile"
description="Jar for the Project">
<jar destfile="${output.dir}/MyProject.jar" basedir="${output.dir}/">
<include name="com/test/Attribute/*.class"/>
<include name="com/test/Objects/*.class"/>
</jar>
</target>
Appreciate if anybody could help.Thanks.
You could add
<include name="Webcontent/Objects/**/*"/>
to your jar task
Note: The ** recursively considers directories under its parent
How can I use Ant to create zip containing all the files and nested directories inside some root directory, but exclude the top-level directory itself from the zip.
For example, say I have this file structure:
/foo
splat.js
/bar
wheee.css
I want the zip to contain splat, and wheee inside /bar, but I don't want all that to be contained inside a 'foo' directory. In other words, unzipping this into /honk should not create a foo directory; splat and bar should end up at the root of /honk.
I'm currently using this (extraneous details removed):
<zip destfile="${zipfile}" basedir="" includes="${distRoot}/**/*.*" />
What kind of fileset select can replace that 'includes' spec to achieve this?
It's not dynamic, but using the fullpath attribute allows you to define the path struture of the zip file. See ant documentation: http://ant.apache.org/manual/Types/zipfileset.html
<zip destfile="YourZipName.zip">
<zipfileset fullpath="splat.js" dir="foo" includes="splat.js"/>
<zipfileset fullpath="bar/wheee.css" dir="foo/bar" includes="wheee.css"/>
</zip>
This may get you want you want dynamically. It should pull in everything in the foo dir then zip it up. It's just a few extra steps.
<mkdir dir="DirToBeZipped"/>
<copy todir="DirToBeZipped">
<fileset dir="foo" includes="*"/>
</copy>
<zip destfile="YourZipName.zip" basedir="DirToBeZipped"/>
I am trying to get files from FTP, it always says no files retrieved,
here goes my code
<target name="ftp">
<ftp action="get"
server="${myftpserver}"
userid="${username}"
password="${password}"
remotedir="a"
binary="no"
verbose="yes"
passive="yes">
<fileset dir="abc" includes="CatalogReferenceAttribute.java"/>
</ftp>
</target>
Here i am trying to retrieve a .java file from FTP folder
a
to my local folder
abc
below is my ouput
Where i was wrong?
Did you put the dependency libraries into ANT's lib directory?
common-net.jar may not be enough... check this page:
http://ant.apache.org/manual/install.html#librarydependencies
I have the following ant build file which is supposed to package all class files in the bin directory into a jarfile:
<?xml version="1.0" encoding="utf-8"?>
<project name="RemoteJunitXletServer.makejar" default="makejar" basedir=".">
<target name="makejar" description="Build a jarfile based on the JunitServer project">
<jar jarfile="JunitServer.jar" includes="**.class" basedir="bin" />
</target>
</project>
Unfortunately, including "**.class" only goes two directories deep, and does not copy any files that are deeper than two directories inside of the bin folder. Do these directories HAVE to be explicitly declared? Or is there a way to tell Ant to just copy all class files inside of the bin folder regardless of location while preserving the folder structure?
Try includes="**/**.class" ...