Repository: ant-antlibs-common
Updated Branches:
  refs/heads/master e7dff170e -> 7f3df8da8


add Ivy-support for antlibs


Project: http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/commit/7f3df8da
Tree: http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/tree/7f3df8da
Diff: http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/diff/7f3df8da

Branch: refs/heads/master
Commit: 7f3df8da84431ac94bb61d9287978bc359b6ef43
Parents: e7dff17
Author: Jan Mat�rne <j...@apache.org>
Authored: Thu Jun 5 12:35:36 2014 +0200
Committer: Jan Mat�rne <j...@apache.org>
Committed: Thu Jun 5 12:35:36 2014 +0200

----------------------------------------------------------------------
 build.properties | 27 +++++++++++++++++++++++++++
 build.xml        | 25 +++++++++++++++++++------
 ivy.xml          | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 93 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/blob/7f3df8da/build.properties
----------------------------------------------------------------------
diff --git a/build.properties b/build.properties
new file mode 100644
index 0000000..676baf7
--- /dev/null
+++ b/build.properties
@@ -0,0 +1,27 @@
+#  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.
+
+
+# Common properties. Could be overwritten by the concrete antlib project.
+
+# Ivy installation. Which version to use, where to store.
+ivy.install.version=2.4.0-rc1
+ivy.jar.dir=${basedir}/ivy
+ivy.jar.file=${ivy.jar.dir}/ivy.jar
+
+# Where to store the dependencies
+lib.dir=lib
+lib.dir.compile=${lib.dir}/compile
+lib.dir.test=${lib.dir}/test

http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/blob/7f3df8da/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 5af8d26..ae3dede 100644
--- a/build.xml
+++ b/build.xml
@@ -15,16 +15,22 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<project name="common">
+<project name="common" xmlns:ivy="antlib:org.apache.ivy.ant">
 
   <dirname property="common.basedir" file="${ant.file.common}"/>
   <import file="${common.basedir}/common-tasks.xml"/>
+  
+  <available property="with.ivy" file="ivy.xml"/>
 
   <target name="setup-properties">
+    <!-- load antlib specific configuration -->
     <property file="build.properties"/>
     <!--load in an optional file containing versions of things-->
     <property file="version.properties"/>
     
+    <!-- load common configuration -->
+    <property file="${common.basedir}/build.properties"/>
+    
     <!--load in a file containing versions of ant
       and other libraries-->
     <property file="${ant.home}/lib/libraries.properties"/>
@@ -54,6 +60,10 @@
     <property name="artifact.stub" 
value="${artifact.name}-${artifact.version}"/>
     <property name="jarname" value="${build.lib}/${artifact.stub}.jar"/>
     <property name="target.jar" value="${jarname}"/>
+    
+    <tstamp>
+      <format property="artifact.publication.datetime" 
pattern="yyyyMMddHHmmss"/>
+    </tstamp>
 
     <!-- properties for distribution target -->
     <property name="dist.name"
@@ -90,7 +100,7 @@
   <target name="package" depends="checksum-target-jar"
        description="Package everything up"/>
 
-  <target name="compile" depends="setup">
+  <target name="compile" depends="setup,resolve">
     <javac 
       srcdir="src/main"
       destdir="${build.classes}"
@@ -98,6 +108,7 @@
       source="${javac.-source}"
       target="${javac.-target}"
       includeantruntime="true"
+      classpathref="classpath.compile"
       />
   </target>
 
@@ -163,7 +174,7 @@
     <fail unless="antunit-present?">The AntUnit Ant library is not 
present.</fail>
   </target>
 
-  <target name="compile-tests" depends="setup-for-junit-tests, antlib"
+  <target name="compile-tests" depends="setup-for-junit-tests, antlib, resolve"
     unless="skip-junit">
     <javac 
       srcdir="${src.junit}"
@@ -175,6 +186,7 @@
       <classpath>
         <pathelement location="${jarname}"/>
         <pathelement location="${ant-testutil.jar}"/>
+        <path refid="classpath.test"/>
       </classpath>
     </javac>
     <copy todir="${build.testclasses}">
