From 3d4a057d8b04be836d64042004716961fea2e64b Mon Sep 17 00:00:00 2001
From: Daniel Stonier <d.stonier@gmail.com>
Date: Tue, 29 Oct 2013 21:46:43 +0900
Subject: [PATCH] use ROS_MAVEN_REPOSITORY

---
 env-hooks/15.rosjava.bash.em                         |  1 +
 env-hooks/15.rosjava.sh.em                           |  1 +
 generate_environment_variables.py                    |  6 ++++++
 .../templates/android_package/build.gradle.in        |  5 +++--
 .../templates/android_project/build.gradle.in        | 10 +++++-----
 .../templates/rosjava_package/build.gradle.in        |  5 +++--
 .../templates/rosjava_project/build.gradle.in        | 12 ++++++------
 7 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/env-hooks/15.rosjava.bash.em b/env-hooks/15.rosjava.bash.em
index b950c1e..5edcc4b 100644
--- a/env-hooks/15.rosjava.bash.em
+++ b/env-hooks/15.rosjava.bash.em
@@ -8,3 +8,4 @@ SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_va
 
 export ROS_MAVEN_PATH=`python ${SCRIPT} --maven-path`
 export ROS_MAVEN_DEPLOYMENT_REPOSITORY=`python ${SCRIPT} --maven-deployment-repository`
+export ROS_MAVEN_REPOSITORY=`python ${SCRIPT} --maven-repository`
diff --git a/env-hooks/15.rosjava.sh.em b/env-hooks/15.rosjava.sh.em
index 9e91c76..62cc858 100644
--- a/env-hooks/15.rosjava.sh.em
+++ b/env-hooks/15.rosjava.sh.em
@@ -8,3 +8,4 @@ SCRIPT=@(CMAKE_INSTALL_PREFIX)/share/rosjava_build_tools/generate_environment_va
 
 export ROS_MAVEN_PATH=`python ${SCRIPT} --maven-path`
 export ROS_MAVEN_DEPLOYMENT_REPOSITORY=`python ${SCRIPT} --maven-deployment-repository`
+export ROS_MAVEN_REPOSITORY=`python ${SCRIPT} --maven-repository`
diff --git a/generate_environment_variables.py b/generate_environment_variables.py
index 6fb7f0d..87581df 100755
--- a/generate_environment_variables.py
+++ b/generate_environment_variables.py
@@ -9,6 +9,7 @@ def parse_arguments():
     parser = argparse.ArgumentParser(description='Generate environment variables for the rosjava maven environment.')
     cmd_group = parser.add_mutually_exclusive_group()
     cmd_group.add_argument('-d', '--maven-deployment-repository', action='store_true', help='Return the current devel workspace maven directory.')
+    cmd_group.add_argument('-r', '--maven-repository', action='store_true', help='The url to the external ros maven repository.')
     cmd_group.add_argument('-m', '--maven-path', action='store_true', help='Generate maven path across all chained workspcaes.')
     cmd_group.add_argument('-g', '--gradle-user-home', action='store_true', help='Generate the local gradle user home in the current devel workspace (share/gradle).')
     args = parser.parse_args()
@@ -48,6 +49,11 @@ if __name__ == '__main__':
             if repo in [os.path.join(w, 'share', 'maven') for w in workspaces]:
                 repo = os.path.join(workspaces[0], 'share', 'maven')
         print repo
+    elif args.maven_repository:
+        repo = get_environment_variable(environment_variables, 'ROS_MAVEN_REPOSITORY')
+        if repo is None:
+            repo = 'https://github.com/rosjava/rosjava_mvn_repo/raw/master'
+        print repo
     elif args.maven_path:
         new_maven_paths = [os.path.join(path, 'share', 'maven') for path in workspaces]
         maven_paths = get_environment_variable(environment_variables, 'ROS_MAVEN_PATH')
