Support for Maven changes-plugin like changes.xml

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/common/trunk@465982 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index 770a6e1..2216f4a 100644
--- a/build.xml
+++ b/build.xml
@@ -284,7 +284,7 @@
         <include name="INSTALL"/>
         <include name="NOTICE"/>
         <include name="TODO"/>
-        <include name="WHATSNEW"/>
+        <include name="changes.xml"/>
         <include name="contributors.xml"/>
         <include name="build.xml"/>
         <include name="version.properties"/>
@@ -304,8 +304,9 @@
       <include name="**/*.java"/>
     </fixcrlf>
 
-    <xslt style="common/contributors.xsl" in="contributors.xml"
-      out="${src.dist.dir}/CONTRIBUTORS"/>
+    <antcall target="create-readable-documents">
+      <param name="dest.dir" value="${src.dist.dir}"/>
+    </antcall>
   </target>
 
   <target name="bin-dist" depends="checksum-target-jar,m2-pom">
@@ -318,7 +319,7 @@
         <include name="INSTALL"/>
         <include name="NOTICE"/>
         <include name="TODO"/>
-        <include name="WHATSNEW"/>
+        <include name="changes.xml"/>
         <include name="contributors.xml"/>
       </fileset>
       <fileset dir="common">
@@ -333,8 +334,9 @@
         <exclude name="etc/testcases/"/>
       </fileset>
     </copy>
-    <xslt style="common/contributors.xsl" in="contributors.xml"
-      out="${bin.dist.dir}/CONTRIBUTORS"/>
+    <antcall target="create-readable-documents">
+      <param name="dest.dir" value="${bin.dist.dir}"/>
+    </antcall>
   </target>
 
   <target name="distribution" description="creates a complete distribution"
@@ -445,4 +447,31 @@
       </fileset>
     </checksum>
   </target>
+
+  <target name="check-contributors">
+    <available property="contributors.file.exists?"
+      file="contributors.xml"/>
+  </target>
+
+  <target name="check-changes">
+    <available property="changes.file.exists?"
+      file="changes.xml"/>
+  </target>
+
+  <target name="style-contributors" depends="check-contributors"
+    if="contributors.file.exists?">
+    <xslt style="common/stylesheets/contributors.xsl" in="contributors.xml"
+      out="${dest.dir}/CONTRIBUTORS"/>
+  </target>
+
+  <target name="style-changes" depends="check-changes"
+    if="changes.file.exists?">
+    <xslt style="common/stylesheets/changes2whatsnew.xsl" in="changes.xml"
+      out="${dest.dir}/WHATSNEW"/>
+    <xslt style="common/stylesheets/changes2readmehtml.xsl" in="changes.xml"
+      out="${dest.dir}/README.html"/>
+  </target>
+
+  <target name="create-readable-documents"
+    depends="style-contributors,style-changes"/>
 </project>
diff --git a/stylesheets/changes2readmehtml.xsl b/stylesheets/changes2readmehtml.xsl
new file mode 100644
index 0000000..f33502d
--- /dev/null
+++ b/stylesheets/changes2readmehtml.xsl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+  <xsl:output method="html" indent="yes"/>
+
+  <xsl:template match="/document/release[1]">
+    <body>
+      <h1>
+        <xsl:text>Changes in </xsl:text>
+        <xsl:value-of select="@version"/>
+      </h1>
+      <h2>
+        <xsl:text>Changes that Could Break Older Environments:</xsl:text>
+      </h2>
+      <ul>
+        <xsl:apply-templates select="./action[@breaks-bwc='true']" mode="li"/>
+      </ul>
+      <h2>
+        <xsl:text>Fixed Bugs:</xsl:text>
+      </h2>
+      <ul>
+        <xsl:apply-templates select="./action[@type='fix']" mode="li"/>
+      </ul>
+      <h2>
+        <xsl:text>Other Changes:</xsl:text>
+      </h2>
+      <ul>
+        <xsl:apply-templates select="./action[not(@type='fix')]" mode="li"/>
+      </ul>
+    </body>
+  </xsl:template>
+
+  <xsl:template match="action" mode="li">
+    <li>
+      <xsl:value-of select="text()"/>
+      <xsl:if test="not(@issue='')">
+        <a>
+          <xsl:attribute name="href">http://issues.apache.org/bugzilla/show_bug.cgi?id=<xsl:value-of select="@issue"/></xsl:attribute>
+          <xsl:text>BugZilla Issue </xsl:text><xsl:value-of select="@issue"/><xsl:text></xsl:text>
+        </a>
+      </xsl:if>
+    </li>
+  </xsl:template>
+
+  <!-- dont copy the text and unmatched nodes as per default in xsl -->
+  <xsl:template match="text()"/>
+
+</xsl:stylesheet>
diff --git a/stylesheets/changes2whatsnew.xsl b/stylesheets/changes2whatsnew.xsl
new file mode 100644
index 0000000..a7c7930
--- /dev/null
+++ b/stylesheets/changes2whatsnew.xsl
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+  <xsl:output method="text" indent="no"/>
+
+  <xsl:template match="release">
+    <xsl:text>Changes in </xsl:text>
+    <xsl:value-of select="@version"/>
+    <xsl:text>
+</xsl:text>
+    <xsl:text>==============================================
+
+</xsl:text>
+    <xsl:text>Changes that Could Break Older Environments:
+--------------------------------------------
+
+</xsl:text>
+
+    <xsl:apply-templates select="./action[@breaks-bwc='true']" mode="li"/>
+
+    <xsl:text>Fixed Bugs:
+-----------
+
+</xsl:text>
+
+    <xsl:apply-templates select="./action[@type='fix' and not(@breaks-bwc='true')]" mode="li"/>
+
+    <xsl:text>Other Changes:
+--------------
+
+</xsl:text>
+
+    <xsl:apply-templates select="./action[not(@type='fix') and not(@breaks-bwc='true')]" mode="li"/>
+    <xsl:text>
+</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="action" mode="li">
+    <xsl:value-of select="text()"/>
+    <xsl:if test="not(@issue='')">
+      <xsl:text>
+        BugZilla Issue </xsl:text><xsl:value-of select="@issue"/><xsl:text>
+
+</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- dont copy the text and unmatched nodes as per default in xsl -->
+  <xsl:template match="text()"/>
+
+</xsl:stylesheet>
diff --git a/contributors.xsl b/stylesheets/contributors.xsl
similarity index 100%
rename from contributors.xsl
rename to stylesheets/contributors.xsl