25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/lowendinsight/pom_dependencies.rb', line 25
def self.get_dependencies_from_repo(url)
h = {}
begin
@url = url
paths = URI(@url).path.split("/")
@name = paths[(paths.size)-1]
g = Git.clone(@url, @name, :path => '/tmp/checkout')
raise unless File.exist?("/tmp/checkout/#{@name}/pom.xml")
o = `cd /tmp/checkout/#{@name} && mvn -B dependency:list -DoutputFile='deps.txt'`
d = File.read("/tmp/checkout/#{@name}/deps.txt").strip.lines.map(&:chomp).drop(1)
d.each do |dep|
dep = dep.strip.split(":")
h["#{dep[4]}:#{dep[0]}.#{dep[1]}"] = dep[3]
end
rescue
h["message"] = "no pom.xml found"
end
FileUtils.rm_rf("/tmp/checkout/#{@name}")
return h
end
|