Skip to content

Commit 4155115

Browse files
committed
Add script to analyze Java version requirements
1 parent 41ffa26 commit 4155115

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

dep-versions.pl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/perl
2+
3+
# dep-versions.pl - reports the minimum version of Java
4+
# needed for each dependency of a project.
5+
6+
use strict;
7+
8+
my @deps = `mvn dependency:list`;
9+
10+
my $active = 0;
11+
for my $dep (@deps) {
12+
chomp $dep;
13+
14+
if (!$active) {
15+
$active = $dep =~ /The following files have been resolved/;
16+
next;
17+
}
18+
19+
# parse GAPCVS from dependency output
20+
$dep =~ s/^\[INFO\]\s*//;
21+
my @t = split(/:/, $dep);
22+
my $tokens = @t;
23+
my $g, my $a, my $p, my $c, my $v, my $s;
24+
if ($tokens == 1) {
25+
# end of dependencies
26+
last;
27+
}
28+
elsif ($tokens == 5) {
29+
# e.g.: org.jruby:jruby-core:jar:1.7.12:runtime
30+
($g, $a, $p, $v, $s) = @t;
31+
$c = '';
32+
}
33+
elsif ($tokens == 6) {
34+
# e.g.: org.jogamp.jocl:jocl:jar:natives-linux-i586:2.3.2:runtime
35+
($g, $a, $p, $c, $v, $s) = @t;
36+
}
37+
else {
38+
die "Unknown dependency format: $dep";
39+
}
40+
41+
# convert GAPCVS to local repository cache path
42+
my $gPart = $g;
43+
$gPart =~ s/\./\//g;
44+
my $cPart = $c ? "-$c" : '';
45+
# e.g.: ~/.m2/repository/org/jogamp/jocl/jocl/2.3.2/jocl-2.3.2-natives-linux-i586.jar
46+
my $path = "\$HOME/.m2/repository/$gPart/$a/$v/$a-$v$cPart.$p";
47+
48+
# report Java version of the component
49+
print `class-version.sh "$path"`;
50+
}

0 commit comments

Comments
 (0)