Add ivy.xml creation

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/common/trunk@503739 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index fc5fceb..3f55f88 100644
--- a/build.xml
+++ b/build.xml
@@ -231,6 +231,7 @@
 
   <dirname property="common.basedir" file="${ant.file.common}"/>
   <import file="${common.basedir}/m2.xml"/>
+  <import file="${common.basedir}/ivy.xml"/>
 
   <target name="src-dist" depends="m2-pom"
     description="--> creates a source distribution">
diff --git a/ivy.xml b/ivy.xml
new file mode 100644
index 0000000..08f7422
--- /dev/null
+++ b/ivy.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project name="ivy">
+  <description>Targets for ivy.xml creation/handling</description>
+
+  <!-- ========================================================== -->
+  <!-- init all the Ivy support   -->
+  <!-- ========================================================== -->
+  <target name="ivy-init"
+          depends="setup">
+    <property name="ivy.organization" value="apache"/>
+    <property name="target.ivy.xml"
+              location="${build.lib}/${artifact.stub}-ivy.xml"/>
+    <tstamp>
+      <format property="publication.datetime" pattern="yyyyMMddHHmmss"/>
+    </tstamp> 
+
+    <!--look for a template Ivy file -->
+    <property name="project.ivy.xml" location="project-template.ivy.xml"/>
+    <available property="project.has-ivy.xml?" file="${project.ivy.xml}"/>
+  </target>
+
+  
+  <!-- ========================================================== -->
+  <!-- ivy.xml creation/copy, depending on whether it exists or not   -->
+  <!-- ========================================================== -->
+
+  <!--copy an existing template-->
+  <target name="copy-ivy.xml" depends="ivy-init" if="project.has-ivy.xml?">
+    <copy file="${project.ivy.xml}" tofile="${target.ivy.xml}">
+      <!-- we expand ant properties here.  -->
+      <filterchain>
+        <expandproperties/>
+      </filterchain>
+    </copy>
+  </target>
+
+
+  <!-- inline creation of a zero dependency ivy.xml.
+    We don't even declare a dependency on ant!
+  -->
+  <target name="make-ivy.xml" depends="ivy-init" unless="project.has-ivy.xml?">
+    <echo message="Creating ivy.xml ${target.ivy.xml}" level="verbose"/>
+    <echoxml file="${target.ivy.xml}">
+      <ivy-module version="1.3">
+        <info organization="${ivy.organization}"
+          module="${artifact.name}"
+          revision="${artifact.version}"
+          publication="${publication.datetime}">
+          <license name="Apache Software License 2.0"
+            url="http://www.apache.org/licenses/LICENSE-2.0"/>
+          <ivy-author name="Apache Ant Development Team"
+            url="http://ant.apache.org/"/>
+        </info>
+      </ivy-module>
+    </echoxml>
+  </target>
+
+  <target name="ivy.xml" depends="copy-ivy.xml,make-ivy.xml">
+    <checksum file="${target.ivy.xml}" algorithm="md5"/>
+    <checksum file="${target.ivy.xml}" algorithm="sha1"/>
+  </target>
+
+</project>
\ No newline at end of file