0N/A#!/usr/bin/perl
0N/A#
809N/A# Licensed to the Apache Software Foundation (ASF) under one or more
809N/A# contributor license agreements. See the NOTICE file distributed with
809N/A# this work for additional information regarding copyright ownership.
809N/A# The ASF licenses this file to You under the Apache License, Version 2.0
809N/A# (the "License"); you may not use this file except in compliance with
809N/A# the License. You may obtain a copy of the License at
0N/A#
0N/A# http://www.apache.org/licenses/LICENSE-2.0
0N/A#
0N/A# Unless required by applicable law or agreed to in writing, software
0N/A# distributed under the License is distributed on an "AS IS" BASIS,
0N/A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0N/A# See the License for the specific language governing permissions and
0N/A# limitations under the License.
0N/A#
0N/A#######################################################################
0N/A#
0N/A# runant.pl
0N/A#
0N/A# wrapper script for invoking ant in a platform with Perl installed
0N/A# this may include cgi-bin invocation, which is considered somewhat daft.
0N/A# (slo: that should be a separate file which can be derived from this
0N/A# and returns the XML formatted output)
0N/A#
0N/A# the code is not totally portable due to classpath and directory splitting
0N/A# issues. oops. (NB, use File::Spec::Functions will help and the code is
0N/A# structured for the catfile() call, but because of perl version funnies
0N/A# the code is not included.
0N/A#
0N/A# created: 2000-8-24
0N/A# author: Steve Loughran steve_l@sourceforge.net
0N/A#######################################################################
0N/A#
0N/A# Assumptions:
0N/A#
0N/A# - the "java" executable/script is on the command path
0N/A# - ANT_HOME has been set
0N/A# - target platform uses ":" as classpath separator or perl indicates it is dos/win32
0N/A# - target platform uses "/" as directory separator.
0N/A
0N/A#be fussy about variables
0N/Ause strict;
0N/A
0N/A#platform specifics (disabled)
0N/A#use File::Spec::Functions;
0N/A
0N/A#turn warnings on during dev; generates a few spurious uninitialised var access warnings
0N/A#use warnings;
0N/A
0N/A#and set $debug to 1 to turn on trace info
0N/Amy $debug=1;
0N/A
0N/A#######################################################################
0N/A#
0N/A# check to make sure environment is setup
0N/A#
0N/A
0N/Amy $HOME = $ENV{ANT_HOME};
0N/Aif ($HOME eq "")
0N/A {
0N/A die "\n\nANT_HOME *MUST* be set!\n\n";
0N/A }
0N/A
0N/Amy $JAVACMD = $ENV{JAVACMD};
0N/A$JAVACMD = "java" if $JAVACMD eq "";
0N/A
0N/Amy $onnetware = 0;
0N/Aif ($^O eq "NetWare")
0N/A{
0N/A $onnetware = 1;
0N/A}
0N/A
0N/Amy $oncygwin = ($^O eq "cygwin");
0N/A
0N/A#ISSUE: what java wants to split up classpath varies from platform to platform
0N/A#and perl is not too hot at hinting which box it is on.
0N/A#here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed.
0N/Amy $s=":";
0N/Aif(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") ||
0N/A ($onnetware == 1))
0N/A {
0N/A $s=";";
0N/A }
0N/A
0N/A#build up standard classpath
0N/Amy $localpath = "$HOME/lib/ant-launcher.jar";
0N/A#set JVM options and Ant arguments, if any
0N/Amy @ANT_OPTS=split(" ", $ENV{ANT_OPTS});
0N/Amy @ANT_ARGS=split(" ", $ENV{ANT_ARGS});
0N/A
0N/A#jikes
0N/Aif($ENV{JIKESPATH} ne "")
0N/A {
0N/A push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}";
0N/A }
0N/A
0N/A#construct arguments to java
0N/Amy @ARGS;
0N/Apush @ARGS, @ANT_OPTS;
0N/A
0N/Amy $CYGHOME = "";
0N/A
0N/Amy $classpath=$ENV{CLASSPATH};
0N/Aif ($oncygwin == 1) {
0N/A $localpath = `cygpath --path --windows $localpath`;
0N/A chomp ($localpath);
0N/A if (! $classpath eq "")
0N/A {
0N/A $classpath = `cygpath --path --windows "$classpath"`;
0N/A chomp ($classpath);
0N/A }
0N/A $HOME = `cygpath --path --windows $HOME`;
0N/A chomp ($HOME);
0N/A $CYGHOME = `cygpath --path --windows $ENV{HOME}`;
0N/A chomp ($CYGHOME);
0N/A}
0N/Apush @ARGS, "-classpath", "$localpath";
0N/Apush @ARGS, "-Dant.home=$HOME";
0N/Aif ( ! $CYGHOME eq "" )
0N/A{
0N/A push @ARGS, "-Dcygwin.user.home=\"$CYGHOME\""
0N/A}
0N/Apush @ARGS, "org.apache.tools.ant.launch.Launcher", @ANT_ARGS;
0N/Apush @ARGS, @ARGV;
0N/Aif (! $classpath eq "")
0N/A{
0N/A if ($onnetware == 1)
0N/A {
0N/A # make classpath literally $CLASSPATH
0N/A # this is to avoid pushing us over the 512 character limit
0N/A # even skip the ; - that is already in $localpath
0N/A push @ARGS, "-lib", "\$CLASSPATH";
0N/A }
0N/A else
0N/A {
0N/A push @ARGS, "-lib", "$classpath";
0N/A }
0N/A}
0N/Aprint "\n $JAVACMD @ARGS\n\n" if ($debug);
0N/A
0N/Amy $returnValue = system $JAVACMD, @ARGS;
0N/Aif ($returnValue eq 0)
0N/A {
0N/A exit 0;
0N/A }
0N/Aelse
0N/A {
0N/A # only 0 and 1 are widely recognized as exit values
0N/A # so change the exit value to 1
0N/A exit 1;
0N/A }