ant

How to solve “Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.” while running “ant test”?

烈酒焚心 提交于 2019-12-18 14:05:31
问题 I have a target named test and I want to do some tests. I put here the important parts in build.xml . It includes: <property name='lib.dir' value='lib' /> <path id='classpath'> <fileset dir="${lib.dir}" includes="**/*.jar" /> </path> And I have put the junit.jar and ant-junit.jar (is it a must?) in the lib directory. However, if I run ant test . The output error is: test: BUILD FAILED /home/xiaohan/EclipseWorkSpace/AntTest/build.xml:82: Problem: failed to create task or type junit Cause: the

How to check if a property has value in Ant

狂风中的少年 提交于 2019-12-18 13:55:23
问题 I have an Ant XML file which I use for build. I have 3 properties. I want to break the build if these properties does not contain any value. Also I want to break the build if the value is empty. How can I do this in Ant? I a using Ant and not Ant-contrib. 回答1: You can use conditions using the <fail> task: <fail message="Property "foo" needs to be set to a value"> <condition> <or> <equals arg1="${foo}" arg2=""/> <not> <isset property="foo"/> </not> </or> </condition> This is equivalent to

eclipse: change jre that is used to run ant

浪子不回头ぞ 提交于 2019-12-18 13:05:08
问题 How do I change the JRE (for example, to go from a from 64bit to 32bit version) that is used to run ant from inside eclipse? 回答1: I am not sure that you can do that in a global way. However, it is possible to choose your JRE when you run Ant on a specific project: Go in the Properties of your project, then select Builders and Ant Builder . In the properties for this builder, go in the JRE tab, and choose an Separate JRE . Another solution is to specify the JRE used directly in your build.xml

Updating files inside an existing WAR file

南楼画角 提交于 2019-12-18 12:55:32
问题 I am trying to update files inside an existing WAR file using the ANT WAR task. I need to replace a set of xml files in a folder in WAR with new ones from my HDD. <war destfile="myApp.war" update="true" > <zipfileset dir="<PathToStubsFolderOnHDD>" includes="**/*.xml" prefix="<PathToStubsFolderInWAR>"/> </war> This works fine if the original WAR does not have xmls with same name. However if the original WAR contains xmls with same name; WAR task does not update them with files from HDD. The

Ant scp task not working, even with jsch on ant/lib

試著忘記壹切 提交于 2019-12-18 12:52:21
问题 I need to copy a war file via scp. I have added the jsch-0.1.42.jar to $ANT_HOME/lib but I'm still getting this error: Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.Scp was not found. This looks like one of Ant's optional components. This is the result of running ant -diagnostics just in case: http://gist.github.com/320859 回答1: This looks like your problem, from the top of the diagnostics: optional tasks : not available Your $ANT_HOME/lib directory is missing ant-jsch.jar, which

ant machine name property

旧城冷巷雨未停 提交于 2019-12-18 12:46:12
问题 Is there a way to get the machine name as ant property, for both Linux and Windows OS. 回答1: On Windows the hostname is in the environment variable "COMPUTERNAME", on Linux the environment variable is "HOSTNAME". Because ant properties are immutable something like the following should work: <property environment="env"/> <property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/> <echo message="hostname = ${env.HOSTNAME}"/> i.e. import the environment as properties prefixed with env. Then set

How to install ant contrib under Windows?

对着背影说爱祢 提交于 2019-12-18 12:32:47
问题 Prelude: Ant-Contrib provides a very well explained wiki page for installation and launch ([http://ant-contrib.sourceforge.net/#install][1]). Indeed, only two steps is necessary: - build ant-contrib-0.3.jar (by ant dist...), - move the built .jar into the lib directory of your Ant installation, Use it by writing in your own project: <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> My problem: I succeeded to build the .jar (build successful is written). But I cannot find any

Ant - copy only file not directory

岁酱吖の 提交于 2019-12-18 12:27:52
问题 I need to copy all files in a folder except directory in that folder using Ant script. Im using below script to do that. <copy todir="targetsir"> <fileset dir="srcdir"> <include name="**/*.*"/> </fileset> </copy> But it copies all files and directory in that folder. how to restrict/filter directory in that folder? thanks, 回答1: Do you mean that srcdir conatins sub-directories, and you you don't want to copy them, you just want to copy the files one level beneath srcdir ? <copy todir="targetsir

Create RPM package from ANT script under Windows

若如初见. 提交于 2019-12-18 12:27:07
问题 I need to create an RPM package from an ANT script that runs on a Windows computer. This package must contain the result classes from the build plus some other, additional resources. I guess there should be some program somewhere that can be invoked from the command line to create this package. The reason why I want to do this under windows is that we have a script that builds installers for several different platforms, and everything is already configured for windows so I want to avoid the

Apache ant does not recognize 'for' task/macro, although I have added ant-contrib via taskdef

允我心安 提交于 2019-12-18 12:18:12
问题 I am getting following while doing ant build: Build\build.xml:247: Problem: failed to create task or type for Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any <presetdef>/<macrodef> declarations have taken place. build.xml line 247 is <for param="file"> Already defined <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> , it didn't work. Then I specifically added following but it is still