tibant
changeset 403:e1584b1a6448
Fix for #114 - .designtimelibs file is overwritten even when there are no changes
| author | tomhoward |
|---|---|
| date | Wed Apr 18 17:10:48 2012 +1000 (14 months ago) |
| parents | 6ca3815bf992 |
| children | 3a42197e5c25 |
| files | src/ant/tibant.xml src/xslt/designtimelibs.xslt test/quick/dtl-file.xml |
line diff
1.1 --- a/src/ant/tibant.xml Tue Mar 06 07:47:56 2012 +1100 1.2 +++ b/src/ant/tibant.xml Wed Apr 18 17:10:48 2012 +1000 1.3 @@ -3287,10 +3287,11 @@ 1.4 <istrue value="@{create-dtl-file}" /> 1.5 <then> 1.6 <tibant:xslt in="@{working-dir}/@{aliases-refid}.xml" 1.7 - out="@{dir}/@{project}/.designtimelibs" 1.8 + out="@{working-dir}/@{aliases-refid}.designtimelibs" 1.9 style="${tibant.xslt}/designtimelibs.xslt" 1.10 taskname="@{taskname}"> 1.11 </tibant:xslt> 1.12 + <tibant:overwrite-if-diff src="@{working-dir}/@{aliases-refid}.designtimelibs" dest="@{dir}/@{project}/.designtimelibs" taskname="@{taskname}"/> 1.13 </then> 1.14 </if> 1.15 </sequential>
2.1 --- a/src/xslt/designtimelibs.xslt Tue Mar 06 07:47:56 2012 +1100 2.2 +++ b/src/xslt/designtimelibs.xslt Wed Apr 18 17:10:48 2012 +1000 2.3 @@ -10,9 +10,7 @@ 2.4 <xsl:template match="/"> 2.5 <xsl:text>#Design time libraries 2.6 #Format: #=File Alias=Description 2.7 -#</xsl:text> 2.8 - <xsl:value-of select="format-dateTime(current-dateTime(), '[F,*-3] [MNn,*-3] [D] [H01]:[m01]:[s01] [Z] [Y]')"/> 2.9 - <xsl:text> 2.10 +#NOTE: This is a generated file. Changes made here will be overwritten 2.11 </xsl:text> 2.12 <xsl:for-each select="properties/property[ends-with(@value,'.projlib')]"> 2.13 <xsl:message><xsl:value-of select="@name"/></xsl:message>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/quick/dtl-file.xml Wed Apr 18 17:10:48 2012 +1000 3.3 @@ -0,0 +1,79 @@ 3.4 +<?xml version="1.0" encoding="UTF-8"?> 3.5 +<project name="TIBant-test-dtl-file" 3.6 + basedir="../.." 3.7 + xmlns:au="antlib:org.apache.ant.antunit" 3.8 + xmlns="antlib:org.apache.tools.ant" 3.9 + xmlns:tibant="org.windyroad.tibant" 3.10 + default="test-dtl-file-not-modified"> 3.11 + 3.12 + <property name="tibant.home" location="${basedir}" /> 3.13 + <property name="tibant.xml" location="${tibant.home}/src/ant/tibant.xml" /> 3.14 + <property name="tibant.xslt" location="${tibant.home}/src/xslt" /> 3.15 + <property name="tibant.jar.dir" location="${tibant.home}/build" /> 3.16 + 3.17 + <import file="../../build.xml" /> 3.18 + 3.19 + 3.20 + <target name="test-dtl-file" depends="-load-ant-contrib,-load-antunit"> 3.21 + <!-- 3.22 + Given a project "build" at "." without a DTL file 3.23 + --> 3.24 + <delete file="build/.designtimelibs" /> 3.25 + 3.26 + <!-- 3.27 + And a propertyset "MyAliases" with the following properties: 3.28 + | MyAlias | foobar.projlib | 3.29 + | My2ndAlias | barfoo.projlib | 3.30 + --> 3.31 + <property name="MyAlias" location="foobar.projlib" /> 3.32 + <property name="My2ndAlias" location="barfoo.projlib" /> 3.33 + <propertyset id="MyAliases"> 3.34 + <propertyref name="MyAlias" /> 3.35 + <propertyref name="My2ndAlias" /> 3.36 + </propertyset> 3.37 + 3.38 + <!-- 3.39 + When a DTL file is created for "build" at "." with the aliases "MyAliases" 3.40 + --> 3.41 + <tibant:internal-create-dtl-file dir="." project="build" aliases-refid="MyAliases" create-dtl-file="true" /> 3.42 + 3.43 + <!-- 3.44 + Then "build/.designtimelibs" should contain: 3.45 + """0=My2ndAlias\= 3.46 + 1=\MyAlias\=""" 3.47 + --> 3.48 + <au:assertTrue message="dtl file not built"> 3.49 + <available file="build/.designtimelibs" /> 3.50 + </au:assertTrue> 3.51 + <echo file="build/expected-dtl-file">#Design time libraries 3.52 +#Format: #=File Alias=Description 3.53 +#NOTE: This is a generated file. Changes made here will be overwritten 3.54 +0=My2ndAlias\= 3.55 +1=MyAlias\= 3.56 +</echo> 3.57 + <au:assertFilesMatch expected="build/expected-dtl-file" actual="build/.designtimelibs" /> 3.58 + </target> 3.59 + 3.60 + <!-- 3.61 + Given a propertyset "MyAliases" with the following properties: 3.62 + | MyAlias | foobar.projlib | 3.63 + | My2ndAlias | barfoo.projlib | 3.64 + And a project "build" at "." with a DTL file with the aliases "MyAliases" 3.65 + --> 3.66 + <target name="test-dtl-file-not-modified" depends="test-dtl-file"> 3.67 + <!-- 3.68 + When a DTL file is created for "build" at "." with the aliases "MyAliases" 3.69 + --> 3.70 + <touch file="build/new-file" /> 3.71 + <tibant:internal-create-dtl-file dir="." project="build" aliases-refid="MyAliases" create-dtl-file="true" /> 3.72 + 3.73 + <!-- 3.74 + Then "build/.designtimelibs" should not be modified 3.75 + --> 3.76 + <au:assertDestIsUptodate message="dtl is newer than it should be" 3.77 + dest="build/new-file" 3.78 + src="build/.designtimelibs" /> 3.79 + </target> 3.80 + 3.81 + 3.82 +</project>
