ant,filepath,unzip,unjar , How to use ant unjar file from a jar into a specific directory without path from jar

How to use ant unjar file from a jar into a specific directory without path from jar


Tag: ant,filepath,unzip,unjar

I want to copy files from within a jar to a specific directory without preserving the path in the jar.

I can use unjar to find just the files I want from the jar OK:

<unjar dest="some_dest_path" overwrite="true" src="somejar.jar">
        <include name="somepath_in_jar/somefile.ext" />

but the somefile gets extracted to:


when I want the file to get extracted to:


ie without dragging the path it was packaged with along with the process

How can I extract a file from a jar without having the extracted file include the path it was packaged with?


Try to use a mapper

<unjar dest="some_dest_path" overwrite="true" src="somejar.jar">
    <include name="somepath_in_jar/somefile.ext" />
  <mapper type="flatten"/>

see ant mapper


How do you determine within Ant whether verbose is enabled?

Within an ant build.xml, I want to influence a child process's verbose flag based on whether ant itself was run with verbose enabled. Is there a variable set to determine this? Or otherwise, can I parse the raw Ant command line somehow to check whether -v is passed?

Using ant.replace in gradle

I want to use ant's replace task to replace token in one of the files like this: version.txt version.number=${versionNumber} build.gradle task writeVersion { ant.replace { file 'version.txt' token 'versionNumber' value '1.0.0' } } but it is giving me following error :- A problem occurred evaluating root project '1.01-Exercise-RunYourFirstTask'. > replace...

Running an Ant target under certain conditions

I have the following Ant targets in my project.xml: <target name=""> </target> <target name="deploy1"> <antcall target="deploy2"/> </target> <target name="deploy2"> <antcall target=""/> </target> <target name=""> <antcall target="deploy1"/> </target> My intent is to be able to exclude the target when running I am not very familiar with ANT and I...

Create build.xml file independant of the location of the libraries on a computer

In order to generate a war file , I've created a build.xml file via eclipse. The build.xml is as shown below: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- WARNING: Eclipse auto-generated file. Any modifications will be overwritten. To include a user specific buildfile here, simply create one in the same directory with...

Triggering a Git fetch, reset using Jenkins

