Iterate over the locales rather than having to hardcode them. Thanks to Hiroshi Miura!
authorAndy Allan <andy@gravitystorm.co.uk>
Sat, 26 Nov 2011 12:39:16 +0000 (12:39 +0000)
committerAndy Allan <andy@gravitystorm.co.uk>
Sat, 26 Nov 2011 12:39:16 +0000 (12:39 +0000)
build.properties.template
build.xml
lib/ant-contrib-1.0b3.jar [new file with mode: 0644]

index 55fcec5..d24b972 100644 (file)
@@ -19,4 +19,4 @@ test.src.dir = ${basedir}/tests/src
 test.fakeroot.dir = ${basedir}/tests/fakeroot
 test.bin.dir = ${basedir}/tests/bin
 report.dir = ${basedir}/tests/report
-report.html.dir = ${basedir}/tests/report/html
\ No newline at end of file
+report.html.dir = ${basedir}/tests/report/html
index 07e43f6..5472453 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,4 +1,4 @@
-<project name="Potlatch 2" default="debug">
+<project name="Potlatch 2" default="debug" xmlns:ac="antlib:net.sf.antcontrib">
 
   <!-- load properties from the environment -->
   <property environment="env" />
@@ -9,6 +9,9 @@
   <!-- flexTasks comes with flex, but apparently it's good practice to put in the libs folder -->
   <taskdef resource="flexTasks.tasks" classpath="${basedir}/lib/flexTasks.jar"/>
 
+  <!-- ant-contrib to build multiple locales -->
+  <taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpath="${basedir}/lib/ant-contrib-1.0b3.jar"/>
+
   <!-- if you are running git-svn, you need to run "git tag -a 0.4 0ac0de" where 0ac0de corresponds to the commitid of
       potlatch2 v0.4 . You need to do this for each point release while we're still in SVN.
       If you don't, then expect "git describe" to fail miserably.
@@ -58,7 +61,7 @@
   </target>
 
   <!-- note that there's an asdoc target in Flex 4, if/when we move to that -->
-  <target name="docs" depends="manifests">
+  <target name="docs" depends="manifests,makeLocalesList">
     <exec executable="${ASDOC}" failonerror="true">
       <arg line="-source-path ."/>
       <arg line="-doc-sources net/systemeD/"/>
@@ -89,6 +92,8 @@
       <arg line="-package net.systemeD.potlatch2.utils 'Data loading utilities'" />
       
       <arg line="-left-frameset-width 300" />
+      <arg line="-locale=${locales.list}" />
+      <arg line="-allow-source-path-overlap true" />
     </exec>
   </target>
 
     </sequential>
   </macrodef>
 
-  <target name="buildLocales">
-    <echo>Building Localization .swf's</echo>
-    <compileLocale locale="en_US" />
-    <compileLocale locale="en_GB" />
-    <compileLocale locale="fr_FR" />
-    <compileLocale locale="de_DE" />
-    <compileLocale locale="pl_PL" />
+  <target name="makeLocalesList">
+    <ac:for param="dirname">
+      <path>
+        <dirset dir="${basedir}/l10n/locale/">
+          <exclude name="bundles"/>
+          <include name="??_??"/>
+        </dirset>
+      </path>
+      <sequential>
+        <ac:var name="localename" unset="true"/>
+        <basename property="localename" file="@{dirname}" />
+        <script language="javascript"><![CDATA[
+            if ((l = project.getProperty("locales.list")) != null) {
+               project.setUserProperty("locales.list", l+ "," +project.getProperty("localename"));
+            } else {
+               project.setUserProperty("locales.list", project.getProperty("localename"));
+            }
+        ]]></script>
+      </sequential>
+    </ac:for>
   </target>
 
+  <target name="buildLocales" depends="makeLocalesList">
+    <echo>Building Localization .swf's</echo>
+    <ac:for list="${locales.list}" keepgoing="true" param="localename">
+      <sequential>
+        <compileLocale locale="@{localename}" />
+      </sequential>
+    </ac:for>
+  </target>
 
   <target name="deployLocales" depends="buildLocales">
     <echo>Deploying the compiled swf and assets package for the given locales</echo>
-    <deployLocale locale="en_US" />
-    <deployLocale locale="en_GB" />
-    <deployLocale locale="fr_FR" />
-    <deployLocale locale="de_DE" />
-    <deployLocale locale="pl_PL" />
+    <ac:for list="${locales.list}" keepgoing="true" param="localename">
+      <sequential>
+        <deployLocale locale="@{localename}" />
+      </sequential>
+    </ac:for>
   </target>
 
 
diff --git a/lib/ant-contrib-1.0b3.jar b/lib/ant-contrib-1.0b3.jar
new file mode 100644 (file)
index 0000000..a7cd45b
Binary files /dev/null and b/lib/ant-contrib-1.0b3.jar differ