1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/java-dirtree/java-conf.in
3 # Copyright (C) 2004 - 2021 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
12 # Common java configuration is needed as well.
13 . $base/package/*/*/java-common-conf.in
19 # Prevent executing normal make and install build steps.
20 # Java packages have custom make and install.
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.
34 # -------------------------------------------------------------------------
36 # -------------------------------------------------------------------------
38 echo_status "Java buildstyle: Maven (version 1)"
40 # Maven 2 needs to be installed to be able to use it.
43 # Invoke maven to start building. However, we strictly
44 # forbid downloading dependancies from remote repositories.
45 # All dependancies should be build locally and added to
46 # the local repository.
47 $root/$(pkgprefix bindir maven1)/maven \
48 -Dmaven.repo.remote.enabled=false \
52 # -------------------------------------------------------------------------
54 # -------------------------------------------------------------------------
56 echo_status "Java buildstyle: Maven (version 2)"
58 # Maven 2 needs to be installed to be able to use it.
61 abort "MAVEN2 building NOT yet implemented."
64 # -------------------------------------------------------------------------
65 # ant_build: Starts the apache ant build tool.
67 # Besides starting the apache build tool. The results of building are
68 # gathered and moved to right place. For this two things are considered.
69 # dist/docs for documentation.
70 # dist/*.jar for java jar files/libraries.
72 # IMPORTANT VARIABLES:
73 # builddocdir - Location where documentation will be.
74 # buildjardir - Location where build result will be.
75 # buildtarget - Ant target to be used for building.
76 # -------------------------------------------------------------------------
78 echo_status "Java buildstyle: Apache Ant"
80 # Ant needs to be installed to be able to use it.
81 pkgprefix -t apache-ant
83 # Invoke Ant to start building.
84 $root/$(pkgprefix bindir apache-ant)/ant -buildfile $1 \
85 -lib $(pkgprefix libdir java-dirtree) \
88 # Copy all created jar files to the package libdir.
89 echo "Trying to copy package jar files."
90 if ls $buildjardir/*.jar 2> /dev/null; then
91 cp -v $buildjardir/*.jar $root$libdir
93 # Strange. No jar files available?
94 echo "Package $pkg produces no jar files in $buildjardir/."
97 # Copy all documentation to the package docdir.
98 echo "Trying to copy package documentaion."
100 if [ -d $tempdir ]; then
101 ( cd $tempdir; tar -c * | tar -x -C $root$docdir )
106 # -------------------------------------------------------------------------
107 # set_build_type: Sets the java build type.
109 # Sets the java build type to be used for building the current package.
110 # -------------------------------------------------------------------------
114 # Build type can only be set once per package, check if it
115 # has already been set.
116 if [ -n "$build_type" ]; then
117 echo "Buildtype already set ($build_type), can't set it to '$1'"
118 Abort "java-conf.in: Buildtype can only be set once."
122 case "$build_type" in
123 ANT) builder_func="ant_build ${buildfile:-build.xml}" ;;
126 *) abort "java-conf.in: Unknown buildtype $1 specified." ;;
129 # Since the built type is set, auto detection is no longer needed.
132 # Set the inmake hook to use the given builder type.
133 hook_add inmake 5 "$builder_func"
136 # Before we continue lets process all command line options.
139 NO_AUTO_DETECT) auto_detect=off ;
140 echo_status "Java buildstyle: Autodetect disabled." ;;
141 BUILD_TYPE=*) set_build_type ${1#*=} ;;
142 BUILD_FILE=*) buildfile=${1#*=} ;;
143 *) abort "java-conf.in: Unknown arguments" ;;
148 # Check if at least one of the jdk's is available right now.
149 if [ -z $JAVA_HOME ]; then
150 # No jdk available, continueing is pointless.
151 abort "At least one of the JDK's need to be installed."
154 # This function determines the maven version to be used on
155 # the given input file.
156 # param: pom/project filename
157 # return: the pom/project file major version number.
158 detect_maven_version() {
159 # Todo: look inside the file to determine the version.
163 # We know how to build Ant, Maven and Maven 2 style projects.
164 # build and build.sh scripts are ignored on purpose. By controlling
165 # the build in here we might make it easier to build packages using
166 # exotic compilers like gcj or jikes.
167 determine_build_type() {
170 # Check if the Ant build.xml file is available.
171 if [ -f build.xml ]; then
172 # Package can be build using Ant. However this might be
173 # overruled by any of the others.
177 # Check if the Maven pom.xml or project.xml file is available.
178 for mavenfile in pom.xml project.xml; do
179 # Check if the maven file exists
180 if [ -f $mavenfile ]; then
181 # A maven file is available, but what maven
182 # version should be used? The projectfile
183 # version can tell us.
184 pomversion=`detect_maven_version $mavenfile`
185 case "$pomversion" in
186 4*) builder_func="maven2_build $mavenfile" ;;
187 # In all other cases we use maven 1.
188 *) builder_func="maven1_build $mavenfile" ;;
193 # Check if we have found an appropriate java builder.
194 if [ -n "$buildtype" ]; then
195 # Set the selected build type.
196 set_build_type $buildtype
198 # Auto detection of the build style resulted into
199 # nothing. So from here on it is up to the package
200 # to decide how to continue building the package.
201 echo_status "Java buildstyle: Unknown buildstyle"
205 # Check if autodetection of the build process is required.
206 if [ "$auto_detect" == "on" ]; then
207 # We use a postpatch hook to determine what kind of build process
208 # is needed. When we know we set the inmake hook appropriately.
209 hook_add postpatch 5 determine_build_type