Permalink
Browse files

Added Ant classpath from Gradle to Ant and Ant to Gradle examples

  • Loading branch information...
1 parent fcae6b9 commit ea4e45a9f225cc614d6c62dc9f999454f184431a @matthewmccullough matthewmccullough committed May 25, 2011
@@ -0,0 +1,30 @@
+ant.importBuild 'build.xml'
+
+defaultTasks = ['gradleBuild']
+
+////////////////////////////////////////////////////////////////////////
+// Gradle paths retrieved from Ant and then built using a Gradle task
+repositories {
+ flatDir name: 'localRepository1', dirs: ant.references['antPathToLibs1']
+ flatDir name: 'localRepository2', dirs: ant.references.antPathToLibs2
+ flatDir name: 'localRepository3', dirs: "antlibs"
+}
+
+task gradleBuild << {
+ //Set classpath to include the JAR
+ println "The repositories bridged from Ant to Gradle are:"
+ println repositories*.name
+
+ println repositories.localRepository1
+
+ println repositories['localRepository2']
+
+ println "localRepository3 class = " + repositories.localRepository3.class
+ println "localRepository3 name = " + repositories.localRepository3.name
+ println "localRepository3 latest = " + repositories.localRepository3.latest
+ println "localRepository3 ivyPatterns = " + repositories.localRepository3.ivyPatterns
+ println "localRepository3 artifactPatterns = " + repositories.localRepository3.artifactPatterns
+ println "localRepository3 checkconsistency = " + repositories.localRepository3.checkconsistency
+ println "localRepository3 m2compatible = " + repositories.localRepository3.m2compatible
+ println "localRepository3 methods = " + repositories.localRepository3.metaClass.methods*.name.sort().unique()
+}
@@ -0,0 +1,5 @@
+<project>
+ <!-- Classpath created by Ant, then used by Gradle -->
+ <path id="antPathToLibs1" location="antlibs"/>
+ <path id="antPathToLibs2" location="antlibs"/>
+</project>
@@ -0,0 +1,2 @@
+#!/bin/bash
+gradle
@@ -0,0 +1,21 @@
+ant.importBuild 'build.xml'
+
+defaultTasks = ['antBuild']
+
+////////////////////////////////////////////////////////////////////////
+// Ant paths injected by Gradle and then built using an Ant goal
+task antPathsInjectedByGradle << {
+ ant.path(id: 'gradlePathToLibs1', location: 'gradlelibs')
+ // or
+ ant.references.gradlePathToLibs2 = ant.path(location: 'gradlelibs')
+ // or
+ ant.references['gradlePathToLibs3'] = ant.path(location: file('gradlelibs').absolutePath)
+
+ println "This task injects Gradle paths into the AntBuilder"
+}
+
+antBuild.doLast {
+ // No antBuild Task needs to be explicitly constructed
+ // antBuild task is created by the build.xml import
+ println "This Ant goal was converted to a Gradle task by the ant.importBuild call"
+}
@@ -0,0 +1,19 @@
+<project>
+ <!-- Classpath created by Gradle, then used by Ant -->
+ <path refid="gradlePathToLibs1"/>
+ <path refid="gradlePathToLibs2"/>
+ <path refid="gradlePathToLibs3"/>
+
+ <!-- Echo one of the gradle paths injected into the Ant build -->
+ <target name="antBuild" depends="antPathsInjectedByGradle">
+ <property name="gradlePathToLibs1AsProperty" refid="gradlePathToLibs1"/>
+ <echo message="gradlePathToLibs1 = ${gradlePathToLibs1AsProperty}"/>
+
+ <property name="gradlePathToLibs2AsProperty" refid="gradlePathToLibs2"/>
+ <echo message="gradlePathToLibs2 = ${gradlePathToLibs2AsProperty}"/>
+
+ <property name="gradlePathToLibs3AsProperty" refid="gradlePathToLibs3"/>
+ <echo message="gradlePathToLibs3 = ${gradlePathToLibs3AsProperty}"/>
+
+ </target>
+</project>
Binary file not shown.
@@ -0,0 +1,2 @@
+#!/bin/bash
+gradle

0 comments on commit ea4e45a

Please sign in to comment.