-
Notifications
You must be signed in to change notification settings - Fork 0
/
maven-package
executable file
·83 lines (72 loc) · 2.09 KB
/
maven-package
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env perl
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
use Getopt::Long;
my $build_opt = undef;
my $package_opt = undef;
my $revision_opt = undef;
my $release_opt = undef;
my $ldd_opt = undef;
my $ldd_args_opt = undef;
my $libexecdir_opt = undef;
GetOptions ("build=s" => \$build_opt,
"package=s" => \$package_opt,
"revision=s" => \$revision_opt,
"release=s" => \$release_opt,
"ldd=s" => \$ldd_opt,
"ldd_args=s" => \$ldd_args_opt,
"libexecdir=s" => \$libexecdir_opt);
sub read_xml_file
{
my ($file_name) = @_;
my $xml = undef;
open FROM, "< $file_name";
my (@lines) = <FROM>;
foreach my $line (@lines)
{
$xml .= $line;
}
close FROM;
return XMLin ($xml);
}
sub make_package
{
my ($pkg_prefix) = @_;
# detect that we've probably built the package
if (-f "target/$pkg_prefix.jar")
{
# create fw directories
`test -d fw-pkgout || mkdir fw-pkgout`;
`test -d fw-pkgtmp || mkdir fw-pkgtmp`;
`cd fw-pkgtmp && ln -sf ../target/$pkg_prefix.jar .`;
`cd fw-pkgtmp && ln -sf ../pom.xml $pkg_prefix.pom`;
`cd fw-pkgtmp && md5sum $pkg_prefix.jar | cut -f1 -d' ' > $pkg_prefix.jar.md5`;
`cd fw-pkgtmp && md5sum $pkg_prefix.pom | cut -f1 -d' ' > $pkg_prefix.pom.md5`;
`cd fw-pkgtmp && sha1sum $pkg_prefix.jar | cut -f1 -d' ' > $pkg_prefix.jar.sha1`;
`cd fw-pkgtmp && sha1sum $pkg_prefix.pom | cut -f1 -d' ' > $pkg_prefix.pom.sha1`;
`cd fw-pkgtmp && tar chvfz ../fw-pkgout/$pkg_prefix.tar.gz $pkg_prefix.*`;
`rm -rf fw-pkgtmp`;
}
else
{
print "ERROR: jar has not been made";
exit 1;
}
}
my $data = read_xml_file ("./pom.xml");
my $version = $data->{'version'};
my $name = $data->{'artifactId'};
my $pkg_prefix = "$name-$version";
my $tar_file = "$pkg_prefix.tar.gz";
unless (-f "fw-pkgout/$tar_file")
{
make_package ($pkg_prefix);
}
if ($release_opt eq "yes")
{
system ("mvn", "deploy") == 0
or die "ERROR: problem deploying to maven repository";
}
0;