You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by to...@apache.org on 2015/03/21 09:44:13 UTC

svn commit: r1668208 - /sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb

Author: tomekr
Date: Sat Mar 21 08:44:12 2015
New Revision: 1668208

URL: http://svn.apache.org/r1668208
Log:
SLING-4502 Cleanup the dependency download logic

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

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=1668208&r1=1668207&r2=1668208&view=diff
==============================================================================
--- sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb (original)
+++ sling/trunk/contrib/sling-s3/scripts/download_dependencies.rb Sat Mar 21 08:44:12 2015
@@ -1,4 +1,5 @@
 #!/usr/bin/env ruby
+require 'fileutils'
 
 DEP_PLUGIN = 'org.apache.maven.plugins:maven-dependency-plugin:2.10'
 SNAPSHOT_REPO = 'https://repository.apache.org/content/repositories/snapshots'
@@ -20,33 +21,30 @@ def dep_get groupId, artifactId, version
   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}"
 
   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
+  repo_file = File.expand_path("#{LOCAL_REPO}/#{repo_dir}/#{jar_name}")
+  puts "Retreiving #{repo_file}"
+  if File.exists?(repo_file)
+    puts "(/) Already downloaded"
+  elsif dep_get groupId, artifactId, version
+    puts "(/) Downloaded"
   else
-    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"
+    abort "(X) Error"
+  end
+  if !OUTPUT.nil?
+    output_dir = File.expand_path("#{OUTPUT}/#{repo_dir}")
+    FileUtils.rm_rf output_dir
+    FileUtils.mkdir_p output_dir
+    if !File.exists?(repo_file)
+      abort "(X) Missing "
     else
-      puts "(X) Error"
+      puts "(/) #{repo_file} -> #{output_dir}"
+      FileUtils.cp repo_file, output_dir
     end
   end
 end
@@ -56,7 +54,7 @@ defaults = Hash.new
 ARGV.each do |f|
   File.open(f).each_line do |l|
     defaults.each { |k, v| l[k] &&= v }
-    if l =~ /^bundle mvn:([^\/]+)\/([^\/]+)\/(.+)$/
+    if l =~ /^(?:bundle|classpath) mvn:([^\/]+)\/([^\/]+)\/(.+)$/
       download($1, $2, $3)
     elsif l =~ /^defaults ([^ ]+) ([^ ]+)$/
       defaults["${#{$1}}"] = $2