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 Fri, 25 Jul 2003 10:05:40 GMT
Interesting thing :-)

I created a buildfile which will do that work.
Required: 
- xmltask libarary from http://www.oopsconsultancy.com/software/xmltask.html
- ant-contrib library from
http://sourceforge.net/project/showfiles.php?group_id=36177

Extract:
- extract the information which libarary are used from the jbuilder project
file (JPX)
- iterate over all used library files (*.library)
  !!! the library file must have the <nameInJPX>.library filename !!!
- extract the class path information and collect that
- transform that collected infos to a semicolon separated list
- create a <path> with that

But there is still a problem: JBuilder allows to define a path INSIDE an
archive. E.g.
    [lib/junit.zip]/classes
This is not handled by this script. But maybe there will be no problems with
that...




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


    <!-- import the ant libraries -->
    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
    <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}"/>

        <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=";"/>

        <!-- store the result in a new xml file -->
        <xmltask dest="${tmp}">
            <insert path="/"><![CDATA[ <root/> ]]></insert>
            <insert path="/root" buffer="libs.classpath"/>
        </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 -->
        <loadfile property="file" srcFile="${tmp}"/>

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

        <!-- extract the values to a valid path -->
        <propertyregex property="pathvalue" input="${file}"
regexp="&lt;root&gt;(.*)&lt;/root&gt;" select="\1"/>

        <!-- create a <path> element -->
        <path id="path">
            <path path="${pathvalue}"/>
        </path>

        <!-- use the created path -->
        <pathconvert property="path.win32" refid="path" targetos="windows"/>
        <echo>path.win32: ${path.win32}</echo>
    </target>


    <!-- Extract the classpath from one library file -->
    <target name="processLibFile" if="libfile">
        <xmltask source="${libfile}.library">
            <copy path="/library/class/path" buffer="libs.classpath"
append="true"/>
        </xmltask>
    </target>

</project>



With short tests on my computer that works ...


Jan



> -----Original Message-----
> From: Gian Franco Casula [mailto:Gian.Franco.Casula@topficie.nl]
> Sent: Thursday, July 24, 2003 1:44 PM
> To: user@ant.apache.org
> Subject: How to map JBuilder settings in Ant syntax
> 
> 
> Hello,
> 
> Does anyone know how to translate the entries in
> 'Required libraries' in the JBuilder 'Project properties'
> in my build.xml?
> 
> Example: in JBuilder I have the 'Required library' called 'mail'
> (which consists of two jar files) it's content is used by JBuilder
> during compilation. Since I haven't 'included' this library in my
> build.xml a compilation error occurs, which I only manage to
> skip by deleting the class referencing the 'mail' files.
> 
> Thank you,
> 
> Gian Franco
> 

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