You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

bootstrap.sh 4.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/bin/sh
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # OS specific support. $var _must_ be set to either true or false.
  17. cygwin=false
  18. darwin=false
  19. case "`uname`" in
  20. CYGWIN*)
  21. cygwin=true
  22. ;;
  23. Darwin*)
  24. darwin=true
  25. if [ -z "$JAVA_HOME" ]; then
  26. if [ -x '/usr/libexec/java_home' ]; then
  27. JAVA_HOME=`/usr/libexec/java_home`
  28. elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
  29. JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
  30. fi
  31. fi
  32. ;;
  33. esac
  34. # For Cygwin, ensure paths are in UNIX format before anything is touched
  35. if $cygwin; then
  36. [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  37. [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  38. fi
  39. # You will need to specify JAVA_HOME if compiling with 1.2 or later.
  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. if [ -f "$JAVA_HOME/lib/classes.zip" ]; then
  45. CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/classes.zip
  46. fi
  47. else
  48. echo "Warning: JAVA_HOME environment variable not set."
  49. echo " If build fails because sun.* classes could not be found"
  50. echo " you will need to set the JAVA_HOME environment variable"
  51. echo " to the installation directory of java."
  52. fi
  53. # IBM's JDK on AIX uses strange locations for the executables:
  54. # JAVA_HOME/jre/sh for java and rmid
  55. # JAVA_HOME/sh for javac and rmic
  56. if [ -z "$JAVAC" ]; then
  57. if [ -n "$JAVA_HOME" ]; then
  58. if [ -x "$JAVA_HOME/sh/javac" ]; then
  59. JAVAC=${JAVA_HOME}/sh/javac
  60. else
  61. JAVAC=${JAVA_HOME}/bin/javac
  62. fi
  63. else
  64. JAVAC=javac
  65. fi
  66. fi
  67. if [ -z "$JAVACMD" ]; then
  68. if [ -n "$JAVA_HOME" ]; then
  69. if [ -x "$JAVA_HOME/jre/sh/java" ]; then
  70. JAVACMD=$JAVA_HOME/jre/sh/java
  71. else
  72. JAVACMD=$JAVA_HOME/bin/java
  73. fi
  74. else
  75. JAVACMD=java
  76. fi
  77. fi
  78. if [ ! -x "$JAVACMD" ]; then
  79. echo "Error: JAVA_HOME is not defined correctly."
  80. echo " We cannot execute $JAVACMD"
  81. exit
  82. fi
  83. ANT_HOME=.
  84. export ANT_HOME
  85. echo ... Bootstrapping Ant Distribution
  86. if [ -d "bootstrap" ]; then
  87. rm -r bootstrap
  88. fi
  89. if [ -d "build" ]; then
  90. rm -r build
  91. fi
  92. DIRLIBS=lib/optional/*.jar
  93. for i in ${DIRLIBS}; do
  94. # if the directory is empty, then it will return the input string
  95. # this is stupid, so case for it
  96. if [ "$i" != "${DIRLIBS}" ]; then
  97. CLASSPATH=$CLASSPATH:"$i"
  98. fi
  99. done
  100. TOOLS=src/main/org/apache/tools
  101. CLASSDIR=build/classes
  102. CLASSPATH=${CLASSDIR}:src/main:${CLASSPATH}
  103. # For Cygwin, switch to Windows format before running java
  104. if $cygwin; then
  105. CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  106. fi
  107. export CLASSPATH
  108. mkdir -p build
  109. mkdir -p ${CLASSDIR}
  110. mkdir -p bin
  111. echo ... Compiling Ant Classes
  112. "${JAVAC}" $BOOTJAVAC_OPTS -d ${CLASSDIR} ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \
  113. ${TOOLS}/ant/util/regexp/RegexpMatcher.java \
  114. ${TOOLS}/ant/util/regexp/RegexpMatcherFactory.java \
  115. ${TOOLS}/ant/property/*.java \
  116. ${TOOLS}/ant/types/*.java \
  117. ${TOOLS}/ant/types/resources/*.java \
  118. ${TOOLS}/ant/*.java ${TOOLS}/ant/taskdefs/*.java \
  119. ${TOOLS}/ant/taskdefs/compilers/*.java \
  120. ${TOOLS}/ant/taskdefs/condition/*.java
  121. ret=$?
  122. if [ $ret != 0 ]; then
  123. echo ... Failed compiling Ant classes !
  124. exit $ret
  125. fi
  126. echo ... Copying Required Files
  127. cp src/main/org/apache/tools/ant/taskdefs/defaults.properties \
  128. ${CLASSDIR}/org/apache/tools/ant/taskdefs
  129. cp src/main/org/apache/tools/ant/types/defaults.properties \
  130. ${CLASSDIR}/org/apache/tools/ant/types
  131. cp src/script/antRun bin
  132. chmod +x bin/antRun
  133. echo ... Building Ant Distribution
  134. "${JAVACMD}" -classpath "${CLASSPATH}" -Dant.home=. $ANT_OPTS org.apache.tools.ant.Main -emacs "$@" bootstrap
  135. ret=$?
  136. if [ $ret != 0 ]; then
  137. echo ... Failed Building Ant Distribution !
  138. exit $ret
  139. fi
  140. echo ... Cleaning Up Build Directories
  141. rm -rf ${CLASSDIR}
  142. rm -rf bin
  143. echo ... Done Bootstrapping Ant Distribution