ok, Dominique - so I haven't missed a description on this subject.
Thanks for pointing me to <script/>

Rolf

Dominique Devienne wrote:

It's worth answering Rolf, but the answer is not good... There is currently
no task that does string manipulation on properties directly. Nevertheless,
you can easily do it yourself using a <script> and any of the
Java-implemented BSF-compatible languages out there: JavaScript, BeanShell,
Jacl, etc... The following below shows you how. This is no substitute for a
good task that would be doing property manipulation, but it does the job
relatively easily (once you have the proper JARs for <script>). --DD

P:\org_apache\antx>%ANT_HOME%\bin\ant -f property-manip-script.xml
Buildfile: property-manip-script.xml

test:
[echo] package name = com.myName.helloWorld
[echo] package path = com\myName\helloWorld
[echo] package class = helloWorld

BUILD SUCCESSFUL
Total time: 1 second
P:\org_apache\antx>type property-manip-script.xml
<?xml version="1.0"?>

<!-- ANT build file to test a specific feature or bug of ANT.
Dominique Devienne <[EMAIL PROTECTED]> November 2002
-->
<project name="property-manip" default="test">

<target name="test">
<property name="package" value="com.myName.helloWorld" />

<!-- Sets the file.size property with the length of the
file as named in the ant.file property -->
<script language="javascript"><![CDATA[
pkgName = self.getProject().getProperty("package");
pkgPath = pkgName.replace('.', java.io.File.separatorChar);
pkgClss = pkgName.substring(pkgName.lastIndexOf('.')+1);
self.getProject().setNewProperty("packagePath", pkgPath);
self.getProject().setNewProperty("packageClass", pkgClss);
]]></script>

<echo message="package name = ${package}" />
<echo message="package path = ${packagePath}" />
<echo message="package class = ${packageClass}" />
</target>

</project>

P:\org_apache\antx>

PS: Of course, getting the class name from the qualified
class name is a bit more involved than that to be generic.
-----Original Message-----
From: Rolf Schumacher [mailto:[EMAIL PROTECTED]] Sent: Monday, November 25, 2002 3:29 AM
To: Ant Users List
Subject: Re: String handling / Macro Processing

Seems that this question is not worth answering or there is no answer it.

Rolf

Rolf Schumacher wrote:


Compared with the not-so-good old make utility
I wonder how string handling is done in Ant.
Looked thru the manual and couldn't find it.

E.g.:
Setting properties like
<property name="package" value="com.myName.helloWorld"/>
<property name="packagePath" value="com/myName/helloWorld"/>
<property name="mainClass" value="HelloWorld"/>

are redundant, at least do me.
There has to be a way to base all three on common information.

What have I missed?

Rolf

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to