Build: Compile resource bundles from ant, not msgfmt,

speeding up builds with translations by 20x
This commit is contained in:
zzz
2016-05-01 20:19:56 +00:00
parent 2fe1f97ee0
commit 33629d0744
17 changed files with 168 additions and 41 deletions

View File

@ -6,7 +6,7 @@
<property name="dist" location="dist"/> <property name="dist" location="dist"/>
<property name="jar" value="desktopgui.jar"/> <property name="jar" value="desktopgui.jar"/>
<property name="resources" value="resources"/> <property name="resources" value="resources"/>
<property name="javadoc" value="javadoc"/> <property name="javadoc" value="javadoc"/>
<property name="javac.compilerargs" value=""/> <property name="javac.compilerargs" value=""/>
<property name="javac.version" value="1.6" /> <property name="javac.version" value="1.6" />
<property name="require.gettext" value="true" /> <property name="require.gettext" value="true" />
@ -17,9 +17,7 @@
<target name="init"> <target name="init">
<mkdir dir="${build}"/> <mkdir dir="${build}"/>
<mkdir dir="${build}/${resources}"/> <mkdir dir="${dist}"/>
<mkdir dir="${build}/${javadoc}"/>
<mkdir dir="${dist}"/>
</target> </target>
<target name="clean"> <target name="clean">
@ -27,35 +25,39 @@
<delete dir="${dist}"/> <delete dir="${dist}"/>
</target> </target>
<target name="compile" depends="init"> <target name="compile" depends="init">
<javac debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" <javac debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
includeAntRuntime="false" includeAntRuntime="false"
srcdir="${src}" destdir="${build}"> srcdir="${src}" destdir="${build}">
<compilerarg line="${javac.compilerargs}" /> <compilerarg line="${javac.compilerargs}" />
<classpath> <classpath>
<pathelement location="../../core/java/build/i2p.jar" /> <pathelement location="../../core/java/build/i2p.jar" />
<pathelement location="../../installer/lib/wrapper/all/wrapper.jar" /> <pathelement location="../../installer/lib/wrapper/all/wrapper.jar" />
<pathelement location="../../router/java/build/router.jar" /> <pathelement location="../../router/java/build/router.jar" />
</classpath> </classpath>
</javac> </javac>
<copy todir="${build}/desktopgui/${resources}"> <copy todir="${build}/desktopgui/${resources}">
<fileset dir="${resources}" /> <fileset dir="${resources}" />
</copy> </copy>
</target> </target>
<target name="bundle" unless="no.bundle"> <target name="bundle" unless="no.bundle">
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" > <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
<env key="JAVA_HOME" value="${java.home}" /> <env key="JAVA_HOME" value="${java.home}" />
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" > <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<!-- multi-lang is optional --> <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <arg value="./bundle-messages.sh" />
<arg value="./bundle-messages.sh" /> </exec>
</exec> <javac source="${javac.version}" target="${javac.version}"
</target> includeAntRuntime="false"
srcdir="${build}/messages-src" destdir="${build}">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target>
<target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" > <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
<exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" > <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
@ -74,7 +76,7 @@
<target name="jar" depends="compile, bundle, listChangedFiles" unless="jar.uptodate" > <target name="jar" depends="compile, bundle, listChangedFiles" unless="jar.uptodate" >
<!-- set if unset --> <!-- set if unset -->
<property name="workspace.changes.tr" value="" /> <property name="workspace.changes.tr" value="" />
<jar basedir="${build}" destfile="${dist}/${jar}"> <jar basedir="${build}" excludes="messages-src/**" destfile="${dist}/${jar}">
<manifest> <manifest>
<attribute name="Main-Class" value="net.i2p.desktopgui.Main"/> <attribute name="Main-Class" value="net.i2p.desktopgui.Main"/>
<attribute name="Build-Date" value="${build.timestamp}" /> <attribute name="Build-Date" value="${build.timestamp}" />

View File

@ -106,7 +106,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build # convert to class files in build
msgfmt --java --statistics -r $CLASS -l $LG -d build $i TD=build/messages-src-tmp
TDX=$TD/net/i2p/desktopgui
TD2=build/messages-src
TDY=$TD2/net/i2p/desktopgui
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -115,6 +121,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -150,6 +150,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-src" destdir="build/obj">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="poupdate" depends="builddep, compile"> <target name="poupdate" depends="builddep, compile">

View File

@ -97,7 +97,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i TD=build/messages-src-tmp
TDX=$TD/org/klomp/snark/web
TD2=build/messages-src
TDY=$TD2/org/klomp/snark/web
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -106,6 +112,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -136,6 +136,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-src" destdir="../jsp/WEB-INF/classes">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="poupdate" depends="compile, precompilejsp"> <target name="poupdate" depends="compile, precompilejsp">
@ -169,6 +174,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages-proxy.sh" /> <arg value="./bundle-messages-proxy.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-proxy-src" destdir="build/obj">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="extractProxyTags"> <target name="extractProxyTags">

