extract common functionality

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/common/trunk@503745 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/common-tasks.xml b/common-tasks.xml
new file mode 100644
index 0000000..19d1979
--- /dev/null
+++ b/common-tasks.xml
@@ -0,0 +1,31 @@
+<?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="common-tasks">
+  <!-- copy that expands Ant properties -->
+  <presetdef name="expandingcopy">
+    <sequential>
+      <copy>
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+      </copy>
+    </sequential>
+  </presetdef>
+</project>
diff --git a/ivy.xml b/ivy.xml
index 08f7422..e3520fa 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -20,6 +20,9 @@
 <project name="ivy">
   <description>Targets for ivy.xml creation/handling</description>
 
+  <dirname property="common.basedir" file="${ant.file.ivy}"/>
+  <import file="${common.basedir}/common-tasks.xml"/>
+
   <!-- ========================================================== -->
   <!-- init all the Ivy support   -->
   <!-- ========================================================== -->
@@ -44,12 +47,7 @@
 
   <!--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>
+    <expandingcopy file="${project.ivy.xml}" tofile="${target.ivy.xml}"/>
   </target>
 
 
diff --git a/m2.xml b/m2.xml
index 7bef611..57473a5 100644
--- a/m2.xml
+++ b/m2.xml
@@ -20,6 +20,9 @@
 <project name="m2">
   <description>Targets for Maven2 POM creation/handling</description>
 
+  <dirname property="common.basedir" file="${ant.file.m2}"/>
+  <import file="${common.basedir}/common-tasks.xml"/>
+
   <!-- ========================================================== -->
   <!-- init all the maven2 support   -->
   <!-- ========================================================== -->
@@ -41,12 +44,7 @@
 
   <!--copy an existing template-->
   <target name="m2-copy-pom" depends="m2-init" if="project.haspom?">
-    <copy file="${project.pom}" tofile="${target.pom}">
-      <!-- we expand ant properties here.  -->
-      <filterchain>
-        <expandproperties/>
-      </filterchain>
-    </copy>
+    <expandingcopy file="${project.pom}" tofile="${target.pom}"/>
   </target>