storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [1/3] storm git commit: STORM-2267 Use user's local maven repo. directory to local repo.
Date Wed, 04 Jan 2017 09:29:25 GMT
Repository: storm
Updated Branches:
  refs/heads/master 6a4112a4c -> abee4d712


STORM-2267 Use user's local maven repo. directory to local repo.

* use user's maven local repository if possible
* if it's not available, just use 'local-repo' (it will be created if not exists)


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/1e09c59f
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/1e09c59f
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/1e09c59f

Branch: refs/heads/master
Commit: 1e09c59f823edffaa2aa30514deed9f3e8518772
Parents: 80dd6e4
Author: Jungtaek Lim <kabhwan@gmail.com>
Authored: Tue Jan 3 13:27:08 2017 +0900
Committer: Jungtaek Lim <kabhwan@gmail.com>
Committed: Tue Jan 3 13:27:08 2017 +0900

----------------------------------------------------------------------
 .../submit/command/DependencyResolverMain.java  | 27 +++++++++++++++++++-
 .../apache/storm/submit/dependency/Booter.java  |  5 ----
 .../submit/dependency/DependencyResolver.java   |  1 -
 3 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/1e09c59f/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
index d6135ac..ac50110 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
@@ -20,6 +20,7 @@ package org.apache.storm.submit.command;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
+import org.apache.commons.lang.StringUtils;
 import org.apache.storm.submit.dependency.AetherUtils;
 import org.apache.storm.submit.dependency.DependencyResolver;
 import org.json.simple.JSONValue;
@@ -28,6 +29,9 @@ import org.sonatype.aether.graph.Dependency;
 import org.sonatype.aether.repository.RemoteRepository;
 import org.sonatype.aether.resolution.ArtifactResult;
 
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -61,7 +65,8 @@ public class DependencyResolverMain {
         }
 
         try {
-            DependencyResolver resolver = new DependencyResolver("local-repo", repositories);
+            String localMavenRepoPath = getOrDefaultLocalMavenRepositoryPath("local-repo");
+            DependencyResolver resolver = new DependencyResolver(localMavenRepoPath, repositories);
 
             List<ArtifactResult> artifactResults = resolver.resolve(dependencies);
 
@@ -130,4 +135,24 @@ public class DependencyResolverMain {
         return artifactToPath;
     }
 
+    private static String getOrDefaultLocalMavenRepositoryPath(String defaultPath) {
+        String localMavenRepoPathStr = getLocalMavenRepositoryPath();
+        if (StringUtils.isNotEmpty(localMavenRepoPathStr)) {
+            Path localMavenRepoPath = new File(localMavenRepoPathStr).toPath();
+            if (Files.exists(localMavenRepoPath) && Files.isDirectory(localMavenRepoPath))
{
+                return localMavenRepoPathStr;
+            }
+        }
+
+        return defaultPath;
+    }
+
+    private static String getLocalMavenRepositoryPath() {
+        String userHome = System.getProperty("user.home");
+        if (StringUtils.isNotEmpty(userHome)) {
+            return userHome + File.separator + ".m2" + File.separator + "repository";
+        }
+
+        return null;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/1e09c59f/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
index 1f03831..816e3cc 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
@@ -48,9 +48,4 @@ public class Booter {
     public static RemoteRepository newCentralRepository() {
         return new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
     }
-
-    public static RemoteRepository newLocalRepository() {
-        return new RemoteRepository("local",
-                "default", "file://" + System.getProperty("user.home") + "/.m2/repository");
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/storm/blob/1e09c59f/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
index 2819746..4534344 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
@@ -54,7 +54,6 @@ public class DependencyResolver {
 
         remoteRepositories = new ArrayList<>();
         remoteRepositories.add(Booter.newCentralRepository());
-        remoteRepositories.add(Booter.newLocalRepository());
         remoteRepositories.addAll(repositories);
     }
 


Mime
View raw message