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.

215 lines
6.9 KiB

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