@@ -182,7 +194,7 @@
     </copy>
   </target>
 
-  <target name="junit-test" depends="ready-to-test-with-junit"
+  <target name="junit-test" depends="ready-to-test-with-junit,resolve"
     unless="skip-junit">
     <mkdir dir="${junit.report.dir}"/>
     <junit
@@ -198,6 +210,7 @@
         <pathelement location="${jarname}"/>
         <pathelement location="${ant-testutil.jar}"/>
         <pathelement location="${build.testclasses}"/>
+        <path refid="classpath.test"/>
       </classpath>
 
       <batchtest todir="${junit.report.dir}">
@@ -209,7 +222,7 @@
     </junit>
   </target>
 
-  <target name="antunit-test" depends="ready-to-test-with-antunit"
+  <target name="antunit-test" depends="ready-to-test-with-antunit,resolve"
     unless="skip-antunit">
     <condition property="antunit.includes" value="${antunit.testcase}"
                else="**/test.xml,**/*-test.xml">
@@ -581,5 +594,5 @@
 
     <delete dir="${dist.name}"/>
   </target>
-
+  
 </project>

http://git-wip-us.apache.org/repos/asf/ant-antlibs-common/blob/7f3df8da/ivy.xml
----------------------------------------------------------------------
diff --git a/ivy.xml b/ivy.xml
index b24b651..f3ab47a 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -17,7 +17,7 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project name="ivy">
+<project name="ivy" xmlns:ivy="antlib:org.apache.ivy.ant">
   <description>Targets for ivy.xml creation/handling</description>
 
   <dirname property="common.basedir" file="${ant.file.ivy}"/>
@@ -111,5 +111,51 @@
       <file file="${target.ivy.xml}"/>
     </checksums>
   </target>
+ 
+
+  <!-- ========================================================== -->
+  <!-- Bootstraping Ivy as in 
http://ant.apache.org/ivy/history/latest-milestone/samples/build.xml -->
+  <!-- ========================================================== -->
+
+  
+  <target name="download-ivy" if="with.ivy" depends="setup-properties">
+    <mkdir dir="${ivy.jar.dir}"/>
+    <!-- download Ivy from web site so that it can be used even without any 
special installation -->
+    <echo message="installing ivy..."/>
+    <get 
src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar";
 dest="${ivy.jar.file}" usetimestamp="true"/>
+  </target>
+  
+  <!-- ================================= 
+    target: install-ivy         
+    this target is not necessary if you put ivy.jar in your ant lib directory
+    if you already have ivy in your ant lib, you can simply remove this
+    target and the dependency the 'go' target has on it
+  ================================= -->
+  <target name="install-ivy" if="with.ivy" depends="download-ivy" 
description="--> install ivy">
+    <!-- try to load ivy here from local ivy dir, in case the user has not 
already dropped
+    it into ant's lib dir (note that the latter copy will always take 
precedence).
+    We will not fail as long as local lib dir exists (it may be empty) and
+    ivy is in at least one of ant's lib dir or the local lib dir. -->
+    <path id="ivy.lib.path">
+      <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
+    </path>
+    <taskdef resource="org/apache/ivy/ant/antlib.xml" 
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
+  </target>
+  
+
+  <!-- ========================================================== -->
+  <!-- Standard Ivy targets   -->
+  <!-- ========================================================== -->
+
+  <target name="resolve" depends="install-ivy" if="with.ivy" 
unless="no.resolve">
+    <ivy:resolve file="ivy.xml"/>    
+    <ivy:retrieve conf="default" pattern="${lib.dir.compile}/[artifact].[ext]" 
sync="yes"/>
+    <ivy:retrieve conf="test" pattern="${lib.dir.test}/[artifact].[ext]" 
sync="yes"/>
+    <ivy:cachepath pathid="classpath.compile" conf="default"/>
+    <ivy:cachepath pathid="classpath.test" conf="default,test"/>
+  </target>
+
+    
 
 </project>
+ 
\ No newline at end of file

Reply via email to