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.8 kB

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