source: local/greenstone3/windows-64bit/apache-ant-1.9.5/bin/runant.pl@ 30443

Last change on this file since 30443 was 30443, checked in by davidb, 8 years ago

Move to newer version of ant needed, for some of the features now used in Greenstone3's build.xml + newer versions of Java

  • Property svn:executable set to *
File size: 4.2 KB
Line 
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#
33# Assumptions:
34#
35# - the "java" executable/script is on the command path
36# - ANT_HOME has been set
37# - target platform uses ":" as classpath separator or perl indicates it is dos/win32
38# - target platform uses "/" as directory separator.
39
40#be fussy about variables
41use strict;
42
43#platform specifics (disabled)
44#use File::Spec::Functions;
45
46#turn warnings on during dev; generates a few spurious uninitialised var access warnings
47#use warnings;
48
49#and set $debug to 1 to turn on trace info
50my $debug=1;
51
52#######################################################################
53#
54# check to make sure environment is setup
55#
56
57my $HOME = $ENV{ANT_HOME};
58if ($HOME eq "")
59 {
60 die "\n\nANT_HOME *MUST* be set!\n\n";
61 }
62
63my $JAVACMD = $ENV{JAVACMD};
64$JAVACMD = "java" if $JAVACMD eq "";
65
66my $onnetware = 0;
67if ($^O eq "NetWare")
68{
69 $onnetware = 1;
70}
71
72my $oncygwin = ($^O eq "cygwin");
73
74#ISSUE: what java wants to split up classpath varies from platform to platform
75#and perl is not too hot at hinting which box it is on.
76#here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed.
77my $s=":";
78if(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") ||
79 ($onnetware == 1))
80 {
81 $s=";";
82 }
83
84#build up standard classpath
85my $localpath = "$HOME/lib/ant-launcher.jar";
86#set JVM options and Ant arguments, if any
87my @ANT_OPTS=split(" ", $ENV{ANT_OPTS});
88my @ANT_ARGS=split(" ", $ENV{ANT_ARGS});
89
90#jikes
91if($ENV{JIKESPATH} ne "")
92 {
93 push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}";
94 }
95
96#construct arguments to java
97my @ARGS;
98push @ARGS, @ANT_OPTS;
99
100my $CYGHOME = "";
101
102my $classpath=$ENV{CLASSPATH};
103if ($oncygwin == 1) {
104 $localpath = `cygpath --path --windows $localpath`;
105 chomp ($localpath);
106 if (! $classpath eq "")
107 {
108 $classpath = `cygpath --path --windows "$classpath"`;
109 chomp ($classpath);
110 }
111 $HOME = `cygpath --path --windows $HOME`;
112 chomp ($HOME);
113 $CYGHOME = `cygpath --path --windows $ENV{HOME}`;
114 chomp ($CYGHOME);
115}
116push @ARGS, "-classpath", "$localpath";
117push @ARGS, "-Dant.home=$HOME";
118if ( ! $CYGHOME eq "" )
119{
120 push @ARGS, "-Dcygwin.user.home=\"$CYGHOME\""
121}
122push @ARGS, "org.apache.tools.ant.launch.Launcher", @ANT_ARGS;
123push @ARGS, @ARGV;
124if (! $classpath eq "")
125{
126 if ($onnetware == 1)
127 {
128 # make classpath literally $CLASSPATH
129 # this is to avoid pushing us over the 512 character limit
130 # even skip the ; - that is already in $localpath
131 push @ARGS, "-lib", "\$CLASSPATH";
132 }
133 else
134 {
135 push @ARGS, "-lib", "$classpath";
136 }
137}
138print "\n $JAVACMD @ARGS\n\n" if ($debug);
139
140my $returnValue = system $JAVACMD, @ARGS;
141if ($returnValue eq 0)
142 {
143 exit 0;
144 }
145else
146 {
147 # only 0 and 1 are widely recognized as exit values
148 # so change the exit value to 1
149 exit 1;
150 }
Note: See TracBrowser for help on using the repository browser.