sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tom...@apache.org
Subject svn commit: r1667792 - in /sling/trunk/contrib/sling-s3/scripts: crankstart.sh download_dependencies.rb
Date Thu, 19 Mar 2015 15:26:07 GMT
Author: tomekr
Date: Thu Mar 19 15:26:07 2015
New Revision: 1667792

URL: http://svn.apache.org/r1667792
Log:
SLING-4502 Allow to download bundles to a local directory

Modified:
    sling/trunk/contrib/sling-s3/scripts/crankstart.sh
    sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb

Modified: sling/trunk/contrib/sling-s3/scripts/crankstart.sh
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/sling-s3/scripts/crankstart.sh?rev=1667792&r1=1667791&r2=1667792&view=diff
==============================================================================
--- sling/trunk/contrib/sling-s3/scripts/crankstart.sh (original)
+++ sling/trunk/contrib/sling-s3/scripts/crankstart.sh Thu Mar 19 15:26:07 2015
@@ -1,7 +1,13 @@
 #!/bin/sh
 
+MVN_OPTS=""
+
+if [ "$M2REPO" ] ; then
+  MVN_OPTS="${MVN_OPTS} -Dorg.ops4j.pax.url.mvn.localRepository=${M2REPO}"
+fi
+
 REPO="https://repository.apache.org/content/repositories/snapshots@snapshots@id=apache-snapshots"
 REPO="${REPO},http://repo1.maven.org/maven2/@id=central"
+MVN_OPTS="${MVN_OPTS} -Dorg.ops4j.pax.url.mvn.repositories=${REPO}"
 
-java -Dorg.ops4j.pax.url.mvn.repositories=$REPO \
-     -jar contrib/crankstart.jar "$@"
+java ${MVN_OPTS} -jar contrib/crankstart.jar "$@"

Modified: sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb?rev=1667792&r1=1667791&r2=1667792&view=diff
==============================================================================
--- sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb (original)
+++ sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb Thu Mar 19 15:26:07 2015
@@ -1,8 +1,10 @@
 #!/usr/bin/env ruby
 
-DEP_PLUGIN = 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get'
+DEP_PLUGIN = 'org.apache.maven.plugins:maven-dependency-plugin:2.10'
 SNAPSHOT_REPO = 'https://repository.apache.org/content/repositories/snapshots'
 LOCAL_REPO = '~/.m2/repository'
+# If set, copy artifacts to OUTPUT location, default is ~/.m2 only
+OUTPUT = ENV["OUTPUT"]
 
 def run cmd
   output = ""
@@ -13,18 +15,39 @@ def run cmd
   output
 end
 
+def dep_get groupId, artifactId, version
+  result = run "mvn #{DEP_PLUGIN}:get -DremoteRepositories=#{SNAPSHOT_REPO} -Dartifact=#{groupId}:#{artifactId}:#{version}
-Dtransitive=false"
+  result.include? 'BUILD SUCCESS'
+end
+
+def dep_copy groupId, artifactId, version, dest
+  `mkdir -p #{dest}`
+  result = run "mvn #{DEP_PLUGIN}:copy -Dartifact=#{groupId}:#{artifactId}:#{version} -DoutputDirectory=#{dest}"
+  result.include? 'BUILD SUCCESS'
+end
+
 def download groupId, artifactId, version
   puts "#{groupId}:#{artifactId}:#{version}"
-  local = "#{LOCAL_REPO}/#{groupId.gsub('.', '/')}/#{artifactId}/#{version}/#{artifactId}-#{version}.jar"
-  if File.exists?(File.expand_path(local))
-    puts "(/) Already installed"
-    return
-  end
-  result = run "mvn #{DEP_PLUGIN} -DremoteRepositories=#{SNAPSHOT_REPO} -Dartifact=#{groupId}:#{artifactId}:#{version}
-Dtransitive=false"
-  if result.include? 'BUILD SUCCESS'
-    puts "(/) Downloaded"
+
+  repo_dir = "#{groupId.gsub('.', '/')}/#{artifactId}/#{version}"
+  jar_name = "#{artifactId}-#{version}.jar"
+
+  if !OUTPUT.nil?
+    if File.exists?(File.expand_path("#{OUTPUT}/#{repo_dir}/#{jar_name}"))
+      puts "(/) Already downloaded"
+    elsif dep_copy groupId, artifactId, version, "#{OUTPUT}/#{repo_dir}"
+      puts "(/) Downloaded"
+    else
+      puts "(X) Error"
+    end
   else
-    puts "(X) Error\n#{result}"
+    if File.exists?(File.expand_path("#{LOCAL_REPO}/#{repo_dir}/#{jar_name}"))
+      puts "(/) Already installed"
+    elsif dep_get groupId, artifactId, version
+      puts "(/) Installed to local repo"
+    else
+      puts "(X) Error"
+    end
   end
 end
 



Mime
View raw message