ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Mcewen-TM <Chris.Mce...@telus.com>
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
Jan,

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

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: March 25, 2003 5:10 AM
To: user@ant.apache.org
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
manually.
So you can directly "refactor" them.

If you have many projects, write a (template-based) generator. I´m not sure
about
the format of the project files. If they are written in XML (*.jpx) you can
use
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
downloaded
from newsgroup  borland.public.jbuilder.opentools some time ago - but I had
never 
tried it, so I can´t give any additional information on that.




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

<!-- JPX 2 Ant -->
<!--
http://groups.google.com/groups?dq=&hl=de&lr=&ie=UTF-8&safe=off&threadm=3D2B
22DF.6080802%40valid.email&prev=/groups%3Fhl%3Dde%26lr%3D%26safe%3Doff%26gro
up%3Dborland.public.jbuilder.opentools -->

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common"
  xmlns:str="http://exslt.org/strings"
  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"
select="property[@name='Libraries']/@value"/>
    <xsl:variable name="srcpath"
select="property[@name='SourcePath']/@value"/>
    <!-- TODO this is the DestPath with SourcePath removed -->
    <!-- xsl:variable name="destpath"
select="property[@name='DestPath']/@value"/ -->
    <xsl:variable name="destpath" select="'classes'"/>

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

    <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 -->
      <!--
http://www.experimentalstuff.com/Technologies/JavaMake/download.html -->
      <taskdef name="javamake"
classname="com.sun.tools.javamake.ant.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}"/>
 </xsl:for-each>

 <mkdir dir="{$destpath}"/>
 <javamake
   destdir="{$destpath}"
   debug="on"
   compiler="javac1.4"
   source="1.4">

   <!-- Add all the reference libraries by extracting them from the -->
   <!-- Libraries property and then parsing the library XML files -->
   <classpath>
     <path>
       <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:call-template>
    </xsl:variable>
    <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="''"/>
      </xsl:call-template>
    </xsl:variable>
    <pathelement location="{$jarfile}"/>
  </xsl:for-each>
       </xsl:for-each>

     </path>
   </classpath>

   <!-- 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}"/>
   </xsl:for-each>
 </javamake>
      </target>

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

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

    </project>
  </xsl:template>

  <!-- reusable replace-string function from -->
  <!-- http://aspn.activestate.com/ASPN/Cookbook/XSLT/Recipe/65426 -->
  <xsl:template name="replace-string">
    <xsl:param name="text"/>
    <xsl:param name="from"/>
    <xsl:param name="to"/>

    <xsl:choose>
      <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:call-template>
      </xsl:when>
      <xsl:otherwise>
 <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


</xsl:stylesheet>





Jan Matèrne



> -----Ursprüngliche Nachricht-----
> Von: Chris Mcewen-TM [mailto:Chris.Mcewen@telus.com]
> 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. 
> mailto:chris.mcewen@telus.com <mailto:chris.mcewen@telus.com> 
> 
> 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
> 
>  
> 

Mime
View raw message