OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
6.8 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: package/.../java-dirtree/java-conf.in
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. # Common java configuration is needed as well.
  16. . $base/package/*/*/java-common-conf.in
  17. # Defaults
  18. auto_detect=on
  19. build_type=
  20. # Prevent executing normal make and install build steps.
  21. # Java packages have custom make and install.
  22. makeopt=''
  23. makeinstopt=''
  24. # Set variables used for building java sources to there default values.
  25. # builddocdir - Location where documentation can be found after building.
  26. # buildjardir - Location where build results (jarfiles) can be found.
  27. # buildtarget - target(Ant)/goal(Maven) to be used for building.
  28. # buildfile - buildfile containing the build rules.
  29. builddocdir=dist/docs
  30. buildjardir=dist
  31. buildtarget=dist
  32. buildfile=
  33. # -------------------------------------------------------------------------
  34. #
  35. # -------------------------------------------------------------------------
  36. maven1_build() {
  37. echo_status "Java buildstyle: Maven (version 1)"
  38. # Maven 2 needs to be installed to be able to use it.
  39. pkgprefix -t maven1
  40. # Invoke maven to start building. However, we strictly
  41. # forbid downloading dependancies from remote repositories.
  42. # All dependancies should be build locally and added to
  43. # the local repository.
  44. $root/$(pkgprefix bindir maven1)/maven \
  45. -Dmaven.repo.remote.enabled=false \
  46. $mavengoals --pom $1
  47. }
  48. # -------------------------------------------------------------------------
  49. #
  50. # -------------------------------------------------------------------------
  51. maven2_build() {
  52. echo_status "Java buildstyle: Maven (version 2)"
  53. # Maven 2 needs to be installed to be able to use it.
  54. pkgprefix -t maven
  55. abort "MAVEN2 building NOT yet implemented."
  56. }
  57. # -------------------------------------------------------------------------
  58. # ant_build: Starts the apache ant build tool.
  59. #
  60. # Besides starting the apache build tool. The results of building are
  61. # gathered and moved to right place. For this two things are considered.
  62. # dist/docs for documentation.
  63. # dist/*.jar for java jar files/libraries.
  64. #
  65. # IMPORTANT VARIABLES:
  66. # builddocdir - Location where documentation will be.
  67. # buildjardir - Location where build result will be.
  68. # buildtarget - Ant target to be used for building.
  69. # -------------------------------------------------------------------------
  70. ant_build() {
  71. echo_status "Java buildstyle: Apache Ant"
  72. # Ant needs to be installed to be able to use it.
  73. pkgprefix -t apache-ant
  74. # Invoke Ant to start building.
  75. $root/$(pkgprefix bindir apache-ant)/ant -buildfile $1 \
  76. -lib $(pkgprefix libdir java-dirtree) \
  77. $antopt $buildtarget
  78. # Copy all created jar files to the package libdir.
  79. echo "Trying to copy package jar files."
  80. if ls $buildjardir/*.jar 2> /dev/null ; then
  81. cp -v $buildjardir/*.jar $root/$libdir
  82. else
  83. # Strange. No jar files available?
  84. echo "Package $pkg produces no jar files in $buildjardir/."
  85. fi
  86. # Copy all documentation to the package docdir.
  87. echo "Trying to copy package documentaion."
  88. tempdir=$builddocdir
  89. if [ -d $tempdir ] ; then
  90. ( cd $tempdir; tar -c * | tar -x -C $root/$docdir )
  91. fi
  92. unset tempdir
  93. }
  94. # -------------------------------------------------------------------------
  95. # set_build_type: Sets the java build type.
  96. #
  97. # Sets the java build type to be used for building the current package.
  98. # -------------------------------------------------------------------------
  99. set_build_type() {
  100. local builder_func=
  101. # Build type can only be set once per package, check if it
  102. # has already been set.
  103. if [ -n "$build_type" ] ; then
  104. echo "Buildtype already set ($build_type), can't set it to '$1'"
  105. Abort "java-conf.in: Buildtype can only be set once."
  106. fi
  107. build_type="$1"
  108. case "$build_type" in
  109. ANT) builder_func="ant_build ${buildfile:-build.xml}" ;;
  110. MAVEN) todo ;;
  111. SCRIPT) todo ;;
  112. *) abort "java-conf.in: Unknown buildtype $1 specified." ;;
  113. esac
  114. # Since the built type is set, auto detection is no longer needed.
  115. auto_detect=off
  116. # Set the inmake hook to use the given builder type.
  117. hook_add inmake 5 "$builder_func"
  118. }
  119. # Before we continue lets process all command line options.
  120. while [ "$1" ] ; do
  121. case "$1" in
  122. NO_AUTO_DETECT) auto_detect=off ;
  123. echo_status "Java buildstyle: Autodetect disabled." ;;
  124. BUILD_TYPE=*) set_build_type ${1#*=} ;;
  125. BUILD_FILE=*) buildfile=${1#*=} ;;
  126. *) abort "java-conf.in: Unknown arguments" ;;
  127. esac
  128. shift
  129. done
  130. # Check if at least one of the jdk's is available right now.
  131. if [ -z $JAVA_HOME ]; then
  132. # No jdk available, continueing is pointless.
  133. abort "At least one of the JDK's need to be installed."
  134. fi
  135. # This function determines the maven version to be used on
  136. # the given input file.
  137. # param: pom/project filename
  138. # return: the pom/project file major version number.
  139. detect_maven_version() {
  140. # Todo: look inside the file to determine the version.
  141. echo "3"
  142. }
  143. # We know how to build Ant, Maven and Maven 2 style projects.
  144. # build and build.sh scripts are ignored on purpose. By controlling
  145. # the build in here we might make it easier to build packages using
  146. # exotic compilers like gcj or jikes.
  147. determine_build_type() {
  148. local buildtype=
  149. # Check if the Ant build.xml file is available.
  150. if [ -f build.xml ]; then
  151. # Package can be build using Ant. However this might be
  152. # overruled by any of the others.
  153. buildtype="ANT"
  154. fi
  155. # Check if the Maven pom.xml or project.xml file is available.
  156. for mavenfile in pom.xml project.xml; do
  157. # Check if the maven file exists
  158. if [ -f $mavenfile ]; then
  159. # A maven file is available, but what maven
  160. # version should be used? The projectfile
  161. # version can tell us.
  162. pomversion=`detect_maven_version $mavenfile`
  163. case "$pomversion" in
  164. 4*) builder_func="maven2_build $mavenfile" ;;
  165. # In all other cases we use maven 1.
  166. *) builder_func="maven1_build $mavenfile" ;;
  167. esac
  168. fi
  169. done
  170. # Check if we have found an appropriate java builder.
  171. if [ -n "$buildtype" ]; then
  172. # Set the selected build type.
  173. set_build_type $buildtype
  174. else
  175. # Auto detection of the build style resulted into
  176. # nothing. So from here on it is up to the package
  177. # to decide how to continue building the package.
  178. echo_status "Java buildstyle: Unknown buildstyle"
  179. fi
  180. }
  181. # Check if autodetection of the build process is required.
  182. if [ "$auto_detect" == "on" ] ; then
  183. # We use a postpatch hook to determine what kind of build process
  184. # is needed. When we know we set the inmake hook appropriately.
  185. hook_add postpatch 5 determine_build_type
  186. fi