ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: How to map JBuilder settings in Ant syntax
Date Mon, 04 Aug 2003 15:45:45 GMT
BTW, I am in contact with oopconsult. And during some tests I did a little
refactoring 
for that buildfile. But it requires the next version of xmltask.



<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="test" basedir="." default="main">

    <!-- import the ant libraries -->
    <taskdef name="xmltask"
classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>


    <!-- the jbuilder project file to analyze -->
    <property name="jbx.file" value="SZV.jpx"/>


    <target name="main" description="Create a classpath from JBuilder
project file">

        <!-- extract the used libraries from the JPX file and load that as
ant property -->
        <property name="tmp" value="tmp.xml"/>

        <xmltask source="${jbx.file}">
            <copy
path="/project/property[@category='sys'][@name='Libraries']"
buffer="usedlibs"/>
        </xmltask>
        <xmltask dest="${tmp}">
            <insert path="/" buffer="usedlibs"/>
        </xmltask>
        <xmlproperty file="${tmp}" />
        <delete file="${tmp}"/>

        <!-- analyze each library file -->
        <script language="javascript"> <![CDATA[
            list = project.getProperty("property(value)");
            tokenizer = new java.util.StringTokenizer(list, ";");

            while (tokenizer.hasMoreTokens()) {
                token = tokenizer.nextToken();
                file = new java.io.File(token + ".library");

                if (file.exists()) {
                    xmltaskCopyPath.setSource(file);
                    xmltaskCopyPath.perform();
                }
            }
        ]]> </script>

        <!-- store the result in a new xml file -->
        <xmltask dest="${tmp}">
            <!-- create a root document -->
            <insert path="/"><![CDATA[ <root/> ]]></insert>
            <!-- insert all collected paths -->
            <insert path="/root" buffer="libs.classpath"/>
            <!-- remove paths inside a jar file -->
            <remove path="//path[contains(text(), ']/')]"/>
        </xmltask>

        <!-- change to intermediate format -->
        <replace file="${tmp}">
            <replacefilter token="["/>
            <replacefilter token="]"/>
            <replacefilter token="&lt;path&gt;"/>
            <replacefilter token="&lt;/path&gt;" value=";"/>
            <replacefilter token="${line.separator}"/>
        </replace>

        <!-- read the input -->
        <xmlproperty file="${tmp}" prefix="jbpath"/>

        <delete file="${tmp}"/>

        <!-- create a <path> element -->
        <path id="path">
            <path path="${jbpath.root}"/>
        </path>

        <!-- use the created path -->
        <pathconvert property="path.win32" refid="path" targetos="windows"/>
        <echo/>
        <echo/>
        <echo>all included libraries are:  ${property(value)}</echo>
        <echo>path.win32: ${path.win32}</echo>
    </target>


    <target name="-forInternalUse">
        <xmltask id="xmltaskCopyPath">
            <copy path="/library/class/path" buffer="libs.classpath"
append="true"/>
        </xmltask>
    </target>

</project>



Jan


> -----Original Message-----
> From: Materne, Jan (RZF) 
> Sent: Monday, August 04, 2003 5:43 PM
> To: 'Ant Users List'
> Subject: RE: How to map JBuilder settings in Ant syntax
> 
> 
> > Hi,
> > 
> > Could you please kindly answer these two questions:
> > 
> > >         <xmlproperty file="${tmp}" />
> > >         <echo>all included libraries are:  
> ${property(value)}</echo>
> > > 
> > >         <!-- iterate over the used library files and extract 
> > > their classpath
> > > -->
> > >         <foreach target="processLibFile" param="libfile" 
> > > list="${property(value)}" delimiter=";"/>
> > 
> 
> 
> > What is the exact semantics of ${property(value)}?
> 
> 
> The JPX is in the format
> 
> <project>
>    <property>
>    ...
> </project>
> 
> 
> I read one <property> (with xmltask) into a buffer and writes 
> that out. Result:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <property category="sys" name="Libraries" value="Log4J 
> 1.2.8;JUnit 3.8.1"/>
> 
> 
> After reading that with <xmlproperty> I get the content of 
> the xml-attribute "value"
> via the name property(value).
> See the manual for xmlproperty and the "default loading" 
> example for more infos on that.
> 
> So ${property(value)} evaluates to "Log4J 1.2.8;JUnit 3.8.1".
> 
> 
> > Is the name of the property its value as well? If so, why the echo
> > displays (and are accordingly processed) only the properties 
> > defined in
> > the ${tmp} file and loaded by <xmlproperty/>, but not the 
> > others defined
> > in the build?
> 
> I don´t understand that question, but maybe I answered that above :-)
> 
> 
> 
> > And a second question: Do you happen to have as well some parsing
> > targets for the JBuilder group .jprg files, so that automatic 
> > extraction
> > of project names, followed by finding their libs is possible?
> 
> I haven´t found any group file on my computer. If the format 
> of that files
> is xml based, that should be possible. But you have to ensure 
> to use the
> right XPath´s.
> 
> 
> 
> Jan
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message