ant-contrib

How can I use something like an array or list in Ant?

泄露秘密 提交于 2020-01-22 15:12:10
问题 I have a list of strings (e.g. "piyush,kumar") in an Ant script for which I want to assign piyush to var1 like <var name="var1" value="piyush"/> and kumar to var2 like <var name="var2" value="kumar"/> . So far, I'm using a buildfile like the following: <?xml version="1.0"?> <project name="cutter" default="cutter"> <target name="cutter"> <for list="piyush,kumar" param="letter"> <sequential> <echo>var1 @{letter}</echo> </sequential> </for> </target> </project> I'm not sure how to progress this

Check multiple file exists or not using ANT

有些话、适合烂在心里 提交于 2020-01-15 06:59:26
问题 I am using ANT to check count for set of files in two jars. I am not able to check whether the files of same pattern exists or not. for e.g. I have 2 files like /host/user/dir1/ABC1.txt and /host/user/dir1/ABC2.txt. now i want to check whether the file of pattern "/host/user/dir1/ABC*" present or not ?? I can check individual file /host/user/dir1/ABC1.txt, using available tag, but not able to check the files for specific pattern. thanks in advance. For individual file, following works fine:

Change values of list in ANT

拟墨画扇 提交于 2020-01-05 05:55:52
问题 I need to change the values of an ANT-script list in real time. This is the situation; I have these properties: x.y.6.1=something1 x.y.6.2=something2 x.y.6.3=something3 list=6.1,6.2 I want the list to become list=something1;something2 This is the gist of the code; <target name="target1"> <foreach list="${list}" target="target2" param="var" delimiter="," /> </target> <target name="target2"> <propertycopy name="var" from="x.y.${var}" silent="true"/> </target> Now, the propertycopy part works,

ant iterate over files

有些话、适合烂在心里 提交于 2020-01-02 15:18:18
问题 I want to iterate over a list of jars (undefined number) and add them all to the jar file. To add them I plan to use something like this: <jar id="files" jarfile="all.jar"> <zipfileset src="first.jar" includes="**/*.java **/*.class"/> <zipfileset src="second.jar" includes="**/*.java **/*.class"/> </jar> but how do I iterate over them? I don't have ant-contrib Thanks! 回答1: Just use zipgroupfileset with the Ant Zip task <zip destfile="out.jar"> <zipgroupfileset dir="lib" includes="*.jar"/> <

Calling foreach in maven-antrun-plugin

被刻印的时光 ゝ 提交于 2020-01-01 11:36:17
问题 I'm trying to set up maven to execute the LESS CSS preprocessor on a directory in my web project. The basic flow is: Maven calls maven-antrun-plugin. Ant-contrib <foreach/> loops through a directory and finds all the .less files and calls a target. The target executes Rhino, which executes LESS which converts the file. To do this, I have the following XML: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions>

Updating xml elements using ant

ⅰ亾dé卋堺 提交于 2019-12-25 03:16:24
问题 I have an XSL file, which acts as a configuration file for my application. In fact it is an XML file, which has the elements wrapped around it. This file is called Config.xsl: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.example.org/Config"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" standalone="yes" /> <xsl:template match="/"> <Config> <Test>somevalue</Test> <Test1

In Ant, how can I test if a property ends with a given value?

风格不统一 提交于 2019-12-24 02:52:23
问题 In Ant, how can I test if a property ends with a given value? For example <property name="destdir" value="D:\FeiLong Soft\Essential\Development\repository\org\springframework\spring-beans" /> how can I test if ${destdir} ends with "spring-beans" ? additional: In my ant-contrib-1.0b3.jar, without 'endswith' task~~ 回答1: As Matteo, Ant-Contrib contains a lot of nice stuff, and I use it heavily. However, in this case can simply use the <basename> task: <basename property="basedir.name" file="$

How can I use an Ant foreach iteration with values from a file?

回眸只為那壹抹淺笑 提交于 2019-12-23 13:26:10
问题 In our Ant build environment, I have to do the same task for a number of items. The AntContrib foreach task is useful for that. However, the list is in a parameter, where I actually have the list in a file. How can I iterate over items in a file in an foreach-like way in Ant? Something like (pseudo-code): <foreach target="compile-module" listFromFile="$fileWithModules"/> I'm happy to write a custom Task, and welcome any suggestion on possible solutions. 回答1: I tried to load the file into a

Iterating over all filenames in a directory in Ant

徘徊边缘 提交于 2019-12-21 21:44:23
问题 I need to iterate over all files in a directory. But I need just the name of each file, not absolute paths. Here's my attempt using ant-contrib: <target name="store"> <for param="file"> <path> <fileset dir="." includes="*.xqm"/> </path> <sequential> <basename file="@{file}" property="name" /> <echo message="@{file}, ${name}"/> </sequential> </for> </target> The problem is that ${name} expression gets evaluated only once. Is there another approach to this problem? 回答1: From ant manual basename

How to emulate if-elseif-else in Ant without using Ant-contrib?

☆樱花仙子☆ 提交于 2019-12-21 21:44:05
问题 I need an if-elseif-else conditional statement in Ant. I do not want to use Ant-contrib. I tried the solution here <target name="condition.check"> <input message="Please enter something: " addproperty="somethingProp"/> <condition property="allIsWellBool"> <not> <equals arg1="${somethingProp}" arg2="" trim="true"/> </not> </condition> </target> <target name="if" depends="condition.check, else" if="allIsWellBool"> <echo message="if condition executes here"/> </target> <target name="else"