Author: sflanigan
Date: 2008-11-25 21:21:52 -0500 (Tue, 25 Nov 2008)
New Revision: 12057
Modified:
trunk/i18n/build.xml
trunk/i18n/feature.xsl
trunk/i18n/pom.xml
Log:
Created <foreachlocale> macro and extracted -fragment, -categorydef and -plugin
tasks to be called from the macro.
Modified: trunk/i18n/build.xml
===================================================================
--- trunk/i18n/build.xml 2008-11-26 00:40:35 UTC (rev 12056)
+++ trunk/i18n/build.xml 2008-11-26 02:21:52 UTC (rev 12057)
@@ -50,13 +50,6 @@
<!-- pick up the "for" task from ant-contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpathref="dependency.classpath" />
-<!-- xpath and groovy tasks currently unused:
- <taskdef resource="net/uworks/andariel/andariel.properties"
classpathref="dependency.classpath" />
-
- <taskdef name="groovy"
- classname="org.codehaus.groovy.ant.Groovy"
- classpathref="dependency.classpath"/>
--->
<!-- ant-gettext tasks -->
<taskdef name="prop2pot"
classname="org.fedorahosted.tennera.antgettext.Prop2PotTask"
classpathref="dependency.classpath" />
<taskdef name="pot2en"
classname="org.fedorahosted.tennera.antgettext.Pot2EnTask"
classpathref="dependency.classpath" />
@@ -103,11 +96,11 @@
<target name="prop2pot" depends="init"
description="Extract translation templates (POT) from the JBoss Tools English
properties files">
<!-- paths under jbt.srcdir look like: ${module}/plugins/${plugin}/{src,main,...}
-->
- <!-- TODO includes should be just plugins/*/src/**/*.properties.
- See
https://jira.jboss.org/jira/browse/JBIDE-2972
includes="plugins/*/*/**/*.properties" -->
+ <!-- TODO properties *should* be found in exactly one place, but aren't.
+ See
https://jira.jboss.org/jira/browse/JBIDE-2972 -->
<prop2pot srcDir="${jbt.srcdir}" dstDir="po"
includes="*/plugins/*/src/**/*.properties" >
<!-- next two are Maven style, not currently used in JBT: -->
-<!--
+<!-- These filesets were used in a <jar> call, not supported by
<prop2pot>
<fileset erroronmissingdir="false"
dir="${plugindir}/src/main/java"/>
<fileset erroronmissingdir="false"
dir="${plugindir}/src/main/resources"/>
@@ -162,25 +155,54 @@
macrodef: checkprop checks that specified property has been set
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<macrodef name="checkprop">
- <attribute name="propname" />
+ <attribute name="name" />
<sequential>
<if>
- <!-- TODO fail on empty value -->
<not>
- <isset property="@{propname}"/>
+ <isset property="@{name}"/>
</not>
<then>
- <fail message="property '@{propname}' is not set"/>
+ <fail message="property '@{name}' is not set"/>
</then>
</if>
+ <if>
+ <length string="${@{name}}" length="0"/>
+ <then>
+ <fail message="property '@{name}' has an empty value"/>
+ </then>
+ </if>
</sequential>
</macrodef>
+ <!-- = = = = = = = = = = = = = = = = =
+ macrodef: foreachlocale
+ = = = = = = = = = = = = = = = = = -->
+ <macrodef name="foreachlocale">
+ <attribute name="task" />
+ <sequential>
+ <!-- for each configured locale (in i18n.properties) -->
+ <for param="locale" list="${locales}">
+ <sequential>
+ <antcall target="@{task}" inheritall="true">
+ <param name="locale" value="@{locale}"/>
+ <param name="localename"
value="${NAME_@{locale}}"/>
+
+ <!-- Having these task-specific params is ugly, but
+ otherwise <var>s don't get passed through: -->
+ <param name="plugindir" value="${plugindir}"/>
+ <param name="featurexml" value="${featurexml}"/>
+ </antcall>
+ </sequential>
+ </for>
+ </sequential>
+ </macrodef>
+
<!-- Processes the generated props directory, one plugin at a time,
generating manifests and jars -->
<target name="plugins" depends="init" description="Generate
fragment manifests and jars for langpack plugins">
<delete dir="${jardir}/plugins" />
<mkdir dir="${jardir}/plugins" />
+ <!-- for each plugin directory -->
<for param="plugindir">
<path>
<dirset dir="${propdir}" includes="*/*" />
@@ -188,50 +210,52 @@
<sequential>
<echo message="@{plugindir}" />
<!-- TODO avoid property override if possible -->
+ <!-- work out the plugin ID -->
+ <var name="plugin" unset="true" />
<propertyregex override="true" property="plugin"
input="@{plugindir}"
regexp="^${propdir}[/\\][^/\\]+[/\\]([^/\\]+).*"
select="\1" />
- <checkprop propname="plugin"/>
+ <checkprop name="plugin"/>
<echo level="verbose" message="@{plugindir} contains props for
plugin ${plugin}"/>
- <checkprop propname="PLUGIN_VERSION"/>
- <checkprop propname="PLUGIN_VENDOR"/>
- <for param="locale" list="${locales}">
- <sequential>
- <!-- TODO avoid property override if possible -->
- <propertycopy override="true" property="localename"
from="NAME_@{locale}"/>
- <checkprop propname="localename"/>
-
- <!-- Jars up one fragment plugin. -->
- <jar
- destfile="${jardir}/plugins/${plugin}.nl-(a){locale}_${PLUGIN_VERSION}.jar"
- update="no"
- basedir="@{plugindir}"
- duplicate="fail"
- includes="**/*_(a){locale}.properties">
- <manifest>
- <attribute name="Manifest-Version"
- value="1.0"/>
- <attribute name="Created-By"
- value="JBoss Tools i18n (build.xml)"/>
- <attribute name="Bundle-Name"
- value="${plugin} ${localename} NLS Support"/>
- <attribute name="Bundle-SymbolicName"
- value="${plugin}.nl_@{locale} ;singleton=true"/>
- <attribute name="Bundle-Version"
- value="${PLUGIN_VERSION}"/>
- <attribute name="Bundle-Vendor"
- value="${PLUGIN_VENDOR}"/>
- <attribute name="Fragment-Host"
- value="${plugin}"/>
- </manifest>
- </jar>
- </sequential>
- </for>
+ <!-- making sure these values are available to -plugin -->
+ <checkprop name="PLUGIN_VERSION"/>
+ <checkprop name="PLUGIN_VENDOR"/>
+ <var name="plugindir" value="@{plugindir}" />
+ <foreachlocale task="-plugin"/>
</sequential>
</for>
</target>
+
+ <target name="-plugin" >
+ <!-- Jars up one fragment plugin. -->
+ <jar
+ destfile="${jardir}/plugins/${plugin}.nl-${locale}_${PLUGIN_VERSION}.jar"
+ filesonly="true"
+ update="false"
+ whenmanifestonly="create"
+ basedir="${plugindir}"
+ duplicate="fail"
+ includes="**/*_${locale}.properties">
+ <manifest>
+ <attribute name="Manifest-Version"
+ value="1.0"/>
+ <attribute name="Created-By"
+ value="JBoss Tools i18n (build.xml)"/>
+ <attribute name="Bundle-Name"
+ value="${plugin} ${localename} NLS Support"/>
+ <attribute name="Bundle-SymbolicName"
+ value="${plugin}.nl_${locale} ;singleton=true"/>
+ <attribute name="Bundle-Version"
+ value="${PLUGIN_VERSION}"/>
+ <attribute name="Bundle-Vendor"
+ value="${PLUGIN_VENDOR}"/>
+ <attribute name="Fragment-Host"
+ value="${plugin}"/>
+ </manifest>
+ </jar>
+ </target>
<target name="features" depends="init"
description="Generate langpack feature manifests (one per locale) for each JBT
feature, and corresponding site.xml">
@@ -246,84 +270,36 @@
suffix=".tmp"
createfile="true"
deleteonexit="false" />
- <sequential>
- <for param="featurexml">
- <path>
- <fileset dir="${jbt.srcdir}"
includes="*/features/*/feature.xml"/>
- </path>
- <sequential>
- <!-- TODO avoid property override if possible -->
- <propertyregex
- override="true"
- property="feature"
- input="@{featurexml}"
-
regexp="^${jbt.srcdir}[/\\][^/\\]+[/\\]features[/\\]([^/\\]+)[/\\]feature.xml"
- select="\1" />
- <checkprop propname="feature"/>
- <echo level="verbose" message="Processing feature
${feature}"/>
- <for param="locale" list="${locales}">
- <sequential>
- <!-- TODO avoid property override if possible -->
- <propertycopy override="true" property="localename"
from="NAME_@{locale}"/>
- <!-- TODO use a macro for this -->
- <echo append="true" file="${temp.file.sitefeatures}"
- message="<feature
url=&quot;features/${feature}.nl-(a){locale}_${PLUGIN_VERSION}.jar&quot;
- id="${feature}.nl-@{locale}"
version="${PLUGIN_VERSION}">
- <category name="@{locale}"/>
- </feature>" />
- <!-- demunged, that looks like:
- <feature
url="features/${feature}.nl-(a){locale}_${PLUGIN_VERSION}.jar"
- id="${feature}.nl-@{locale}"
version="${PLUGIN_VERSION}">
- <category name="@{locale}"/>
- </feature>
- -->
- <!-- Process feature.xml with <xslt> -->
- <!-- consider: using groovy instead to eliminate empty plugin fragments -->
- <xslt
- style="feature.xsl"
- in="@{featurexml}"
- out="${propdir}/features/${feature}.nl-(a){locale}_${PLUGIN_VERSION}/feature.xml"
- >
- <param name="feature" expression="${feature}" />
- <param name="locale" expression="@{locale}" />
- <param name="localename" expression="${localename}" />
- <param name="pluginversion" expression="${PLUGIN_VERSION}"
/>
- </xslt>
-
- <copy overwrite="true"
- todir="${propdir}/features/${feature}.nl-@{locale}_${PLUGIN_VERSION}">
- <fileset dir="feature-template/FEATURE.nl-LOCALE_VERSION" />
- </copy>
- <jar
destfile="${jardir}/features/${feature}.nl-(a){locale}_${PLUGIN_VERSION}.jar"
- basedir="${propdir}/features/${feature}.nl-@{locale}_${PLUGIN_VERSION}"
/>
- <!-- might want to keep around for debugging: -->
- <delete
dir="${propdir}/features/${feature}.nl-@{locale}_${PLUGIN_VERSION}" />
- </sequential>
- </for>
- </sequential>
- </for>
- </sequential>
- <!--
- Generate a list of features for each locale, so that the update
- site can have a category for each locale:
- -->
- <for param="locale" list="${locales}">
+ <!-- for each feature manifest -->
+ <for param="featurexml">
+ <path>
+ <fileset dir="${jbt.srcdir}"
includes="*/features/*/feature.xml"/>
+ </path>
<sequential>
<!-- TODO avoid property override if possible -->
- <propertycopy override="true" property="localename"
from="NAME_@{locale}"/>
- <echo append="true" file="${temp.file.sitefeatures}"
- message="<category-def name="@{locale}"
label="JBoss Tools Localization (${localename})"/>" />
- <!-- demunged, that looks like:
- <category-def
- name="@{locale}"
- label="JBoss Tools Localization (${localename})"/>
- -->
+ <!-- work out the feature ID -->
+ <var name="feature" unset="true" />
+ <propertyregex
+ override="true"
+ property="feature"
+ input="@{featurexml}"
+ regexp="^${jbt.srcdir}[/\\][^/\\]+[/\\]features[/\\]([^/\\]+)[/\\]feature.xml"
+ select="\1" />
+ <checkprop name="feature"/>
+ <echo level="verbose" message="Processing feature
${feature}"/>
+
+ <!-- making sure this value is available to -feature -->
+ <var name="featurexml" value="@{featurexml}" />
+ <foreachlocale task="-feature"/>
</sequential>
</for>
+
+ <foreachlocale task="-categorydef"/>
-
- <!-- Read in the above list of features -->
- <!-- FIXME var features (loading list of features) -->
+ <!-- Read in the list of <feature>s and <category-def>s created by
+ the targets -categorydef and -feature -->
+ <!-- TODO this is an ugly way to build XML
+ (see also the <echo>s in above-mentioned targets) -->
<var name="features" unset="true" />
<loadfile property="features"
srcFile="${temp.file.sitefeatures}"/>
<delete file="${temp.file.sitefeatures}"/>
@@ -336,6 +312,55 @@
</copy>
</target>
+ <!-- Create a <category-def> for ${locale} for site.xml -->
+ <target name="-categorydef">
+ <!-- ugly -->
+ <echo append="true" file="${temp.file.sitefeatures}"
+ message="<category-def name="${locale}"
label="JBoss Tools Localization (${localename})"/>" />
+ <!-- demunged, that looks like:
+ <category-def
+ name="${locale}"
+ label="JBoss Tools Localization (${localename})"/>
+ -->
+ </target>
+
+ <!-- Create feature jar including manifest. Also create a <feature> for
site.xml -->
+ <target name="-feature">
+ <!-- create langpack feature element for site.xml -->
+ <!-- ugly -->
+ <echo append="true" file="${temp.file.sitefeatures}"
+ message="<feature
url="features/${feature}.nl-${locale}_${PLUGIN_VERSION}.jar"
+ id="${feature}.nl-${locale}"
version="${PLUGIN_VERSION}">
+ <category name="${locale}"/>
+ </feature>" />
+ <!-- demunged, that looks like:
+ <feature url="features/${feature}.nl-${locale}_${PLUGIN_VERSION}.jar"
+ id="${feature}.nl-${locale}" version="${PLUGIN_VERSION}">
+ <category name="${locale}"/>
+ </feature>
+ -->
+ <!-- Process feature.xml with <xslt> -->
+ <xslt
+ style="feature.xsl"
+ in="${featurexml}"
+ out="${propdir}/features/${feature}.nl-${locale}_${PLUGIN_VERSION}/feature.xml"
+ >
+ <param name="feature" expression="${feature}" />
+ <param name="locale" expression="${locale}" />
+ <param name="localename" expression="${localename}" />
+ <param name="pluginversion" expression="${PLUGIN_VERSION}"
/>
+ </xslt>
+
+ <copy overwrite="true"
+ todir="${propdir}/features/${feature}.nl-${locale}_${PLUGIN_VERSION}">
+ <fileset dir="feature-template/FEATURE.nl-LOCALE_VERSION" />
+ </copy>
+ <jar
destfile="${jardir}/features/${feature}.nl-${locale}_${PLUGIN_VERSION}.jar"
+ basedir="${propdir}/features/${feature}.nl-${locale}_${PLUGIN_VERSION}"
/>
+ <!-- might want to keep around for debugging: -->
+ <delete
dir="${propdir}/features/${feature}.nl-${locale}_${PLUGIN_VERSION}" />
+ </target>
+
<target name="p2" description="Generate metadata for Eclipse 3.4's
update manager (P2)" >
<!-- Generate P2 metadata so that update manager won't take forever.
http://wiki.eclipse.org/Equinox_p2_Metadata_Generator
Modified: trunk/i18n/feature.xsl
===================================================================
--- trunk/i18n/feature.xsl 2008-11-26 00:40:35 UTC (rev 12056)
+++ trunk/i18n/feature.xsl 2008-11-26 02:21:52 UTC (rev 12057)
@@ -12,6 +12,13 @@
<feature provider-name="%providerName">
<xsl:attribute name="id"><xsl:value-of select="$feature"
/>-<xsl:value-of select="$locale" />
</xsl:attribute>
+ <!-- NB A few feature labels (eg org.jboss.tools.birt.feature)
+ use %featureName, which is then replicated in the langpack
+ feature (bad).
+ TODO change affected feature manifests to inline those feature
+ names (since they shouldn't be translated anyway) or use @id
+ here, not @label.
+ -->
<xsl:attribute name="label">JBoss Tools Language Pack for
<xsl:value-of select="@label" /> in <xsl:value-of
select="$localename" />
</xsl:attribute>
<xsl:attribute name="version">
Modified: trunk/i18n/pom.xml
===================================================================
--- trunk/i18n/pom.xml 2008-11-26 00:40:35 UTC (rev 12056)
+++ trunk/i18n/pom.xml 2008-11-26 02:21:52 UTC (rev 12057)
@@ -35,17 +35,5 @@
<!-- 1.0b3 is not in the central/jboss maven repos -->
<version>1.0b2</version>
</dependency>
-<!--
- <dependency>
- <groupId>net.uworks</groupId>
- <artifactId>andariel</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>1.5.6</version>
- </dependency>
--->
</dependencies>
</project>