From 84c95fbbd2858471b79c6c7e085aeb7db9b53106 Mon Sep 17 00:00:00 2001
From: Daniel Stonier <d.stonier@gmail.com>
Date: Thu, 31 Oct 2013 16:20:29 +0900
Subject: [PATCH] bugfix catkin tree generator, always take latest version of a
 package.

---
 .../groovy/org/ros/gradle_plugins/CatkinPlugin.groovy  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/CatkinPlugin.groovy b/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/CatkinPlugin.groovy
index dca1678..c4fe340 100644
--- a/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/CatkinPlugin.groovy
+++ b/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/CatkinPlugin.groovy
@@ -86,12 +86,18 @@ class CatkinPackages {
     
     def generate() {
         if ( this.pkgs.size() == 0 ) {
-            println("Catkin plugin is generating the catkin package tree...")
             this.workspaces.each { workspace ->
                 def manifestTree = project.fileTree(dir: workspace, include: '**/package.xml')
                 manifestTree.each { file -> 
                     def pkg = new CatkinPackage(file)
-                    this.pkgs.put(pkg.name, pkg)
+                    if(this.pkgs.containsKey(pkg.name)) {
+                        if(this.pkgs[pkg.name].version < pkg.version) {
+                            println("Catkin generate tree: replacing older version of " + pkg.name + "[" + this.pkgs[pkg.name].version + "->" + pkg.version + "]") 
+                            this.pkgs[pkg.name] = pkg
+                        }
+                    } else {
+                        this.pkgs.put(pkg.name, pkg)
+                    }
                 }
             }
         }
-- 
GitLab