stefano 2003/02/20 12:04:58 Modified: tools/src blocks-build.xsl Log: the new build system Revision Changes Path 1.19 +158 -266 xml-cocoon2/tools/src/blocks-build.xsl Index: blocks-build.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/tools/src/blocks-build.xsl,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- blocks-build.xsl 31 Jan 2003 18:08:48 -0000 1.18 +++ blocks-build.xsl 20 Feb 2003 20:04:58 -0000 1.19 @@ -1,335 +1,227 @@ <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output method="xml" version="1.0" indent="yes" /> <xsl:template match="/"> - <project default="all" basedir="." name="blocks-build"> - <description>Autogenerated Ant build file that creates the build dependencies.</description> - + <project basedir="." name="blocks"> + <description>Autogenerated Ant build file that builds blocks.</description> + + <path id="classpath"> + <fileset dir="{string('${lib.core}')}"> + <include name="*.jar"/> + </fileset> + <fileset dir="{string('${lib.endorsed}')}"> + <include name="*.jar"/> + </fileset> + <fileset dir="{string('${lib.core}/jvm${target.vm}')}"> + <include name="*.jar"/> + </fileset> + <fileset dir="{string('${lib.optional}')}"> + <include name="*.jar"/> + </fileset> + <fileset dir="{string('${build.blocks}')}"> + <include name="*.jar"/> + </fileset> + <path location="{string('${build.mocks}')}"/> + <path location="{string('${build.dest}')}"/> + <path location="{string('${build.deprecated.dest}')}"/> + <path location="{string('${build.scratchpad.dest}')}"/> + </path> + + <target name="init"/> + <xsl:apply-templates select="module" /> </project> </xsl:template> <xsl:template match="module"> - <target name="cocoon-core"> - <!-- <ant antfile="build.xml" target="package" /> --> - </target> - - <target name="all"> - <xsl:attribute name="depends">cocoon-core - <xsl:for-each select="project">, - <xsl:value-of select="@name" /> - </xsl:for-each> - </xsl:attribute> - </target> - - <target name="prepare-database-connection" depends="prepare-database-connection-pw,prepare-database-connection-no-pw"> - <!-- need to use 'string()' since xsl expands curly braces! --> - <filter token="db_driver" value="{string('${cocoon.samples.database.driver}')}"/> - <filter token="db_url" value="{string('${cocoon.samples.database.url}')}"/> - <filter token="db_user" value="{string('${cocoon.samples.database.user}')}"/> + <target name="compile"> + <xsl:attribute name="depends">init<xsl:for-each select="project[contains(@name,'-block')]"><xsl:text>,</xsl:text><xsl:value-of select="@name"/>-compile</xsl:for-each></xsl:attribute> </target> - <target name="prepare-jdbc" depends="filter-jdbc,nofilter-jdbc"/> - - <target name="prepare-database-connection-pw" if="cocoon.samples.database.password"> - <filter token="db_password" value="{string('${cocoon.samples.database.password}')}"/> + <target name="patch"> + <xsl:attribute name="depends">init<xsl:for-each select="project[contains(@name,'-block')]"><xsl:text>,</xsl:text><xsl:value-of select="@name"/>-patch</xsl:for-each></xsl:attribute> </target> - <target name="prepare-database-connection-no-pw" unless="cocoon.samples.database.password"> - <filter token="db_password" value=""/> + <target name="samples"> + <xsl:attribute name="depends">init<xsl:for-each select="project[contains(@name,'-block')]"><xsl:text>,</xsl:text><xsl:value-of select="@name"/>-samples</xsl:for-each></xsl:attribute> </target> - <target name="filter-jdbc" unless="jdbc3.present"> - <filter token="JDBC3_START"> - <xsl:attribute name="value">${line.separator} /* Start JDBC3 specific code </xsl:attribute> - </filter> - <filter token="JDBC3_END" value=" End JDBC3 specific code */"/> + <target name="lib"> + <xsl:attribute name="depends">init<xsl:for-each select="project[contains(@name,'-block')]"><xsl:text>,</xsl:text><xsl:value-of select="@name"/>-lib</xsl:for-each></xsl:attribute> </target> - <target name="nofilter-jdbc" if="jdbc3.present"> - <filter token="JDBC3_START" value="Start JDBC3 specific code"/> - <filter token="JDBC3_END" value="End JDBC3 specific code"/> - </target> - - - <xsl:apply-templates select="project" /> + <xsl:apply-templates select="project[contains(@name,'-block')]" /> </xsl:template> <xsl:template match="project"> - <xsl:variable name="current-project-target" select="@name" /> - <xsl:variable name="block-name" select="substring-before(@name,'-block')" /> - - <target name="-{@name}-project-samples" if="{@name}.has.sample"> - <property name="currentblock.dir"> - <xsl:attribute name="value">${blocks.dir}/${currentblock.name}</xsl:attribute> - </property> - <copy filtering="on"> - <xsl:attribute name="todir">${build.war}/samples/${currentblock.name}</xsl:attribute> - - <fileset> - <xsl:attribute name="dir">${currentblock.dir}/samples</xsl:attribute> - </fileset> - </copy> - </target> - - <target name="-{@name}-project-mocks" if="{@name}.has.mocks"> - <path id="currentblock.classpath"> - <fileset> - <xsl:attribute name="dir">${lib.dir}</xsl:attribute> - - <include name="**/*.jar" /> - </fileset> - <fileset> - <xsl:attribute name="dir">${build.dir}</xsl:attribute> + <target name="{@name}" unless="exclude.block.{$block-name}"/> - <include> - <xsl:attribute name="name">*.jar</xsl:attribute> - </include> - </fileset> - </path> - - <property name="currentblock.dir"> - <xsl:attribute name="value">${blocks.dir}/${currentblock.name}</xsl:attribute> - </property> - - <property name="currentblock.mocks.dir"> - <xsl:attribute name="value">${currentblock.dir}/mocks</xsl:attribute> - </property> - - <property name="build.currentblock.mocks.dir"> - <xsl:attribute name="value">${build.blocks.root}/${currentblock.name}/mocks</xsl:attribute> - </property> - - <mkdir> - <xsl:attribute name="dir">${build.currentblock.mocks.dir}</xsl:attribute> - </mkdir> - - <javac> - <xsl:attribute name="srcdir">${currentblock.mocks.dir}</xsl:attribute> - <xsl:attribute name="destdir">${build.currentblock.mocks.dir}</xsl:attribute> - <xsl:attribute name="debug">${debug}</xsl:attribute> - <xsl:attribute name="optimize">${optimize}</xsl:attribute> - <xsl:attribute name="deprecation">${deprecation}</xsl:attribute> - <xsl:attribute name="target">${target.vm}</xsl:attribute> - <xsl:attribute name="nowarn">${nowarn}</xsl:attribute> - <xsl:attribute name="fork">true</xsl:attribute> - - <classpath refid="currentblock.classpath" /> - </javac> - - - </target> - - <target name="-{@name}-project" depends="-{@name}-project-mocks,-{@name}-project-samples,prepare-jdbc,prepare-database-connection"> - - <property name="currentblock.dir"> - <xsl:attribute name="value">${blocks.dir}/${currentblock.name}</xsl:attribute> - </property> + <target name="{@name}-compile" unless="exclude.block.{$block-name}"> + <xsl:if test="depend"> + <xsl:attribute name="depends"><xsl:value-of select="@name"/><xsl:for-each select="depend[not(@version or contains(@project,'cocoon'))]"><xsl:text>,</xsl:text><xsl:value-of select="@project"/>-compile</xsl:for-each></xsl:attribute> + </xsl:if> - <property name="currentblock.java.dir"> - <xsl:attribute name="value">${currentblock.dir}/java</xsl:attribute> - </property> + <!-- Test if this block has special build --> + <available property="{$block-name}.has.build" file="{string('${block}')}/{$block-name}/build.xml"/> - <property name="currentblock.conf.dir"> - <xsl:attribute name="value">${currentblock.dir}/conf</xsl:attribute> - </property> + <!-- Test if this block has mocks --> + <available property="{$block-name}.has.mocks" type="dir" file="{string('${block}')}/{$block-name}/mocks/"/> - <property name="currentblock.samples.dir"> - <xsl:attribute name="value">${currentblock.dir}/samples</xsl:attribute> - </property> + <xsl:if test="@status='unstable'"> + <echo message="-----------------------------------------------"/> + <echo message="ATTENTION: {$block-name} is marked unstable."/> + <echo message="It should be considered alpha quality"/> + <echo message="which means that its API might change without notice."/> + <echo message="-----------------------------------------------"/> + </xsl:if> - <property name="build.currentblock.dir"> - <xsl:attribute name="value">${build.blocks.root}/${currentblock.name}</xsl:attribute> - </property> + <antcall target="{$block-name}-compile"/> + </target> - <property name="build.currentblock.src"> - <xsl:attribute name="value">${build.currentblock.dir}/src</xsl:attribute> - </property> + <target name="{@name}-patch" unless="exclude.block.{$block-name}"> + <xsl:if test="depend"> + <xsl:attribute name="depends"><xsl:value-of select="@name"/><xsl:for-each select="depend[not(@version or contains(@project,'cocoon'))]"><xsl:text>,</xsl:text><xsl:value-of select="@project"/>-patch</xsl:for-each></xsl:attribute> + </xsl:if> - <property name="build.currentblock.dest"> - <xsl:attribute name="value">${build.currentblock.dir}/dest</xsl:attribute> - </property> + </target> + + <target name="{@name}-samples" unless="exclude.block.{$block-name}"> + <xsl:if test="depend"> + <xsl:attribute name="depends"><xsl:value-of select="@name"/><xsl:for-each select="depend[not(@version or contains(@project,'cocoon'))]"><xsl:text>,</xsl:text><xsl:value-of select="@project"/>-samples</xsl:for-each></xsl:attribute> + </xsl:if> - <mkdir> - <xsl:attribute name="dir">${build.currentblock.src}</xsl:attribute> - </mkdir> + <!-- Test if this block has samples --> + <available property="{$block-name}.has.samples" file="{string('${block}')}/{$block-name}/samples/sitemap.xmap"/> - <mkdir> - <xsl:attribute name="dir">${build.currentblock.dest}</xsl:attribute> - </mkdir> + <antcall target="{$block-name}-samples"/> + </target> + + <target name="{@name}-lib" unless="exclude.block.{$block-name}"> + <xsl:if test="depend"> + <xsl:attribute name="depends"><xsl:value-of select="@name"/><xsl:for-each select="depend[not(@version or contains(@project,'cocoon'))]"><xsl:text>,</xsl:text><xsl:value-of select="@project"/>-lib</xsl:for-each></xsl:attribute> + </xsl:if> + <!-- Test if this block has libraries --> + <available property="{$block-name}.has.lib" type="dir"> + <xsl:attribute name="file">${blocks}/<xsl:value-of select="$block-name"/>/lib/</xsl:attribute> + </available> + <antcall target="{$block-name}-lib"/> + </target> - <property name="currentblock.mocks.dir"> - <xsl:attribute name="value">${currentblock.dir}/mocks</xsl:attribute> - </property> - - <property name="build.currentblock.mocks.dir"> - <xsl:attribute name="value">${build.blocks.root}/${currentblock.name}/mocks</xsl:attribute> - </property> - - <mkdir> - <xsl:attribute name="dir">${build.currentblock.mocks.dir}</xsl:attribute> - </mkdir> - - - - - <path id="currentblock.classpath"> - <fileset> - <xsl:attribute name="dir">${lib.dir}</xsl:attribute> + <target name="{$block-name}-prepare"> + <mkdir dir="{string('${build.blocks}')}/{$block-name}/src"/> + <mkdir dir="{string('${build.blocks}')}/{$block-name}/dest"/> - <include name="**/*.jar" /> + <copy filtering="on" todir="{string('${build.blocks}')}/{$block-name}/conf"> + <fileset dir="{string('${blocks}')}/{$block-name}/conf"> + <include name="**/*.x*" /> </fileset> + </copy> - <fileset> - <xsl:attribute name="dir">${build.dir}</xsl:attribute> - - <include> - <xsl:attribute name="name">*.jar</xsl:attribute> - </include> + <path id="{$block-name}.classpath"> + <path refid="classpath"/> + <fileset dir="{string('${blocks}')}/{$block-name}/lib"> + <include name="*.jar"/> </fileset> - - <pathelement> - <xsl:attribute name="path">${build.currentblock.mocks.dir}</xsl:attribute> - </pathelement> - - <pathelement> - <xsl:attribute name="path">${build.mocks}</xsl:attribute> - </pathelement> - + <pathelement path="{string('${build.blocks}')}/{$block-name}/mocks"/> </path> - - <copy filtering="on"> - <xsl:attribute name="todir">${build.currentblock.src}</xsl:attribute> + </target> - <fileset> - <xsl:attribute name="dir">${currentblock.java.dir}</xsl:attribute> + <target name="{$block-name}-compile" depends="{$block-name}-build,{$block-name}-prepare,{$block-name}-mocks"> + + <copy filtering="on" todir="{string('${build.blocks}')}/{$block-name}/src"> + <fileset dir="{string('${blocks}')}/{$block-name}/java"> <include name="**/*.java" /> - <!-- excludes moved from build.xml --> - <!--exclude name="**/Ora*.java" unless="ora.driver.present"/> - <exclude name="**/Ifx*.java" unless="ifx.driver.present"/--> </fileset> </copy> - <copy filtering="on"> - <xsl:attribute name="todir">${build.currentblock.dest}</xsl:attribute> - - <fileset> - <xsl:attribute name="dir">${currentblock.java.dir}</xsl:attribute> + <copy filtering="on" todir="{string('${build.blocks}')}/{$block-name}/dest"> + <fileset dir="{string('${blocks}')}/{$block-name}/java"> <include name="**/*.xsl"/> </fileset> </copy> - <copy filtering="off"> - <xsl:attribute name="todir">${build.currentblock.dest}</xsl:attribute> - - <fileset> - <xsl:attribute name="dir">${currentblock.java.dir}</xsl:attribute> - + <copy filtering="off" todir="{string('${build.blocks}')}/{$block-name}/dest"> + <fileset dir="{string('${blocks}')}/{$block-name}/java"> <include name="**/Manifest.mf" /> - <include name="META-INF/**" /> </fileset> </copy> - <copy filtering="on"> - <xsl:attribute name="todir">${build.currentblock.dest}</xsl:attribute> - - <fileset> - <xsl:attribute name="dir">${currentblock.conf.dir}</xsl:attribute> - - <include name="**/*.x*" /> - </fileset> - </copy> - - <copy filtering="off"> - <xsl:attribute name="todir">${build.blocks.root}</xsl:attribute> - - <fileset> - <xsl:attribute name="dir">${currentblock.conf.dir}</xsl:attribute> + <xpatch extension="xroles" directory="{string('${blocks}')}/{$block-name}/conf" configuration="{string('${build.dest}/org/apache/cocoon/cocoon.roles')}"/> - <include name="**/*.x*" /> - </fileset> - </copy> - -<!-- A task to change the roles file. It is used to add optional components --> - <taskdef name="roles-tool" classname="XConfToolTask"> - <xsl:attribute name="classpath">${tools.dir}/anttasks</xsl:attribute> - </taskdef> - -<!-- Invoke the XConfTool to add optional roles for components --> - <roles-tool extension="xroles"> - <xsl:attribute name="directory">${currentblock.conf.dir}</xsl:attribute> - - <xsl:attribute name="configuration">${build.dest}/org/apache/cocoon/cocoon.roles</xsl:attribute> - </roles-tool> - - <echo> - <xsl:attribute name="message">Compiling block with Java ${ant.java.version}, debug ${debug}, optimize ${optimize}, deprecation ${deprecation}...</xsl:attribute> - </echo> - - <javac> - <xsl:attribute name="srcdir">${build.currentblock.src}</xsl:attribute> - <xsl:attribute name="destdir">${build.currentblock.dest}</xsl:attribute> - <xsl:attribute name="debug">${debug}</xsl:attribute> - <xsl:attribute name="optimize">${optimize}</xsl:attribute> - <xsl:attribute name="deprecation">${deprecation}</xsl:attribute> - <xsl:attribute name="target">${target.vm}</xsl:attribute> - <xsl:attribute name="nowarn">${nowarn}</xsl:attribute> - <xsl:attribute name="fork">true</xsl:attribute> - - <classpath refid="currentblock.classpath" /> + <javac + srcdir="{string('${build.blocks}')}/{$block-name}/src" + destdir="{string('${build.blocks}')}/{$block-name}/dest" + debug="{string('${compiler.debug}')}" + optimize="{string('${compiler.optimize}')}" + deprecation="{string('${compiler.deprecation}')}" + target="{string('${target.vm}')}" + nowarn="{string('${compiler.nowarn}')}" + compiler="{string('${compiler}')}"> + <classpath refid="{$block-name}.classpath" /> </javac> - - <jar> - <xsl:attribute name="jarfile">${build.dir}/${currentblock.name}-block.jar</xsl:attribute> - - <fileset> - <xsl:attribute name="dir">${build.currentblock.dest}</xsl:attribute> - + + <jar jarfile="{string('${build.blocks}')}/{$block-name}-block.jar"> + <fileset dir="{string('${build.blocks}')}/{$block-name}/dest"> <include name="org/**" /> - <include name="META-INF/**" /> </fileset> </jar> + </target> + <target name="{$block-name}-build" if="{$block-name}.has.build"> + <ant inheritAll="true" inheritRefs="false" target="main" antfile="{string('${blocks}')}/{$block-name}/build.xml"/> </target> - + <target name="{$block-name}-mocks" if="{$block-name}.has.mocks"> + <path id="{$block-name}.classpath"> + <path refid="classpath"/> + <fileset dir="{string('${build}')}"> + <include name="*.jar"/> + </fileset> + </path> - <target name="{$current-project-target}" if="cocoon.blocks.{$block-name}.include"> -<!-- if there is a dependency... --> - <xsl:if test="depend"> - <xsl:attribute name="depends">cocoon-core<xsl:for-each select="depend[not(@version)]">, <xsl:value-of select="@project" /></xsl:for-each> - </xsl:attribute> - </xsl:if> + <mkdir dir="{string('${build.blocks}')}/{$block-name}/mocks"/> - <!-- Test if this block has a sample --> - <available property="{@name}.has.sample"> - <xsl:attribute name="file">${blocks.dir}/<xsl:value-of select="$block-name"/>/samples/sitemap.xmap</xsl:attribute> - </available> + <javac + srcdir="{string('${blocks}')}/{$block-name}/mocks" + destdir="{string('${build.blocks}')}/{$block-name}/mocks" + debug="{string('${compiler.debug}')}" + optimize="{string('${compiler.optimize}')}" + deprecation="{string('${compiler.deprecation}')}" + target="{string('${target.vm}')}" + nowarn="{string('${compiler.nowarn}')}" + compiler="{string('${compiler}')}"> + <classpath refid="{$block-name}.classpath" /> + </javac> + </target> - <!-- Test if this block has a sample --> - <available property="{@name}.has.mocks" type="dir"> - <xsl:attribute name="file">${blocks.dir}/<xsl:value-of select="$block-name"/>/mocks/</xsl:attribute> - </available> - - <xsl:if test="@status='unstable'"> - <echo message="-----------------------------------------------"/> - <echo message="ATTENTION: {$block-name} is marked unstable"/> - <echo message="It should be considered being pre-alpha quality"/> - <echo message="It's API might change without notice"/> - <echo message="-----------------------------------------------"/> - </xsl:if> - - <antcall target="-{@name}-project"> - <param name="currentblock.name" value="{$block-name}" /> - </antcall> + <target name="{$block-name}-lib" if="{$block-name}.has.lib"> + <copy filtering="on" todir="{string('${build.webapp.lib}')}"> + <fileset dir="{string('${blocks}')}/{$block-name}/lib"> + <include name="*.jar"/> + </fileset> + </copy> + </target> + + <target name="{$block-name}-patches" depends="{$block-name}-prepare"> + <xpatch directory="{string('${build.blocks}')}/{$block-name}/conf" extension="xmap" configuration="${build.webapp}/sitemap.xmap"/> + <xpatch directory="{string('${build.blocks}')}/{$block-name}/conf" extension="xpipe" configuration="${build.webapp}/sitemap.xmap"/> + <xpatch directory="{string('${build.blocks}')}/{$block-name}/conf" extension="xconf" configuration="${build.webapp}/WEB-INF/cocoon.xconf"/> + </target> + + <target name="{$block-name}-samples" if="{$block-name}.has.samples"> + <copy filtering="on" todir="{string('${build.webapp}')}/samples/{$block-name}"> + <fileset dir="{string('${blocks}')}/{$block-name}/samples"/> + </copy> + <xpatch directory="{string('${build.blocks}')}/{$block-name}/conf" extension="xsamples" configuration="${build.webapp}/samples/samples.xml"/> + <xpatch directory="{string('${build.blocks}')}/{$block-name}/conf" extension="samplesxpipe" configuration="${build.webapp}/samples/sitemap.xmap"/> </target> </xsl:template> </xsl:stylesheet> -
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]