1
|
#!/usr/bin/perl
|
2
|
#
|
3
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
# contributor license agreements. See the NOTICE file distributed with
|
5
|
# this work for additional information regarding copyright ownership.
|
6
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
# (the "License"); you may not use this file except in compliance with
|
8
|
# the License. You may obtain a copy of the License at
|
9
|
#
|
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
#
|
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
# See the License for the specific language governing permissions and
|
16
|
# limitations under the License.
|
17
|
#
|
18
|
#######################################################################
|
19
|
#
|
20
|
# runant.pl
|
21
|
#
|
22
|
# wrapper script for invoking ant in a platform with Perl installed
|
23
|
# this may include cgi-bin invocation, which is considered somewhat daft.
|
24
|
# (slo: that should be a separate file which can be derived from this
|
25
|
# and returns the XML formatted output)
|
26
|
#
|
27
|
# the code is not totally portable due to classpath and directory splitting
|
28
|
# issues. oops. (NB, use File::Spec::Functions will help and the code is
|
29
|
# structured for the catfile() call, but because of perl version funnies
|
30
|
# the code is not included.
|
31
|
#
|
32
|
# created: 2000-8-24
|
33
|
# author: Steve Loughran steve_l@sourceforge.net
|
34
|
#######################################################################
|
35
|
#
|
36
|
# Assumptions:
|
37
|
#
|
38
|
# - the "java" executable/script is on the command path
|
39
|
# - ANT_HOME has been set
|
40
|
# - target platform uses ":" as classpath separator or perl indicates it is dos/win32
|
41
|
# - target platform uses "/" as directory separator.
|
42
|
|
43
|
#be fussy about variables
|
44
|
use strict;
|
45
|
|
46
|
#platform specifics (disabled)
|
47
|
#use File::Spec::Functions;
|
48
|
|
49
|
#turn warnings on during dev; generates a few spurious uninitialised var access warnings
|
50
|
#use warnings;
|
51
|
|
52
|
#and set $debug to 1 to turn on trace info
|
53
|
my $debug=1;
|
54
|
|
55
|
#######################################################################
|
56
|
#
|
57
|
# check to make sure environment is setup
|
58
|
#
|
59
|
|
60
|
my $HOME = $ENV{ANT_HOME};
|
61
|
if ($HOME eq "")
|
62
|
{
|
63
|
die "\n\nANT_HOME *MUST* be set!\n\n";
|
64
|
}
|
65
|
|
66
|
my $JAVACMD = $ENV{JAVACMD};
|
67
|
$JAVACMD = "java" if $JAVACMD eq "";
|
68
|
|
69
|
my $onnetware = 0;
|
70
|
if ($^O eq "NetWare")
|
71
|
{
|
72
|
$onnetware = 1;
|
73
|
}
|
74
|
|
75
|
my $oncygwin = ($^O eq "cygwin");
|
76
|
|
77
|
#ISSUE: what java wants to split up classpath varies from platform to platform
|
78
|
#and perl is not too hot at hinting which box it is on.
|
79
|
#here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed.
|
80
|
my $s=":";
|
81
|
if(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") ||
|
82
|
($onnetware == 1))
|
83
|
{
|
84
|
$s=";";
|
85
|
}
|
86
|
|
87
|
#build up standard classpath
|
88
|
my $localpath = "$HOME/lib/ant-launcher.jar";
|
89
|
#set JVM options and Ant arguments, if any
|
90
|
my @ANT_OPTS=split(" ", $ENV{ANT_OPTS});
|
91
|
my @ANT_ARGS=split(" ", $ENV{ANT_ARGS});
|
92
|
|
93
|
#jikes
|
94
|
if($ENV{JIKESPATH} ne "")
|
95
|
{
|
96
|
push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}";
|
97
|
}
|
98
|
|
99
|
#construct arguments to java
|
100
|
my @ARGS;
|
101
|
push @ARGS, @ANT_OPTS;
|
102
|
|
103
|
my $CYGHOME = "";
|
104
|
|
105
|
my $classpath=$ENV{CLASSPATH};
|
106
|
if ($oncygwin == 1) {
|
107
|
$localpath = `cygpath --path --windows $localpath`;
|
108
|
chomp ($localpath);
|
109
|
if (! $classpath eq "")
|
110
|
{
|
111
|
$classpath = `cygpath --path --windows "$classpath"`;
|
112
|
chomp ($classpath);
|
113
|
}
|
114
|
$HOME = `cygpath --path --windows $HOME`;
|
115
|
chomp ($HOME);
|
116
|
$CYGHOME = `cygpath --path --windows $ENV{HOME}`;
|
117
|
chomp ($CYGHOME);
|
118
|
}
|
119
|
push @ARGS, "-classpath", "$localpath";
|
120
|
push @ARGS, "-Dant.home=$HOME";
|
121
|
if ( ! $CYGHOME eq "" )
|
122
|
{
|
123
|
push @ARGS, "-Dcygwin.user.home=\"$CYGHOME\""
|
124
|
}
|
125
|
push @ARGS, "org.apache.tools.ant.launch.Launcher", @ANT_ARGS;
|
126
|
push @ARGS, @ARGV;
|
127
|
if (! $classpath eq "")
|
128
|
{
|
129
|
if ($onnetware == 1)
|
130
|
{
|
131
|
# make classpath literally $CLASSPATH
|
132
|
# this is to avoid pushing us over the 512 character limit
|
133
|
# even skip the ; - that is already in $localpath
|
134
|
push @ARGS, "-lib", "\$CLASSPATH";
|
135
|
}
|
136
|
else
|
137
|
{
|
138
|
push @ARGS, "-lib", "$classpath";
|
139
|
}
|
140
|
}
|
141
|
print "\n $JAVACMD @ARGS\n\n" if ($debug);
|
142
|
|
143
|
my $returnValue = system $JAVACMD, @ARGS;
|
144
|
if ($returnValue eq 0)
|
145
|
{
|
146
|
exit 0;
|
147
|
}
|
148
|
else
|
149
|
{
|
150
|
# only 0 and 1 are widely recognized as exit values
|
151
|
# so change the exit value to 1
|
152
|
exit 1;
|
153
|
}
|