Hi,
Is it possible multithread calling proccesses in different jvms?
Taner Diler
[EMAIL PROTECTED] wrote:
sure ... the javascript implementation is written against Ants Java API :-)
Take the code, add some imports, type declarations ...
Quick translation - add imports etc...:
public class GetProductInfosTask extends Task {
public static final String splitChar = ":";
private String prefix; // add getter + setter
private File file; // add getter + setter
public void execute() {
if (prefix==null || file==null) {
throw new BuildException("prefix and file must be set");
}
// read the file
Reader rdr = new java.io.FileReader(file);
String content = FileUtils.readFully(rdr);
// split into metadata and content data
String lines[] = content.split( project.getProperty("line.separator") );
String header = lines[0];
String body = lines[1];
// get the metadata
String metaData[] = header.split(splitChar);
// get the content data and save as Ant properties
String contentData[] = body.split(splitChar);
for (int i=0; i<contentData.length; i++) {
getProject().setNewProperty(prefix + "." + metaData[i],
contentData[i]);
}
}
}
Jan
-----Ursprüngliche Nachricht-----
Von: Mikael Petterson (KI/EAB) [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 17. Oktober 2005 14:16
An: Ant Users List
Betreff: RE: make properites of data in file
Hi,
Since it is it is too much work to try the javascript
installation I will go for writing my own task.
Is it possible to create and set new properties within the new task?
cheers,
//mikael
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: den 17 oktober 2005 11:23
To: [email protected]
Subject: AW: make properites of data in file
The easiest way is defining the Ant properties and creating
the product.attributes.
But you can parse that file and assign properties ... using
your own task.
Quick hack (without any error handling). It parses the first
line to get the meta data and parses the second line for the
data. After that it stores the values.
Jan
<project>
<scriptdef name="getProductInfos" language="javascript">
<attribute name="prefix"/>
<attribute name="file"/>
<![CDATA[
// imports
importClass(Packages.org.apache.tools.ant.util.FileUtils);
// constants
splitChar = ":";
// arguments
prefix = attributes.get("prefix");
file = attributes.get("file");
// read the file
rdr = new java.io.FileReader(file);
content = FileUtils.readFully(rdr);
// split into metadata and content data
lines = content.split( project.getProperty("line.separator") );
header = lines[0];
body = lines[1];
// get the metadata
metaData = header.split(splitChar);
// get the content data and save as Ant properties
contentData = body.split(splitChar);
for (i=0; i<contentData.length; i++) {
project.setNewProperty(prefix + "." + metaData[i],
contentData[i]);
}
]]>
</scriptdef>
<getProductInfos prefix="prod" file="product.attributes"/>
<echoproperties prefix="prod"/>
</project>
-----Ursprüngliche Nachricht-----
Von: Mikael Petterson (KI/EAB) [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 17. Oktober 2005 10:38
An: [email protected]
Betreff: make properites of data in file
Hi,
I have the following properties in my build.xml:
<property name="target" value="xxx"/>
<property name="productnumber" value="yyy"/> <property
name="productrevision" value="zzz"/>
In a file called product.attribues I have the following information:
TARGET:PRODUCT_NUMBER:PRODUCT_REVISION
jvm:CXC1327714/22:R1A01
Is it possible to assign ant properties with the values in my files?
cheers,
//mikael
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For
additional
commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For
additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For
additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
__________ NOD32 1.1257 (20051016) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]