diff --git a/src/rosjava_build_tools/templates/android_package/build.gradle.in b/src/rosjava_build_tools/templates/android_package/build.gradle.in
index 24e8bb7..592b221 100644
--- a/src/rosjava_build_tools/templates/android_package/build.gradle.in
+++ b/src/rosjava_build_tools/templates/android_package/build.gradle.in
@@ -20,6 +20,7 @@ task wrapper(type: Wrapper) {
 
 buildscript {
     def rosMavenPath = "$System.env.ROS_MAVEN_PATH".split(':').collect { 'file://' + it }
+    def rosMavenRepository = "$System.env.ROS_MAVEN_REPOSITORY"
     repositories {
         rosMavenPath.each { p ->
             maven {
@@ -28,11 +29,11 @@ buildscript {
         }
         mavenLocal()
         maven {
-            url 'https://github.com/rosjava/rosjava_mvn_repo/raw/master'
+            url rosMavenRepository
         }
     }
     dependencies {
-        classpath group: 'org.ros.rosjava_bootstrap', name: 'gradle_plugins', version: '[0.1,)'
+        classpath group: 'org.ros.rosjava_bootstrap', name: 'gradle_plugins', version: '[0.1,0.2)'
     }
 }
 
diff --git a/src/rosjava_build_tools/templates/android_project/build.gradle.in b/src/rosjava_build_tools/templates/android_project/build.gradle.in
index 2a72f22..d2da1a7 100644
--- a/src/rosjava_build_tools/templates/android_project/build.gradle.in
+++ b/src/rosjava_build_tools/templates/android_project/build.gradle.in
@@ -17,17 +17,17 @@
 /* 
  Examples of 
    1) dependencies from another project in this gradle stack.
-   2,3) dependency from a maven repository.
+   2,3) open ranged dependencies from a maven repository.
    
-   It's a good idea to use + on the patch version dependency to
-   save continually updating these references, but avoid applying
-   the same principle to api breaking minor changes in the version.
+   It's a good idea to restrict the open ranged dependency to
+   the patch version to avoid breakages due to api changes
+   which usually occur on minor and major version numbers.
 */
 /* 
 dependencies {
   compile project(':local_android_library_dependency')
   compile 'org.ros.android_core:android_gingerbread_mr1:[0.1,)'
-  compile 'com.github.ros_java.android_extras:gingerbread:[0.1,)'
+  compile 'com.github.rosjava.android_extras:gingerbread:[0.1,0.2)'
 }
 */
 
diff --git a/src/rosjava_build_tools/templates/rosjava_package/build.gradle.in b/src/rosjava_build_tools/templates/rosjava_package/build.gradle.in
index a4daa44..738e26f 100644
--- a/src/rosjava_build_tools/templates/rosjava_package/build.gradle.in
+++ b/src/rosjava_build_tools/templates/rosjava_package/build.gradle.in
@@ -20,6 +20,7 @@ task wrapper(type: Wrapper) {
 
 buildscript {
     def rosMavenPath = "$System.env.ROS_MAVEN_PATH".split(':').collect { 'file://' + it }
+    def rosMavenRepository = "$System.env.ROS_MAVEN_REPOSITORY"
     repositories {
         rosMavenPath.each { p ->
             maven {
@@ -28,11 +29,11 @@ buildscript {
         }
         mavenLocal()
         maven {
-            url 'https://github.com/rosjava/rosjava_mvn_repo/raw/master'
+            url rosMavenRepository
         }
     }
     dependencies {
-        classpath group: 'org.ros.rosjava_bootstrap', name: 'gradle_plugins', version: '[0.1,)'
+        classpath group: 'org.ros.rosjava_bootstrap', name: 'gradle_plugins', version: '[0.1,0.2)'
     }
 }
 
diff --git a/src/rosjava_build_tools/templates/rosjava_project/build.gradle.in b/src/rosjava_build_tools/templates/rosjava_project/build.gradle.in
index 6fe92d9..3c7f004 100644
--- a/src/rosjava_build_tools/templates/rosjava_project/build.gradle.in
+++ b/src/rosjava_build_tools/templates/rosjava_project/build.gradle.in
@@ -17,17 +17,17 @@
 /* 
  Examples of 
    1) dependencies from another project in this gradle stack.
-   2,3) dependency from a maven repository.
+   2,3) open ranged dependencies from a maven repository.
    
-   It's a good idea to use + on the patch version dependency to
-   save continually updating these references, but avoid applying
-   the same principle to api breaking minor changes in the version.
+   It's a good idea to restrict the open ranged dependency to
+   the patch version to avoid breakages due to api changes
+   which usually occur on minor and major version numbers.
 */
 /* 
 dependencies {
   compile project(':local_android_library_dependency')
-  compile 'org.ros.android_core:android_gingerbread_mr1:[0.1,)'
-  compile 'com.github.ros_java.android_extras:gingerbread:[0.1,)'
+  compile 'org.ros.rosjava_core:rosjava:[0.1,)'
+  compile 'com.github.rosjava.rosjava_extras:hokuyo:[0.1,0.2)'
 }
 */
 
-- 
GitLab