-
Notifications
You must be signed in to change notification settings - Fork 16
/
dep-versions.pl
executable file
·50 lines (42 loc) · 1.16 KB
/
dep-versions.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
#!/usr/bin/perl
# dep-versions.pl - reports the minimum version of Java
# needed for each dependency of a project.
use strict;
my @deps = `mvn -B dependency:list`;
my $active = 0;
for my $dep (@deps) {
chomp $dep;
if (!$active) {
$active = $dep =~ /The following files have been resolved/;
next;
}
# parse GAPCVS from dependency output
$dep =~ s/^\[INFO\]\s*//;
my @t = split(/:/, $dep);
my $tokens = @t;
my $g, my $a, my $p, my $c, my $v, my $s;
if ($tokens == 1) {
# end of dependencies
last;
}
elsif ($tokens == 5) {
# e.g.: org.jruby:jruby-core:jar:1.7.12:runtime
($g, $a, $p, $v, $s) = @t;
$c = '';
}
elsif ($tokens == 6) {
# e.g.: org.jogamp.jocl:jocl:jar:natives-linux-i586:2.3.2:runtime
($g, $a, $p, $c, $v, $s) = @t;
}
else {
die "Unknown dependency format: $dep";
}
# convert GAPCVS to local repository cache path
my $gPart = $g;
$gPart =~ s/\./\//g;
my $cPart = $c ? "-$c" : '';
# e.g.: ~/.m2/repository/org/jogamp/jocl/jocl/2.3.2/jocl-2.3.2-natives-linux-i586.jar
my $path = "\$HOME/.m2/repository/$gPart/$a/$v/$a-$v$cPart.$p";
# report Java version of the component
print `class-version.sh "$path"`;
}