summaryrefslogtreecommitdiff
blob: 0d5077d618265a819db3cccac736ef55a5126e1b (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#! /bin/bash

#   Copyright 2001-2004 The Apache Software Foundation
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

#   Edited for Gentoo Linux
#   $Header: /var/cvsroot/gentoo-x86/dev-java/ant-core/files/1.6.5-ant,v 1.2 2005/07/09 15:46:06 axxo Exp $

# Extract launch and ant arguments, (see details below).
ant_exec_args=
no_config=false
use_jikes_default=false
ant_exec_debug=false
show_help=false
for arg in "$@" ; do
  if [ "$arg" = "--noconfig" ] ; then
    no_config=true
  elif [ "$arg" = "--usejikes" ] ; then
    use_jikes_default=true
  elif [ "$arg" = "--execdebug" ] ; then
    ant_exec_debug=true
  elif [ my"$arg" = my"--h"  -o my"$arg" = my"--help"  ] ; then
    show_help=true
    ant_exec_args="$ant_exec_args -h"
  else
    if [  my"$arg" = my"-h"  -o  my"$arg" = my"-help" ] ; then
      show_help=true
    fi
    ant_exec_args="$ant_exec_args \"$arg\""
  fi
done

# Source/default ant configuration
if $no_config ; then
  rpm_mode=false
  usejikes=$use_jikes_default
else
  # load system-wide ant configuration
  if [ -f "/etc/ant.conf" ] ; then
    . /etc/ant.conf
  fi

  # load user ant configuration
  if [ -f "$HOME/.ant/ant.conf" ] ; then
    . $HOME/.ant/ant.conf
  fi
  if [ -f "$HOME/.antrc" ] ; then
    . "$HOME/.antrc"
  fi

  # provide default configuration values
  if [ -z "$rpm_mode" ] ; then
    rpm_mode=false
  fi
  if [ -z "$usejikes" ] ; then
    usejikes=$use_jikes_default
  fi
fi


if [ -z $JAVA_HOME ] ; then
	if [ -f $HOME/.gentoo/java-env ] ; then
		source $HOME/.gentoo/java-env
	else
		JAVA_HOME=`java-config --jdk-home`
		CLASSPATH=`java-config --classpath`:${CLASSPATH}
	fi
fi

if [ -z $JAVA_HOME ] ; then
  echo "Error: No JDK found!"
  echo "Try using java-config script to set your JDK"
  echo "Remember that you need a JDK not a JRE"
  exit 1
fi

ANT_HOME=/usr/share/ant-core

# set ANT_LIB location
ANT_LIB="${ANT_HOME}/lib"

JAVACMD="`java-config --java`"

if [ ! -x "$JAVACMD" ] ; then
  echo "Error: JAVA_HOME is not defined correctly."
  echo "  We cannot execute $JAVACMD"
  exit 1
fi

if [ -z "$LOCALCLASSPATH" ] ; then
  LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
else
  LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
fi

# add in the dependency .jar files
LOCALCLASSPATH="${LOCALCLASSPATH}:`java-config --classpath=ant-tasks,log4j,xerces-2,xalan,junit,antlr,bcel,bsh,commons-beanutils-1.6,commons-collections,commons-logging,commons-net,jakarta-oro-2.0,jdepend,jsch,jakarta-regexp-1.3,rhino-1.5,jython,jta,jaf,javamail 2> /dev/null`"

if [ -n "$JAVA_HOME" ] ; then
  if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
    LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
  fi

  if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
    LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
  fi

else
  echo "Warning: JAVA_HOME environment variable is not set (or not exported)."
  echo "  If build fails because sun.* classes could not be found"
  echo "  you will need to set the JAVA_HOME environment variable"
  echo "  to the installation directory of java."
  echo "  Try using java-config script"
fi

# Allow Jikes support (off by default)
if $usejikes; then
  ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
fi

# Show script help if requested
if $show_help ; then
  echo $0 '[script options] [options] [target [target2 [target3] ..]]'
  echo 'Script Options:'
  echo '  --help, --h            print this message and ant help'
  echo '  --noconfig             suppress sourcing of /etc/ant.conf,'
  echo '                         $HOME/.ant/ant.conf, and $HOME/.antrc'
  echo '                         configuration files'
  echo '  --usejikes             enable use of jikes by default, unless'
  echo '                         set explicitly in configuration files'
  echo '  --execdebug            print ant exec line generated by this'
  echo '                         launch script'
  echo '  '
fi

# Execute ant using eval/exec to preserve spaces in paths,
# java options, and ant args
ant_sys_opts=


if [ -n "$JIKESPATH" ]; then
	ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
fi

# 2002-11-02, karltk@gentoo.org:
# The Blackdown JDK on PPC hiccups with native threads
#
if [ "`arch`" == "ppc" ] ; then
	export THREADS_FLAG="green"
fi


ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\" $ant_exec_args"

if $ant_exec_debug ; then
  echo $ant_exec_command
fi
eval $ant_exec_command