Issue with the space in the path specified for build.xml - ant

I have a build file, which has the following property in it.
<property name="schema.dir" value="src/main/resources/schema" />
This schema.dir is used to refer a wsdl file.The parent folder which contains the build.xml has a space in it like this folder name .
When I echoed the property it displayed only src/main/resources/schema.
But I can see from the ant logs that issue is with the space in the folder name.
Since the parent folder is having a space in it, I am not able to refer the wsdl.
Can somebody suggest a solution so that file can be accessed with out changing the folder name

Is it possible to provide directly full path to wsdl file?
Try to replace " " sign with "%20".
For test you can hardcode that and with ANT you can use the propertyregex task from Ant Contrib.
See Replacing characters in Ant property

Have you tried specifying your property as a location rather than a string so Ant knows it's dealing with a file path, you can also specify the path as relative to your base directory.
<property name="schema.dir" location="${basedir}/src/main/resources/schema"/>
Adding ${basedir} to the path may not be necessary after changing the property from a value to a location.

Related

How to refer to a changing path in Ant?

I have a dynamic path in my server inside which resides a file to be updated.
I am using Ant to make the file changes. But it does not seem to identify the path.
I have defined it in the following way:
<replaceregexp file="/tmp/automation/server/main*/main*/webserver/apache-tomcat.*/webapps/ROOT/WEB-INF/web.xml" match="https://api.test.com" replace="${test-Endpoint}" byline="true" />
Here 'main' is suffixed with the time-stamp and hence keep changing on every installation.

How to use directory paths stored in property file in ANT dirset or fileset?

I need to store some directory paths in property files for ant. So I have file that contains for example:
plugins.system=plugins\\whatever
plugins.content=plugins\\example
this.is.fine=plugins
this.also.does.not.work=plugins/example
The problem is, that dirset or fileset does not find the directory. I belive, that it's due escaping. When I set property directly in build.xml without double slashes it works fine. Is there any way how to "unescape" properties when I load them?
Thank you for answer.

How to get a filename without extension in ant

I know how to get the basename for a file with java's ANT build tool, but in this case I want to change the name of a file to include a build version number. Unfortunately the file's name gets set in another ant script (from the android system) which I am importing and I'm not able to set the property for that file or the imported script will complain that the property should not be set already. Thus, if i have a property holding MyApp-release.apk and I want to change the value to MyApp-release-1.10.apk how would I do this? I know I can put the 1.10 at the start of the filename with basename and that's probably what I will do, but I'd rather do it the other way.
Form http://ant.apache.org/manual/Tasks/basename.html:
Task to determine the basename of a specified file, optionally minus a
specified suffix.
<basename property="cmdname" file="D:/usr/local/foo.exe"
suffix=".exe"/>

Ant file path question

I have an Ant file that has this as a path. TRying to find out what it might mean.
deploy.dir = ${basedir}/..
First there is nowhere I can find where ${basedir} is being set. Is this some variable type being set in another file on the server or does ${basedir} mean the same directory the build file is in?
Then what does /.. mean after it.
Thanks
http://ant.apache.org/manual/using.html will explain that ${basedir} is, by default, where you are sitting when you type 'ant'.
.. means what it means on Windows and Linux in pathnames: one directory up.
The default value of ${basedir} is the directory containing your build xml file. This is even true if you say basedir="." in the project element. However, if on the command line, you say:
-Dbasedir=.
then it will be where you are sitting when executing ant. Since in most cases the build xml file will be where you are sitting, the difference shouldn't matter.

how to include directories inside JAR into the classpath at buildtime using ANT?

I have a JAR in my lib folder of the project and trying to get the directory structure that contains property files on the classpath when building using ANT. Any ideas how best to the get that structure on the classpath?
Thanks!
I'm assuming you want to load a properties file into your build using the property task.
If this is the case, there are a couple of options.
First you could use the url form of the task, using a jar url:
<property url="jar:file:lib/my_jar.jar!/path/to/myfile.properties" />
Alternatively you could use the resource form, and specify the jar as the classpath:
<property resource="/path/to/myfile.properties" classpath="lib/my_jar.jar"/>
If it's something else you want to do rather than load the properties, look into javaresource - many tasks are able to take a resource as input so you should be able to find a way to do what you want.

Resources