I am in need of an urgent help and any guidance from anyone out there would be really appreciated. Please find below the use-case that I am trying to accomplish here: I have a Java package which is checked in Git (and and I have a Ant job to...

how to get Full Path if image to send to server by MultiPart in Android

In My App, user can take Picture from Camera Or Select from Gallery And Crop It to send to server. So there is No Problem., Problem is when user select picture from Gallery URI path from camera cropped : /mnt/sdcard/avatar_1434958340804.jpg URI path from Storage cropped : /external/images/media/19 Error: IOException :...

ANT: Build Failed: failed to create task or type testng:

<project name="name" default="test" basedir="."> <!-- Define <testng> task --> <taskdef resource="testngtasks"> <classpath> <pathelement location="/lib/testng-6.8.5.jar"/> </classpath> </taskdef> <property name="testdir" location="test" /> <property name="srcdir" location="src" /> <property name="libdir" location="lib" /> <property name="full-compile" value="true" /> <path id="classpath.base"/> <path id="classpath.test"> <fileset...

prompt user for input in ant and take action based on input

I would like to be able to prompt an user for input during the execution of ant. Pseudo code for what I am trying to do is: echo "Enter y or n:" read yorn if [ $yorn = 'y' ] then echo "$yorn" > /tmp/junk fi Here is what I...

Creating an ANT macro to combine two properties file

Suppose that I have two properties file (say and which contains key value pair. How to write ANT task to create a new properties file (say which contains the key value pair of both these files(a and b). Please help.

Compile with ant classpath issue with JUnit

I am having a compile issue with ant, junit.jar cannot be found here is my build file: <path id="lib"> <fileset dir="library"> <include name="*.jar" /> </fileset> </path> <target name="test"> <mkdir dir="tmp/reports" /> <mkdir dir="tmp/build" /> <javac srcdir="test" destdir="tmp/build" includeantruntime="false"> <classpath refid="lib" /> </javac> <echo message="Build done" /> <junit fork="yes" haltonfailure="yes"> <batchtest...

SQL data export

I have the below script to execute SQL file. <target name="dataExcel" > <sql classpath="/ojdbc14.jar" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:orcl" userid="scott"password="tiger" src="/generateData.sql" /> </target> Is it possible to spool data to Excel file? I need to automate SQL data export to Excel using script. Edit 1 <project name="xlsx task"> <taskdef name="xlsx" classname="" classpath="PATH/TO/ant4x.jar"/> <target...

Unexpected top level exception: bad class file magic, in Android

I am trying to compile my android program via command line, using ANT. And the code compiles fine. But when the target -dex is executed, I get the following error: [dex] input: /Users/aditya/Desktop/workspace/Java/Play/bin/classes [dex] input: /Library/Java/Android/tools/support/annotations.jar [dex] Using Pre-Dexed annotations-5bd0afe28d834ceff67df1063f0f145b.jar <- /Library/Java/Android/tools/support/annotations.jar [dex] Converting compiled files and external libraries into...

How to run java files that I have mentioned in my testng xml?

I have a testng.xml file and a build.xml file. I want to know how can we write code in build.xml file which can run all java files that I have mentioned in my testng.xml file?

how do you run ant

I am trying to build a jar file using ant like this: CLASSPATH=/files/hadoop-core-1.0.4.jar CFLAGS=-m64 CXXFLAGS=-m64 ant compile-native tar I keep getting this error: Error: Could not find or load main class ant --execdebug show this: exec "/usr/java/jdk1.8.0_25/bin/java" -classpath "/usr/bin/build-classpath: error: JAVAVER_LIBDIR /usr/share/java-1.8.0 does not exist or is not a...

Code Coverage for Android Library Project while using Robolectric

I have an android library project. We are using Robolectric to run the unit tests. Unit Tests are working fine from the IDE as well as Ant build.xml file. I am able to get the code coverage using the eclEmma plugin in Eclipse. But I am facing problems while getting...

Ant debug and ant release failed

I am trying to generate apk on command line using ant. I am able to use ant clean but for ant debug and ant release command I am getting following error. BUILD FAILED C:\Android\sdk\tools\ant\build.xml:649: The following error occurred while executing this line: C:\Android\sdk\tools\ant\build.xml:694: Execute failed: Cannot run program "C:\Workspace\SampleApp\${aapt}":...

how to use excludesfile/includesfile in ant zip task

I need to specify a list of specific files to exclud but when I try something like excludesfile="file1, file2" I get an error executing the task saying: C:\Users.....\Desktop\testProject\ Excludesfile C:\Users......\Desktop\testProject\file1, file2 not found. Here is my code: <target name="jar" depends="common.jar"> <zip destfile="${}/some-jar.jar" basedir="${base.dir}" includes="src/**,gradle/**" excludesfile="file1,file2"> </zip> </target> ...

Datapusher issue (409 Client error) during CKAN setup : maybe a filepath issue?

I'm writting here about a CKAN installation problem. I have already a functional datastore (I've got answer from the API test) and functional filestore, my config file is OK (all options sets, like site.url , etc...). I can post files on the CKAN site, I can get it, SOLR is...

ant LinkageError without includeantruntime

How can I prevent the AntClassLoader and URLClassLoader from causing a linkage error? Due to an older project, junit and hamcrest.core are put into ANT_HOME and our build uses includeantruntime=true in order to run unit tests. I am now working on a project built with ant where I don't want...

how do you download files via ant though proxy [duplicate]

This question already has an answer here: Ant GET task and proxy 1 answer I am using ant which uses an build.xml file. This is the command: java version : 1.8.0 ant version: 1.7.1 CLASSPATH=/app/hbase-0.94.27/lib/hadoop-core-1.0.4.jar CFLAGS=-m64 CXXFLAGS=-m64 ant compile-native tar it hangs here: Buildfile: build.xml ivy-download: [get] Getting:

PDF file path is incorrect [duplicate]

This question already has an answer here: Android - Access file from assets \ PDF display 4 answers I want to open a PDF file in my application but something goes wrong everytime. Yeah , I watched many topics about it, however none of them helped me. Here are...

javadoc Illegal package name

I am trying to build this project . Built with: ant -buildfile build.xml However I get the following error: [javadoc] javadoc: error - Illegal package name: "/home/bionix/Desktop/gs-collections/collections-api/target/generated-sources/java/com/gs/collections/api/block/function/primitive/" [javadoc] javadoc: error - Illegal package name:...

Any way to make Groovydoc remove (selected) package qualifiers as per Javadoc's 'noqualifier' option?

I've just started generating Groovydoc for a library I'm working on. However, the preponderance of java.lang and java.util and other common package prefixes in the method signatures is obscuring the real intent of the methods. I'd like to be able to generate the Groovydoc without these. As in the (made...

Getting application folder path on MeteorJS?

In Meteor I've been looking for a way to get the home folder of the running Meteor application in Server. For example, if my .meteor folder is in C:/Users/Me/Repos/MyWebsite/.meteor, is there a way to get the path C:/Users/Me/Repos/MyWebsite/, or where ever the app is currently running at? The reason I...

Moving a command to the background halfway through execution in Bash

I'm working on a bash script that starts multiple other shell scripts some of which terminate on their own, some of which run indefinitely until terminated. I'm looking for a way to move the execution of one of these subprocesses to the background only after a certain line of output...

Ant places stacktraces in standard output

I am using Ant, together with tasks I have created myself. When those custom ant tasks fail, their output is redirected to stdout. I want them to be redirected to stderr. A simple full generic Ant example is : <project name="test" default="init" basedir="."> <!-- Initialise project parameters --> <target name="init">...

Only writing the relative filename from the full file name c#

So I do not know if this is possible, but below I have a file path in a variable path: string path = @"c:\users\povermyer\documents\visual studio 2013\Projects\DanProject\PNRS \PNRS.log"; What I want to do is I want to have the console window write just the last part in the path. For example,...

Saved photos don't appear on device after update

On my iPhone app, I'm saving pictures associated with an event via this code: [pngData writeToFile:filePath atomically:YES]; //Write the file self.thisTransaction.picPath = filePath; Later I retrieve and display the photo with this code: UIImage * image = [UIImage imageWithContentsOfFile:thisTransaction.picPath]; Works great on my iPad (I don't have an iPhone). However,...

How to have ImageIO.write create a folder path as needed

I have the following code: String nameAndPath = "C:\\example\\folder\\filename.png"; BufferedImage image = addInfoToScreenshot(); //this method works fine and returns a BufferedImage ImageIO.write(image, "png", new File(nameAndPath)); Now, the path C:\example\folder\ does NOT exist, so I get an exception thrown with message: (The system cannot find the path specified) How can I...

Via Windows command line, how can we compile a Netbeans C/C++ application?

Let's take this simple C/C++ application Netbeans project folder. In Netbeans IDE, we just hit build button on the toolbar to build the application. I want to do that automatically via Windows command line, how can I do that? I did google, and found some related posts though not very...

Cordova build fails, can't find ${appt}

The command cordova build android fails with the following output BUILD FAILED F:\Programs\SDK\tools\ant\build.xml:597: The following error occurred while executing this line: F:\Programs\SDK\tools\ant\build.xml:649: The following error occurred while executing this line: F:\Programs\SDK\tools\ant\build.xml:694: Execute failed: Cannot run program "F:\code\asistenciaBT\platforms\android\CordovaLib\${aapt}" (in directory "F:\code\asistenciaBT\platforms\android\CordovaLib"): CreateProcess error=2, El sistema no puede...

XSLT filePath with document as variable

I try to use a variable in the filePath, but it isn't working: BodyPart filePath="C:\\FileOutEmail\\($vpDocNr).xml" content-type="" content-id="" content-disposition="" multipart-type="" I also tried with the whole path in a variable without results: BodyPart filePath='$bestand' content-type="" content-id="" content-disposition="" multipart-type="" Is this possible, what is the right syntax?...

ant build file terminating tag error

I am trying to run an ant build file for a java jar. For some reason, whenever I try to run ant run, it comes back and says, "Element of type target must be terminated by the matching </target> tag" This seems strange because I see that I do have...

Any way to write Ant Script to enter multiple input from directory and run them in parallel

I want to write a script which takes input from directory all the adapters and build the adapters in parallel. I just want a generic script which works with every mobile first code to build adapters. <target name="build-adapter"> <dirset id="check" dir="/Users/admin/Documents/workspace1/MyTime/adapters" includes="*"/> <property name="test" refid="check"/> <echo>${test}</echo> <parallel> <adapter-builder folder="/Users/admin/Documents/workspace1/MyTime/adapters/${test}"...

Cannot compile Java adapter using adapter-builder task (ANT) in MFP v7

We have been using the adapter-builder task ( to compile our MFP adapters for several weeks. We just started now adopting Java adapters in our MFP apps but we cannot compile them with the adapter-builder task. Looking at the compilation errors in the output, it seems the adapter-builder task does...

Ant build should wait for a child process to complete

Hi I am new to ant and I have written a target which spawns a child process . Here I want the ant to wait until the child process is completed. How can I do that ? Can anyone please help me <target name = "buildtarget" depends="load-props"> <property name="targetname" value="build"/>...

Copy subdirectories if they contain a specific file in Ant

Really new to Ant and I have been trying to figure that out but could not... Let say I have a structure like that : Root |-data |-dir1 |-include.xml |-subdir1 |-file1 |-file2 |-include.xml |-subdir2 |--dir2 |-file1 |-include.xml |--dir3 |--dir4 |-file1 |-include.xml |--dir5 |-build.xml |-other files I'd like to copy the...

Maven with Ant : exec Command line

I want to retrieve the serial number of my computer by running ant task in pom.xml. <profile> <id>generate-license</id> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>compile</phase> <configuration> <tasks> <exec executable="wmic bios get serialnumber" resultproperty="serialNumber" failonerror="false" /> <echo message="Serial number: ${serialNumber}" /> </tasks>...

Netbeans build.xml to execute when using Ant

I'm relatively new to using build files and Ant to compile and execute from a command line so i wanted to know how it would be possible to modify the build-impl.xml file auto generated from netbeans so that after it compiles it also executes the program. Currently when i type...

How to test for operating system in ant build

It seems the only reliably provided property by ant is the "" property. However this name has variants ;lie "Windows 8" "Windows 7" etc But for my purposes both are "Windows" - Is there a way to conditionally set a property based on a partial string match of another property...

Recursively expand and search pattern of specific subdirectories

I'm looking for an option to search specific subdirectories in python. For instance a directory structure like this: some_files/ common/ 2009/ 2010/ 2011/ ... I only want to search for in the subdirectories that start with a 2, so that it must be something like 'some_files/2*'. I think it must...

How to filter file paths then use the resulting paths

I trying to get a list of mp3 from a directory. let dir_paths = fs::read_dir(&Path::new("some_directory")).unwrap(); let paths = dir_paths.filter(|x| match x.unwrap().path().extension() { None => true, Some(ext) => ext == "mp3" }); The Error Message src/ 27:49 error: cannot move out of borrowed content src/ let paths = dir_paths.filter(|ref x| match...

Java - Check properties file at compile time

I need some advices from you today. I am working on a project which uses a huge constants holding class. There are lots of public static final String CONST_NAME = "const_value"; I am getting those using MyConstClass.CONST_NAME but now I need to externalise them in order to configure the project....

Python: too many joins()?

I'm not sure why I'm getting this error, I'm using str.join() and os.path.join() at different points in the script, is that the cause? Using os.path.join: from os.path import getsize, dirname, join class Wav: src_path = "No path" dest_path = destination old_name = "name.wav" new_name = "" def __init__(self, path): self.src_path...

MobileFirst Platform native iOS app building have error while building .wlapp

I am working on MobileFirst Platform version7 using ant script to build the project .war, .wlapp, .adapter. Everything was working fine while our project was a hybrid one. Now the project is migrated to native-iOS in. I am using following code to build .wlapp. <target name="build-wlapp"> <app-builder worklightServerHost="localhost:10080" applicationFolder="//Users/admin/Documents/workspace/NewProj/apps/Try" environments="iOSnative"...

What does slash dot refer to in a file path?

I'm trying to install a grunt template on my computer but I'm having issues. I realized that perhaps something different is happening because of the path given by the Grunt docs, which is %USERPROFILE%\.grunt-init\ What does that . mean before grunt-init? I've tried to do the whole import manually but...

Simple way to choose a file

Is there some simple way to choose a file path in Java? I've been searching around, and JFileChooser keeps coming up, but that's already too excessive for what I want now, as it seems to require making a whole GUI just for that. I'll do it if need be, but...

what is the process of the running the java files that are present in testng xml using ANT

I want to know the process of running the java files that are mentioned in testng.xml using ANT. Do we have to compile those java files first and then run it? Or the testng ANT task takes care of compiling and running? I have gone through the testng ANT task...

MobileFirst app build - failed creating temporary directory to build adapter

I have working command line build setup for my MobileFirst application. However today when I ran a build, I got following error: BUILD FAILED C:\...\build.xml:29: Failed creating temporary directory to build adapter What might be the cause of this error? I'm running the build via ant: ant build Relevant part...

JUnit 4.11 not showing parameter value but index

We have a project with a number of JUnit testclasses that has been using the Eclipse internal JUnit implementation until recently. In order to run our tests from the ant build script we have changed the build path for our project to use an external junit-4.11.jar and the required hamcrest-core...