View File

@ -99,7 +99,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i TD=build/messages-proxy-src-tmp
TDX=$TD/net/i2p/i2ptunnel/proxy
TD2=build/messages-proxy-src
TDY=$TD2/net/i2p/i2ptunnel/proxy
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -108,6 +114,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -98,7 +98,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d ../jsp/WEB-INF/classes $i TD=build/messages-src-tmp
TDX=$TD/net/i2p/i2ptunnel/web
TD2=build/messages-src
TDY=$TD2/net/i2p/i2ptunnel/web
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -107,6 +113,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -110,6 +110,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-src" destdir="build/obj">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="poupdate" depends="builddep, compile"> <target name="poupdate" depends="builddep, compile">

View File

@ -97,7 +97,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i TD=build/messages-src-tmp
TDX=$TD/net/i2p/client/streaming
TD2=build/messages-src
TDY=$TD2/net/i2p/client/streaming
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -106,6 +112,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -158,6 +158,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-src" destdir="build/obj">
<compilerarg line="${javac.compilerargs}" />
</javac>
<!-- jar again to get the latest messages_*.class files --> <!-- jar again to get the latest messages_*.class files -->
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" /> <jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
</target> </target>
@ -204,6 +209,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages-news.sh" /> <arg value="./bundle-messages-news.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-news-src" destdir="build/obj">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="bundle-countries" unless="no.bundle"> <target name="bundle-countries" unless="no.bundle">
@ -217,6 +227,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages-countries.sh" /> <arg value="./bundle-messages-countries.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-countries-src" destdir="build/obj">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="extractProxyTags"> <target name="extractProxyTags">

View File

@ -113,7 +113,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i TD=build/messages-countries-src-tmp
TDX=$TD/net/i2p/router/countries
TD2=build/messages-countries-src
TDY=$TD2/net/i2p/router/countries
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -122,6 +128,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -99,7 +99,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i TD=build/messages-news-src-tmp
TDX=$TD/net/i2p/router/news
TD2=build/messages-news-src
TDY=$TD2/net/i2p/router/news
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -108,6 +114,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -126,7 +126,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i TD=build/messages-src-tmp
TDX=$TD/net/i2p/router/web
TD2=build/messages-src
TDY=$TD2/net/i2p/router/web
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -135,6 +141,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -149,6 +149,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-src" destdir="${bin}">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="poupdate" depends="compile, precompilejsp"> <target name="poupdate" depends="compile, precompilejsp">
@ -171,7 +176,7 @@
<delete file="susidns.war" /> <delete file="susidns.war" />
<delete> <delete>
<fileset dir="." includes="**/*.class" /> <fileset dir="." includes="**/*.class" />
<fileset dir="." includes="tmp" /> <fileset dir="." includes="tmp, build" />
<fileset dir="WEB-INF" includes="web-fragment.xml, web-out.xml" /> <fileset dir="WEB-INF" includes="web-fragment.xml, web-out.xml" />
</delete> </delete>
<delete dir="${bin}" /> <delete dir="${bin}" />

View File

@ -99,7 +99,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d WEB-INF/classes $i TD=build/messages-src-tmp
TDX=$TD/i2p/susi/dns
TD2=build/messages-src
TDY=$TD2/i2p/susi/dns
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -108,6 +114,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE

View File

@ -113,6 +113,11 @@
<exec executable="sh" osfamily="windows" failifexecutionfails="false" > <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" /> <arg value="./bundle-messages.sh" />
</exec> </exec>
<javac source="${javac.version}" target="${javac.version}"
includeAntRuntime="false"
srcdir="build/messages-src" destdir="src/WEB-INF/classes">
<compilerarg line="${javac.compilerargs}" />
</javac>
</target> </target>
<target name="poupdate" depends="builddep, compile"> <target name="poupdate" depends="builddep, compile">

View File

@ -97,7 +97,13 @@ do
echo "Generating ${CLASS}_$LG ResourceBundle..." echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj # convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d src/WEB-INF/classes $i TD=build/messages-src-tmp
TDX=$TD/i2p/susi/webmail
TD2=build/messages-src
TDY=$TD2/i2p/susi/webmail
rm -rf $TD
mkdir -p $TD $TDY
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "ERROR - msgfmt failed on ${i}, not updating translations" echo "ERROR - msgfmt failed on ${i}, not updating translations"
@ -106,6 +112,8 @@ do
RC=1 RC=1
break break
fi fi
mv $TDX/messages_$LG.java $TDY
rm -rf $TD
fi fi
done done
rm -f $TMPFILE rm -f $TMPFILE