Reviewers: Jasvir, metaweta, Description: If you start with up-to-date trunk, do 'ant runserver', then make some edits, then do 'ant runserver' again, you can end up with a build where some files think the Caja version is '999' and other files think the version is '999m', so nothing works.
There are three ways that svnversion is baked into the caja build: 1. ant target build.info always rewrites buildInfo.properties, which is where the java code reads version from. This tracks svnversion fine. 2. ant rule <transform> will cajole js and embed the buildInfo version in the generated js output. This doesn't track svnversion, because there's no way to tell <transform> to compare svnversion against the existing output. 3. some ant targets do <replace> of "%VERSION%" on js files like caja.js. This gets re-run all the time, but it doesn't track svnversion either, because the substitutions happen in-place in ant-lib. Once the substitution happens once, the version string never changes again, unless the source file changes and forces it to be re-copied first. Since it's messy in general to check if some arbitrary generated file is up-to-date with respect to svnversion, instead I've added an early rule that will delete all target js files if svnversion changes. Please review this at http://codereview.appspot.com/5716047/ Affected files: M build.xml Index: build.xml =================================================================== --- build.xml (revision 4797) +++ build.xml (working copy) @@ -1051,15 +1051,38 @@ </copy> </target> - <target name="build.info"> - <tstamp> - <format property="build.timestamp" pattern="yyyy-MM-dd HH:mm:ss"/> - </tstamp> + <target name="Version.set"> + <loadfile + property="Version.old" + srcFile="${lib.caja}/reporting/Version" + failonerror="false"> + <filterchain><striplinebreaks/></filterchain> + </loadfile> <exec outputproperty="build.svnVersion" executable="tools/svnversion-nocolon" failonerror="false" failifexecutionfails="false" dir="."/> + <condition property="Version.changed"> + <not><equals arg1="${build.svnVersion}" arg2="${Version.old}"/></not> + </condition> + </target> + + <target name="Version.update" depends="Version.set" if="Version.changed"> + <!-- When svnversion changes, we need to recajole js and + re-replace %VERSION%, so here we just nuke all target js --> + <delete> + <fileset dir="${lib}" includes="**/*.js"/> + <fileset dir="${precajolelib}" includes="**/*.js"/> + </delete> + <echo append="false" file="${lib.caja}/reporting/Version" + message="${build.svnVersion}"/> + </target> + + <target name="build.info" depends="Version.update"> + <tstamp> + <format property="build.timestamp" pattern="yyyy-MM-dd HH:mm:ss"/> + </tstamp> <echo append="false" file="${lib.caja}/reporting/buildInfo.properties" message="# Caja Build Information${line.separator}"/> <echo append="true" file="${lib.caja}/reporting/buildInfo.properties"
