donaldp 02/04/20 18:45:04
Modified: . build.xml
Added: tools/xsl build.xsl
Removed: src/stylesheets build.xsl
Log:
Moved build.xsl into tools hierarchy.
Update the build system to make it easier to flick a switch and have the
build.xmls generated for you (by overiding a property on command line)
Revision Changes Path
1.9 +32 -25 jakarta-ant-myrmidon/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/build.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- build.xml 20 Apr 2002 07:34:39 -0000 1.8
+++ build.xml 21 Apr 2002 01:45:04 -0000 1.9
@@ -1,45 +1,49 @@
<project name="Myrmidon" default="main">
+
+ <property name="build.xsl" location="tools/xsl/build.xsl"/>
+ <property name="buildfile.name" value="sample-build.xml"/>
+
<target name="main">
- <ant dir="buildtools"/>
- <ant dir="api"/>
- <ant dir="aut"/>
- <ant dir="container"/>
- <ant dir="framework"/>
- <ant dir="antlib"/>
+ <ant dir="buildtools" antfile="${buildfile.name}"
inheritAll="false"/>
+ <ant dir="api" antfile="${buildfile.name}" inheritAll="false"/>
+ <ant dir="aut" antfile="${buildfile.name}" inheritAll="false"/>
+ <ant dir="container" antfile="${buildfile.name}" inheritAll="false"/>
+ <ant dir="framework" antfile="${buildfile.name}" inheritAll="false"/>
+ <ant dir="antlib" antfile="${buildfile.name}" inheritAll="false"/>
</target>
<target name="build-files" description="Generates the project build
files">
<style in="buildtools/project.xml"
- out="buildtools/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="buildtools/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="api/project.xml"
- out="api/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="api/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="aut/project.xml"
- out="aut/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="aut/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="container/project.xml"
- out="container/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="container/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="framework/project.xml"
- out="framework/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="framework/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="antlib/project.xml"
- out="antlib/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="antlib/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="ant1compat/project.xml"
- out="ant1compat/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="ant1compat/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
<style in="myrmidon/project.xml"
- out="myrmidon/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="myrmidon/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
</target>
@@ -103,10 +107,13 @@
<target name="call-project-target">
<style in="${project}/project.xml"
- out="${project}/sample-build.xml"
- style="src/stylesheets/build.xsl"
+ out="${project}/${buildfile.name}"
+ style="${build.xsl}"
processor="trax" />
- <ant dir="${project}" antfile="sample-build.xml" target="${target}"/>
+ <ant dir="${project}"
+ antfile="${buildfile.name}"
+ target="${target}"
+ inheritAll="false"/>
</target>
</project>
1.1 jakarta-ant-myrmidon/tools/xsl/build.xsl
Index: build.xsl
===================================================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/project">
<xsl:comment>This is a generated file - do not edit.</xsl:comment>
<project name="{name}" default="main">
<!-- Give user a chance to override without editing this file
(and without
typing -D each time they compile it) -->
<property file="ant.properties"/>
<property file="../ant.properties"/>
<property file="${{user.home}}/.ant.properties"/>
<!-- External resources -->
<property name="stylesheet.dir" value="../src/stylesheets"/>
<property name="tools.dir" value="../tools"/>
<!-- Settings used to configure compile environment -->
<property name="build.debug" value="on"/>
<property name="build.optimize" value="off"/>
<property name="build.deprecation" value="off"/>
<property name="build.compress" value="false"/>
<!--Location of intermediate products-->
<property name="build.dir" value="build"/>
<property name="build.lib" value="${{build.dir}}/lib"/>
<property name="build.conf" value="${{build.dir}}/conf"/>
<property name="build.classes" value="${{build.dir}}/classes"/>
<property name="build.reports" value="${{build.dir}}/reports"/>
<property name="build.tests" value="${{build.dir}}/test"/>
<!--Set the properties for distribution directories-->
<property name="dist.dir" value="dist"/>
<property name="dist.javadocs" value="${{dist.dir}}/docs/api"/>
<!--property indicating directory where all distribution archives
are placed-->
<property name="dist.base" value="distributions"/>
<!--Properties for running the unit tests-->
<property name="test.classes" value="${{build.tests}}/classes"/>
<property name="test.working.dir" value="${{test.classes}}"/>
<property name="junit.fork" value="false"/>
<property name="junit.failonerror" value="false"/>
<property name="single.test" value="*"/>
<!-- Global properties -->
<xsl:copy-of select="property"/>
<!-- Various paths and patternsets -->
<path id="project.class.path">
<xsl:copy-of select="classpath/*|classpath/@*"/>
</path>
<path id="compile.class.path">
<path refid="project.class.path"/>
<path>
<xsl:copy-of select="build/classpath/*[name() !=
'ant-runtime']|build/classpath/@*"/>
</path>
</path>
<path id="test.class.path">
<path refid="project.class.path"/>
<path>
<xsl:copy-of
select="unitTest/classpath/*|unitTest/classpath/@*"/>
</path>
</path>
<path id="xdoclet.class.path">
<fileset dir="${{tools.dir}}/xdoclet" includes="*.jar"/>
</path>
<path id="project.source.path">
<xsl:for-each select="build/sourceDirectory">
<pathelement location="{.}"/>
</xsl:for-each>
</path>
<patternset id="project.compile.patternset">
<xsl:for-each select="build/compilePatterns">
<xsl:copy-of select="*|@*"/>
</xsl:for-each>
</patternset>
<target name="main" depends="jars" description="Builds the
project jars" />
<target name="rebuild" depends="clean, main"
description="Rebuilds the project jars" />
<target name="clean" description="Cleans up the project">
<delete file="checkstyle.cache"/>
<delete dir="${{build.dir}}" />
<delete dir="${{dist.dir}}" />
<delete>
<fileset dir="." includes="**/*~" defaultexcludes="no"/>
</delete>
</target>
<target name="clean-classes" description="Cleans all compiled
classes">
<delete dir="${{build.classes}}"/>
<delete dir="${{test.classes}}"/>
</target>
<target name="real-clean" depends="clean" description="Cleans up
the project, including distributions">
<delete dir="${{dist.base}}" />
</target>
<target name="prepare">
<!-- Check for junit -->
<available property="junit.present"
classname="junit.framework.TestCase"/>
<!-- Determine Java version -->
<available property="jdk1.2+"
classname="java.lang.ThreadLocal" />
<available property="jdk1.3+"
classname="java.lang.StrictMath" />
<available property="jdk1.4+"
classname="java.lang.CharSequence" />
<!-- Check for Ant version 1.5 -->
<property resource="org/apache/tools/ant/version.txt"/>
<condition property="ant1.5">
<or>
<equals arg1="${{VERSION}}" arg2="1.5alpha"/>
<equals arg1="${{VERSION}}" arg2="1.5"/>
</or>
</condition>
<!-- taskdef the antlib descriptor task, necessary -->
<xsl:if test="build/jar[not(includeDescriptors =
'false')]|build/antlib[not(includeDescriptors =
'false')]|unitTest[not(includeDescriptors='false')]" >
<taskdef name="antlib-descriptor"
classname="org.apache.myrmidon.build.AntlibDescriptorTask">
<classpath>
<path refid="xdoclet.class.path"/>
<fileset dir="../buildtools/build/lib"
includes="*.jar"/>
</classpath>
</taskdef>
</xsl:if>
<!-- Custom tasks -->
<xsl:copy-of select="build/prepare/*"/>
</target>
<target name="compile-src" depends="prepare">
<mkdir dir="${{build.classes}}"/>
<xsl:if test="build/sourceDirectory">
<!-- Compile all classes -->
<javac
destdir="${{build.classes}}"
debug="${{build.debug}}"
optimize="${{build.optimize}}"
deprecation="${{build.deprecation}}"
target="1.2">
<xsl:if test="not(build/classpath/ant-runtime)">
<xsl:attribute
name="includeAntRuntime">false</xsl:attribute>
</xsl:if>
<classpath refid="compile.class.path"/>
<src refid="project.source.path"/>
<patternset refid="project.compile.patternset"/>
</javac>
<!-- copy resources to same location as .class files -->
<copy todir="${{build.classes}}">
<xsl:for-each select="build/sourceDirectory">
<fileset dir="{.}">
<exclude name="**/*.java"/>
</fileset>
</xsl:for-each>
</copy>
</xsl:if>
</target>
<xsl:choose>
<xsl:when test="unitTest">
<target name="compile" depends="compile-src,
compile-tests"/>
<target name="fail-no-junit" unless="junit.present">
<fail>Could not find JUnit in the project classpath.
Cannot compile the unit tests.</fail>
</target>
<target name="compile-tests" depends="compile-src,
fail-no-junit" if="junit.present">
<mkdir dir="${{test.classes}}"/>
<!-- Compile all classes -->
<javac
destdir="${{test.classes}}"
debug="${{build.debug}}"
optimize="${{build.optimize}}"
deprecation="${{build.deprecation}}"
target="1.2">
<classpath location="${{build.classes}}"/>
<classpath refid="test.class.path"/>
<src location="{unitTest/sourceDirectory}"/>
<patternset refid="project.compile.patternset"/>
</javac>
<!-- copy resources to same location as .class files
-->
<copy todir="${{test.classes}}">
<fileset dir="{unitTest/sourceDirectory}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="test-prepare">
<xsl:copy-of select="unitTest/test-prepare/*"/>
</target>
<target name="run-tests" depends="jars, compile-tests,
test-prepare" if="junit.present">
<mkdir dir="${{build.tests}}"/>
<antlib-descriptor
destdir="${{test.classes}}/META-INF"
libName="tests"
descriptorName="ant-descriptor.xml"
rolesDescriptorName="ant-roles.xml">
<fileset dir="{unitTest/sourceDirectory}">
<patternset
refid="project.compile.patternset"/>
</fileset>
<classpath refid="xdoclet.class.path"/>
<classpath location="${{build.classes}}"/>
<classpath refid="test.class.path"/>
<classpath path="${{java.class.path}}"/>
</antlib-descriptor>
<junit fork="${{junit.fork}}"
haltonfailure="${{junit.failonerror}}"
failureProperty="tests.failed"
printsummary="yes" >
<classpath>
<path location="${{test.classes}}"/>
<fileset dir="${{build.lib}}"
includes="*.jar, *.atl"/>
<path refid="test.class.path"/>
<fileset dir="../tools/xalan"
includes="*.jar"/>
</classpath>
<sysproperty key="test.basedir"
file="${{test.classes}}"/>
<formatter type="xml"/> <!-- xml reports for
junitreport -->
<formatter type="plain"/> <!-- text reports for
humans -->
<batchtest todir="${{build.tests}}">
<fileset dir="${{test.classes}}">
<include
name="**/${{single.test}}TestCase.class"/>
<exclude name="**/Abstract*"/>
<xsl:copy-of
select="unitTest/unitTestPatterns/*"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test" if="tests.failed"
depends="run-tests" description="Runs the unit tests">
<fail>Unit tests failed.</fail>
</target>
</xsl:when>
<xsl:otherwise>
<target name="compile" depends="compile-src"/>
<target name="test" depends="jars">
<echo>This project has no unit tests.</echo>
</target>
</xsl:otherwise>
</xsl:choose>
<target name="jars" depends="compile" description="Builds the
project jar files">
<mkdir dir="${{build.lib}}"/>
<xsl:apply-templates select="build/jar|build/antlib"/>
</target>
<target name="javadocs" description="Generates the javadocs">
<xsl:if test="build/sourceDirectory">
<mkdir dir="${{dist.javadocs}}"/>
<javadoc
destdir="${{dist.javadocs}}">
<classpath refid="compile.class.path" />
<sourcepath refid="project.source.path" />
<xsl:for-each select="package">
<package name="{.}.*"/>
</xsl:for-each>
<doclet
name="com.sun.tools.doclets.standard.Standard">
<param name="-author"/>
<param name="-version"/>
<param name="-doctitle" value="{name}
v{currentVersion}"/>
<param name="-windowtitle" value="{name}
v{currentVersion}"/>
<param name="-link"
value="http://java.sun.com/j2se/1.4/docs/api/"/>
<param name="-link"
value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
<param name="-link"
value="http://jakarta.apache.org/avalon/api/"/>
<param name="-bottom"
value=""Copyright © {inceptionYear}
Apache Jakarta Project. All Rights Reserved.""/>
</doclet>
</javadoc>
</xsl:if>
</target>
<!-- Creates a minimal distribuion -->
<target name="dist-lite" depends="jars" description="Creates a
minimal distribution">
<mkdir dir="${{dist.dir}}"/>
<copy todir="${{dist.dir}}">
<fileset dir="${{build.lib}}" includes="*.jar, *.atl"/>
<fileset dir=".." includes="LICENSE.txt, KEYS,
WARNING.txt"/>
<fileset dir="." includes="README.txt"/>
</copy>
<xsl:copy-of select="build/dist-prepare/*"/>
</target>
<!-- Creates the distribution -->
<target name="dist"
depends="dist-lite, test, javadocs"
description="Creates the distribution">
<mkdir dir="${{dist.base}}"/>
<xsl:variable name="distname" select="concat(id, '-',
currentVersion)"/>
<zip zipfile="${{dist.base}}/{$distname}-bin.zip"
compress="true">
<zipfileset dir="${{dist.dir}}" prefix="{$distname}"/>
</zip>
<!--
<tarfileset prefix=""> is not supported by released ant
but when it is we should enable this across all of the
products
<tar longfile="gnu"
tarfile="${{dist.base}}/{$distname}-bin.tar">
<tarfileset dir="${{dist.dir}}"
username="ant"
prefix="{$distname}"
group="ant"/>
</tar>
<gzip zipfile="${{dist.base}}/{$distname}-bin.tar.gz"
src="${{dist.base}}/{$distname}-bin.tar"/>
Need to switch this on too
<bzip2 zipfile="${{dist.base}}/{$distname}-bin.tar.bz2"
src="{$distname}-bin.tar"/>
<delete file="${{dist.base}}/{$distname}-bin.tar"/>
<checksum fileext=".md5">
<fileset dir="${{dist.base}}" />
</checksum>
-->
</target>
<!-- Extra targets -->
<xsl:copy-of select="build/additionalTargets/*"/>
</project>
</xsl:template>
<xsl:template match="jar|antlib">
<!-- Generate the manifest -->
<redirect:write file="src/conf/{id}.mf">
<xsl:text>Manifest-Version: 1.0
Created-By: Apache Ant Project
</xsl:text>
<xsl:apply-templates select="extension">
<xsl:with-param name="prefix"></xsl:with-param>
</xsl:apply-templates>
<xsl:for-each
select="depends/extension[1]">Extension-List:</xsl:for-each>
<xsl:for-each select="depends/extension"> ext<xsl:value-of
select="position()"/></xsl:for-each>
<xsl:for-each select="depends/extension[last()]"><xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:apply-templates select="depends/extension" />
<xsl:for-each select="attribute"><xsl:value-of select="@name"/>:
<xsl:value-of select="@value"/></xsl:for-each>
</redirect:write>
<mkdir dir="${{build.conf}}/{id}"/>
<!-- Generate the descriptors -->
<xsl:if test="not(includeDescriptors = 'false')">
<xsl:variable name="patterns" select="patternset"/>
<antlib-descriptor
destdir="${{build.conf}}/{id}"
libName="{id}"
descriptorName="ant-descriptor.xml"
rolesDescriptorName="ant-roles.xml">
<xsl:for-each select="../sourceDirectory">
<fileset dir="{.}">
<patternset refid="project.compile.patternset"/>
<xsl:copy-of select="$patterns"/>
</fileset>
</xsl:for-each>
<classpath refid="xdoclet.class.path"/>
<classpath refid="compile.class.path"/>
<classpath path="${{java.class.path}}"/>
</antlib-descriptor>
</xsl:if>
<copy todir="${{build.conf}}/{id}" file="../LICENSE.txt"/>
<xsl:variable name="jarName">
<xsl:choose>
<xsl:when test="name">
<xsl:value-of select="name"/>
</xsl:when>
<xsl:when test="self::antlib">
<!-- Don't include version info in antlib name, since
name is currently used to locate the antlib when
importing. -->
<xsl:value-of select="concat(id, '.atl')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(id, '-',
/project/currentVersion, '.jar')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<jar jarfile="${{build.lib}}/{$jarName}"
basedir="${{build.classes}}"
compress="${{build.compress}}"
manifest="src/conf/{id}.mf">
<metainf dir="${{build.conf}}/{id}" />
<xsl:copy-of select="patternset"/>
<xsl:copy-of select="fileset"/>
<xsl:copy-of select="metainf"/>
</jar>
</xsl:template>
<xsl:template match="extension">
<xsl:param name="prefix" select="concat( 'ext', position(), '-' )"/>
<xsl:if test="@extension-name">
<xsl:value-of select="$prefix"/>Extension-Name: <xsl:value-of
select="@extension-name"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:if test="@specification-vendor">
<xsl:value-of select="$prefix"/>Specification-Vendor:
<xsl:value-of select="@specification-vendor"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:if test="@specification-version">
<xsl:value-of select="$prefix"/>Specification-Version:
<xsl:value-of select="@specification-version"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:if test="@implementation-vendor">
<xsl:value-of select="$prefix"/>Implementation-Vendor:
<xsl:value-of select="@implementation-vendor"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:if test="@implementation-vendor-id">
<xsl:value-of select="$prefix"/>Implementation-Vendor-Id:
<xsl:value-of select="@implementation-vendor-id"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:if test="@implemenation-version">
<xsl:value-of select="$prefix"/>Implementation-Version:
<xsl:value-of select="@implementation-version"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<!-- Chuck all text content -->
<xsl:template match="text()"></xsl:template>
</xsl:stylesheet>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>