reject changes to public API closes #44 closes #47
[ant.git] / bootstrap.sh
1 #!/bin/sh
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 # OS specific support. $var _must_ be set to either true or false.
19 cygwin=false;
20 darwin=false;
21 case "`uname`" in
22 CYGWIN*) cygwin=true ;;
23 Darwin*) darwin=true
24 if [ -z "$JAVA_HOME" ] ; then
25 JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
26 fi
27 ;;
28 esac
29
30 # For Cygwin, ensure paths are in UNIX format before anything is touched
31 if $cygwin ; then
32 [ -n "$JAVA_HOME" ] &&
33 JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
34 [ -n "$CLASSPATH" ] &&
35 CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
36 fi
37
38 # You will need to specify JAVA_HOME if compiling with 1.2 or later.
39
40 if [ -n "$JAVA_HOME" ] ; then
41 if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
42 CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
43 fi
44
45 if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
46 CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/classes.zip
47 fi
48 else
49 echo "Warning: JAVA_HOME environment variable not set."
50 echo " If build fails because sun.* classes could not be found"
51 echo " you will need to set the JAVA_HOME environment variable"
52 echo " to the installation directory of java."
53 fi
54
55 # IBM's JDK on AIX uses strange locations for the executables:
56 # JAVA_HOME/jre/sh for java and rmid
57 # JAVA_HOME/sh for javac and rmic
58 if [ -z "$JAVAC" ] ; then
59 if [ -n "$JAVA_HOME" ] ; then
60 if [ -x "$JAVA_HOME/sh/javac" ] ; then
61 JAVAC=${JAVA_HOME}/sh/javac;
62 else
63 JAVAC=${JAVA_HOME}/bin/javac;
64 fi
65 else
66 JAVAC=javac
67 fi
68 fi
69 if [ -z "$JAVACMD" ] ; then
70 if [ -n "$JAVA_HOME" ] ; then
71 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 JAVACMD=$JAVA_HOME/jre/sh/java
73 else
74 JAVACMD=$JAVA_HOME/bin/java
75 fi
76 else
77 JAVACMD=java
78 fi
79 fi
80
81 if [ ! -x "$JAVACMD" ] ; then
82 echo "Error: JAVA_HOME is not defined correctly."
83 echo " We cannot execute $JAVACMD"
84 exit
85 fi
86
87 ANT_HOME=.
88 export ANT_HOME
89
90 echo ... Bootstrapping Ant Distribution
91
92 if [ -d "bootstrap" ] ; then
93 rm -r bootstrap
94 fi
95
96 if [ -d "build" ] ; then
97 rm -r build
98 fi
99
100 DIRLIBS=lib/optional/*.jar
101 for i in ${DIRLIBS}
102 do
103 # if the directory is empty, then it will return the input string
104 # this is stupid, so case for it
105 if [ "$i" != "${DIRLIBS}" ] ; then
106 CLASSPATH=$CLASSPATH:"$i"
107 fi
108 done
109
110 TOOLS=src/main/org/apache/tools
111 CLASSDIR=build/classes
112
113 CLASSPATH=${CLASSDIR}:src/main:${CLASSPATH}
114
115 # For Cygwin, switch to Windows format before running java
116 if $cygwin; then
117 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
118 fi
119
120 export CLASSPATH
121
122 mkdir -p build
123 mkdir -p ${CLASSDIR}
124 mkdir -p bin
125
126 echo ... Compiling Ant Classes
127
128 "${JAVAC}" $BOOTJAVAC_OPTS -d ${CLASSDIR} ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \
129 ${TOOLS}/ant/util/regexp/RegexpMatcher.java \
130 ${TOOLS}/ant/util/regexp/RegexpMatcherFactory.java \
131 ${TOOLS}/ant/property/*.java \
132 ${TOOLS}/ant/types/*.java \
133 ${TOOLS}/ant/types/resources/*.java \
134 ${TOOLS}/ant/*.java ${TOOLS}/ant/taskdefs/*.java \
135 ${TOOLS}/ant/taskdefs/compilers/*.java \
136 ${TOOLS}/ant/taskdefs/condition/*.java
137 ret=$?
138 if [ $ret != 0 ]; then
139 echo ... Failed compiling Ant classes !
140 exit $ret
141 fi
142
143 echo ... Copying Required Files
144
145 cp src/main/org/apache/tools/ant/taskdefs/defaults.properties \
146 ${CLASSDIR}/org/apache/tools/ant/taskdefs
147 cp src/main/org/apache/tools/ant/types/defaults.properties \
148 ${CLASSDIR}/org/apache/tools/ant/types
149 cp src/script/antRun bin
150 chmod +x bin/antRun
151
152 echo ... Building Ant Distribution
153
154 "${JAVACMD}" -classpath "${CLASSPATH}" -Dant.home=. $ANT_OPTS org.apache.tools.ant.Main -emacs "$@" bootstrap
155 ret=$?
156 if [ $ret != 0 ]; then
157 echo ... Failed Building Ant Distribution !
158 exit $ret
159 fi
160
161
162 echo ... Cleaning Up Build Directories
163
164 rm -rf ${CLASSDIR}
165 rm -rf bin
166
167 echo ... Done Bootstrapping Ant Distribution