ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Mcewen-TM <>
Subject RE: newbie - creating a new build script based on a project file stor ed within JBuilder 4.5
Date Tue, 25 Mar 2003 16:57:42 GMT

How do I execute this script against a project file (*.jpx)?

-----Original Message-----
From: []
Sent: March 25, 2003 5:10 AM
Subject: AW: newbie - creating a new build script based on a project
file stor ed within JBuilder 4.5

If you have a only a couple of projects I would suggest writing them
So you can directly "refactor" them.

If you have many projects, write a (template-based) generator. I´m not sure
the format of the project files. If they are written in XML (*.jpx) you can
XSLT for generating the build.xml. If not you have to write something else.

If you have JPX and want to try XSLT you can start with this script I had
from newsgroup  borland.public.jbuilder.opentools some time ago - but I had
tried it, so I can´t give any additional information on that.

<?xml version='1.0' encoding="iso-8859-1"?>

<!-- JPX 2 Ant -->
up%3Dborland.public.jbuilder.opentools -->

<xsl:stylesheet version="1.0"
  extension-element-prefixes="exsl str"
  exclude-result-prefixes="exsl str"
  <xsl:output encoding="iso-8859-1" method="xml" indent="yes"/>
  <!-- Pass a string in for the project name, or replace with ="'foo'" -->
  <xsl:param name="projectName"/>

  <!-- The top-level jpr element is named "project" -->
  <xsl:template match="/project">
    <!-- Save some key properties for later use -->
    <xsl:variable name="libraries"
    <xsl:variable name="srcpath"
    <!-- TODO this is the DestPath with SourcePath removed -->
    <!-- xsl:variable name="destpath"
select="property[@name='DestPath']/@value"/ -->
    <xsl:variable name="destpath" select="'classes'"/>

      <!-- TODO get the projectName in here -->
      Autogenerated from a JBuilder 7 jpx project file

    <project name="{$projectName}" default="main" basedir="{$srcpath}">
      <!-- The javamake rather than javac task is used to avoid any
issues -->
      <!-- with the order in which the compilation tasks are listed. See -->
      <!-- -->
      <taskdef name="javamake"
      <property name="javamake.pdb.filename" value="jm.pdb"/>

      <!-- These properties are included for information only -->
      <target name="compile">
 <xsl:for-each select="property">
   <xsl:variable name="category" select="@category"/>
   <xsl:variable name="name" select="./@name"/>
   <xsl:variable name="value" select="./@value"/>
   <!-- TODO could concat the category to the name -->
   <property name="{$name}" value="{$value}"/>

 <mkdir dir="{$destpath}"/>

   <!-- Add all the reference libraries by extracting them from the -->
   <!-- Libraries property and then parsing the library XML files -->
       <pathelement location="."/>

       <!-- Step through each referenced library file -->
       <!-- This may not work for libraries defined inside JBuilder? -->
       <xsl:for-each select="str:tokenize($libraries, ';')">
  <!-- Use this version if this .xsl file is not in the same directory as
yout JBuilder .library files -->
  <!-- xsl:variable name="libfile"
select="concat('/the/path/to/my/JBuilder.libraries/', concat(.,
'.library'))"/ -->
  <xsl:variable name="libfile" select="concat(., '.library')"/>
  <!-- Add each jarfile in the library to the classpath -->
  <xsl:for-each select="document($libfile)/library/class/path">
    <!-- Trim the directory string as appropriate -->
    <xsl:variable name="jarfile1">
      <xsl:call-template name="replace-string">
        <xsl:with-param name="text" select="."/>
        <xsl:with-param name="from" select="concat('[', $srcpath)"/>
        <xsl:with-param name="to" select="''"/>
    <xsl:variable name="jarfile">
      <xsl:call-template name="replace-string">
        <xsl:with-param name="text" select="$jarfile1"/>
        <xsl:with-param name="from" select="']'"/>
        <xsl:with-param name="to" select="''"/>
    <pathelement location="{$jarfile}"/>


   <!-- Emit the names of the packages to be compiled -->
   <xsl:for-each select="node">
     <!-- TODO check that the type is indeed package -->
     <xsl:variable name="dirname" select="translate(./@name, '.', '/')"/>
     <src path="{$dirname}"/>

      <!-- Create a jarfile with the same name as the project -->
      <target name="create_jar" depends="compile">
 <jar destfile="classes/{$projectName}.jar" basedir="classes"

      <target name="main" depends="create_jar"/>


  <!-- reusable replace-string function from -->
  <!-- -->
  <xsl:template name="replace-string">
    <xsl:param name="text"/>
    <xsl:param name="from"/>
    <xsl:param name="to"/>

      <xsl:when test="contains($text, $from)">

 <xsl:variable name="before" select="substring-before($text, $from)"/>
 <xsl:variable name="after" select="substring-after($text, $from)"/>
 <xsl:variable name="prefix" select="concat($before, $to)"/>

 <xsl:value-of select="$before"/>
 <xsl:value-of select="$to"/>
 <xsl:call-template name="replace-string">
   <xsl:with-param name="text" select="$after"/>
   <xsl:with-param name="from" select="$from"/>
   <xsl:with-param name="to" select="$to"/>
 <xsl:value-of select="$text"/>


Jan Matèrne

> -----Ursprüngliche Nachricht-----
> Von: Chris Mcewen-TM []
> Gesendet am: Montag, 24. März 2003 18:30
> An: 'Ant Users List'
> Betreff: newbie - creating a new build script based on a project file
> stor ed within JBuilder 4.5
> Good Afternoon,
> What is the best way to collect the information from a project file on
> build/packaging an application and then recording this within 
> the build.xml
> script?
> Regards,
> Chris McEwen 
> Technical Specialist, Configuration Management -SR. 
> <> 
> TELUS Mobility 
> MOB. 416.684.3045 
> LAN.  416.279.3045 
> Quality is never an accident; it is always the result of high 
> intention,
> sincere effort, intelligent direction and skillful execution; 
> it represents
> the wise choice of many alternatives." 
> - William A. Foster

View raw message