Improved the makeStaging task in order to get latest available versions from the release repo.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1717524 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/release/build.gradle b/dependencymanager/release/build.gradle
index be8e65c..a59dc3c 100644
--- a/dependencymanager/release/build.gradle
+++ b/dependencymanager/release/build.gradle
@@ -106,18 +106,35 @@
     }
 
     // Package binaries as a simple collection of bundles. We use same license files as for src distrib.
-    logger.lifecycle("    Packaging binary distribution.")    
+    logger.lifecycle("    Packaging binary distribution.")
+
+    // First, get list of latest released bundles available from our Release repository
+    def released = []
+    def releaseRepo = workspace.getRepository("Release")
+    logger.lifecycle("releaserepo=" + releaseRepo)
+    def bundles=releaseRepo.list(null)
+    bundles.each {
+	    def sortedVersions = releaseRepo.versions(it)
+	    def latestVersion = sortedVersions.last()
+	    def latestBundle = releaseRepo.get(it, latestVersion, null)
+	    released << latestBundle
+    }
+
+    // Now, add all the latest released bundles in the binary distribution
     ant.zip(destfile: "staging/"+topdir+"-bin.zip") {
-        ant.mappedresources() {
-            // simply include all released bundle.
-        	ant.fileset(dir: '..', includes: 'cnf/releaserepo/*/*.jar')
-            ant.chainedmapper() {
-                ant.flattenmapper()
-                ant.globmapper(from: '*', to: topdir+'-bin/*')
+        // simply include all released bundle.
+        released.each {
+	    file=it
+            ant.mappedresources() {
+        	ant.filelist(files: file)
+                ant.chainedmapper() {
+                    ant.flattenmapper()
+                    ant.globmapper(from: '*', to: topdir+'-bin/*')
+                }
             }
         }
         ant.mappedresources() {
-        	ant.fileset(dir: 'resources/bin', includes: '*')
+            ant.fileset(dir: 'resources/bin', includes: '*')
             ant.chainedmapper() {
                 ant.flattenmapper()
                 ant.globmapper(from: '*', to: topdir+'-bin/*')