[Yanel-commits] rev 42458 - in public/yanel/trunk/src/build: . realms targets

guillaume at wyona.com guillaume at wyona.com
Wed Apr 22 07:24:59 CEST 2009


Author: guillaume
Date: 2009-04-22 07:24:54 +0200 (Wed, 22 Apr 2009)
New Revision: 42458

Added:
   public/yanel/trunk/src/build/realms/
   public/yanel/trunk/src/build/realms/build.xml
   public/yanel/trunk/src/build/realms/realms.build.xml
   public/yanel/trunk/src/build/realms2build.xsl
Modified:
   public/yanel/trunk/src/build/targets/realms.xml
Log:
Refactored build of realms that among other things makes it possible
 to handle every realm separately (also those who don't have an Ant build file).
For the moment this is deactivated; to activate, simply replace:
 antfile="${yanel.source.home}/build/build-realms.xml"
with
 antfile="${yanel.source.home}/build/build1-realms.xml"
in src/nuild/targets/realms.xml and src/nuild/targets/realms.xml and rebuild.

Also it may allow use of relative paths in Yanel configuration some day...

Issue: 6888

Added: public/yanel/trunk/src/build/realms/build.xml
===================================================================
--- public/yanel/trunk/src/build/realms/build.xml	                        (rev 0)
+++ public/yanel/trunk/src/build/realms/build.xml	2009-04-22 05:24:54 UTC (rev 42458)
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<project name="realm" default="compile">
+  <!--echo>###### ${ant.file} ${basedir} ######</echo-->
+  <dirname property="realms.build.scripts.dir" file="${ant.file}"/>
+  <property name="realm.home.dir" location="${basedir}"/>
+
+  <property name="yanel.source.home" location="${realms.build.scripts.dir}/../../.."/>
+  <property file="${yanel.source.home}/src/build/local.build.properties"/>
+  <property file="${yanel.source.home}/src/build/build.properties"/>
+
+  <target name="init">
+    <property name="build.dir" location="${yanel.source.home}/build"/>
+    <mkdir dir="${build.dir}"/>
+
+    <property name="realm.ant.file" location="${realm.home.dir}/build.xml"/>
+    <condition property="ant-file-of-realm-exists">
+      <available file="${realm.ant.file}"/>
+    </condition>
+    <!--echo>### ${realm.ant.file} ${ant-file-of-realm-exists} ###</echo-->
+
+    <property name="realm.build.dir" location="${realm.home.dir}/build"/>
+    <condition property="build-dir-of-realm-exists">
+      <available file="${realm.build.dir}" type="dir"/>
+    </condition>
+    <!--echo>### ${realm.build.dir} ${build-dir-of-realm-exists} ###</echo-->
+
+    <property name="realm.lib.dir" location="${realm.home.dir}/build/lib"/>
+    <condition property="lib-dir-of-realm-exists">
+      <available file="${realm.lib.dir}" type="dir"/>
+    </condition>
+    <!--echo>### ${realm.lib.dir} ${lib-dir-of-realm-exists} ###</echo-->
+
+  </target>
+
+  <target name="compile" description="Compile realm" depends="init" if="ant-file-of-realm-exists">
+    <ant inheritAll="false" antfile="${realm.ant.file}" target="compile">
+      <property name="yanel.source.version" value="${yanel.source.version}"/>
+      <property name="maven.url" value="${maven.url}"/>
+    </ant>
+  </target>
+
+  <target name="deploy-libs" description="Deploy libs of realm" depends="init" if="lib-dir-of-realm-exists">
+    <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/lib">
+      <fileset dir="${realm.lib.dir}"/>
+    </copy>
+  </target>
+
+  <target name="clean" description="Clean realm" depends="init" if="build-dir-of-realm-exists">
+    <delete dir="${realm.build.dir}"/>
+  </target>
+
+  <target name="copy-dependencies" description="Copy dependencies of realm" depends="init" if="build-dir-of-realm-exists">
+    <ant inheritAll="false" antfile="${realm.ant.file}" target="copy-dependencies">
+      <property name="build.dir" value="${build.dir}"/>
+      <property name="servlet.context.prefix" value="${servlet.context.prefix}"/>
+      <property name="yanel.source.version" value="${yanel.source.version}"/>
+      <property name="maven.url" value="${maven.url}"/>
+    </ant>
+  </target>
+
+</project>

Added: public/yanel/trunk/src/build/realms/realms.build.xml
===================================================================
--- public/yanel/trunk/src/build/realms/realms.build.xml	                        (rev 0)
+++ public/yanel/trunk/src/build/realms/realms.build.xml	2009-04-22 05:24:54 UTC (rev 42458)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<project name="yanel-realms" default="build-realms">
+
+  <dirname property="realms.build.scripts.dir" file="${ant.file.yanel-realms}"/>
+
+  <presetdef name="realm-subant">
+    <subant genericantfile="${realms.build.scripts.dir}/build.xml"
+     buildpathref="realms.path"
+     inheritall="false"
+     verbose="true"
+    >
+    <!--
+     failonerror="false"
+    -->
+    </subant>
+  </presetdef>
+
+  <target name="build-realms">
+    <realm-subant target="compile"/>
+  </target>
+
+  <target name="copy-dependencies">
+    <realm-subant target="copy-dependencies"/>
+  </target>
+
+  <target name="deploy-realms">
+    <realm-subant target="deploy-libs"/>
+  </target>
+
+  <target name="clean-realms">
+    <realm-subant target="clean"/>
+  </target>
+
+</project>

Added: public/yanel/trunk/src/build/realms2build.xsl
===================================================================
--- public/yanel/trunk/src/build/realms2build.xsl	                        (rev 0)
+++ public/yanel/trunk/src/build/realms2build.xsl	2009-04-22 05:24:54 UTC (rev 42458)
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:yanel="http://www.wyona.org/yanel/1.0"
+  exclude-result-prefixes="yanel"
+>
+
+<xsl:output method="xml" indent="yes"/>
+
+<xsl:param name="local-build-realms-file"/>
+
+<xsl:template match="/">
+
+<xsl:comment> NOTE: This file has been generated automatically from conf/realms.xml resp. conf/local/local.realms.xml! </xsl:comment>
+<project name="realms" default="build-realms">
+  <property name="yanel.source.home" location=".."/><!--XXX HACK-->
+
+  <import file="${{yanel.source.home}}/src/build/realms/realms.build.xml"/>
+
+  <path id="realms.path">
+<xsl:for-each select="/yanel:realms/yanel:realm">
+    <xsl:variable name="absolute-directory-location">
+      <xsl:choose>
+        <xsl:when test="starts-with(yanel:config/@src, '/') or string-length(substring-before(yanel:config/@src, ':/'))='1'">
+          <xsl:value-of select="yanel:config/@src"/>
+        </xsl:when>
+        <xsl:when test="starts-with(yanel:config/@src, '@REALMS_DIR@')">
+          <xsl:value-of select="concat('${yanel.source.home}/src/realms/', substring-after(yanel:config/@src, '@REALMS_DIR@'))"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="concat($local-build-realms-file, '/../', yanel:config/@src)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <pathelement location="{$absolute-directory-location}"/>
+  <xsl:message>found realm with id "<xsl:value-of select="@id"/>" located in <xsl:value-of select="$absolute-directory-location"/></xsl:message>
+</xsl:for-each>
+  </path>
+</project>
+
+</xsl:template>
+
+</xsl:stylesheet>

Modified: public/yanel/trunk/src/build/targets/realms.xml
===================================================================
--- public/yanel/trunk/src/build/targets/realms.xml	2009-04-21 22:17:11 UTC (rev 42457)
+++ public/yanel/trunk/src/build/targets/realms.xml	2009-04-22 05:24:54 UTC (rev 42458)
@@ -29,19 +29,35 @@
   </target>
 
   <target name="generate-realms-build-from-default" description="Generate realms build from default config" depends="init" unless="local.realms.config.exists">
+    <!-- Old way of building realms (TODO: remove it if the alternative way proves better):
+    -->
     <xslt in="${yanel.source.home}/conf/realms.xml" out="../../build/build-realms.xml" style="yanel2realms.xsl" force="false">
       <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
       <param name="yanel.source.version" expression="${yanel.version}-r${yanel.revision}"/>
       <param name="maven.url" expression="${maven.url}"/>
     </xslt>
+
+    <!-- Alternative way of building realms:
+    -->
+    <xslt in="${yanel.source.home}/conf/realms.xml" out="../../build/build1-realms.xml" style="realms2build.xsl" force="false">
+      <param name="local-build-realms-file" expression="${local.config.home}/local.realms.xml"/>
+    </xslt>
   </target>
 
   <target name="generate-realms-build-from-local" description="Generate realms build from local config" depends="init" if="local.realms.config.exists">
+    <!-- Old way of building realms (TODO: remove it if the alternative way proves better):
+    -->
     <xslt in="${local.config.home}/local.realms.xml" out="../../build/build-realms.xml" style="yanel2realms.xsl" force="true">
       <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
       <param name="yanel.source.version" expression="${yanel.version}-r${yanel.revision}"/>
       <param name="maven.url" expression="${maven.url}"/>
     </xslt>
+
+    <!-- Alternative way of building realms:
+    -->
+    <xslt in="${yanel.source.home}/conf/realms.xml" out="../../build/build1-realms.xml" style="realms2build.xsl" force="false">
+      <param name="local-build-realms-file" expression="${local.config.home}/local.realms.xml"/>
+    </xslt>
   </target>
   
 </project>



More information about the Yanel-commits mailing list