1 ################################################################################
3 # ant.cygclass - functions for building Java packages with Ant
5 # Part of cygport - Cygwin packaging application
6 # Copyright (C) 2006-2020 Cygport authors
7 # Provided by the Cygwin project <https://cygwin.com/>
9 # cygport is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # cygport is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with cygport. If not, see <https://www.gnu.org/licenses/>.
22 ################################################################################
24 #****ih* Cygclasses/ant.cygclass
28 # Apache Ant is a build system written in Java and used in many Java projects.
29 # The build is controlled by a single XML file, named 'build.xml' by default,
30 # which specifies the targets to be built, the commands to build them, and the
31 # options which may be given to control the build.
33 # Ant includes support for a number of commands (called tasks), including
34 # compiling and executing Java code, generating documentation, downloading
35 # files, de/compressing archives, and running testsuites. Third-party Ant
36 # tasks also exist to support additional commands.
38 # This cygclass builds packages which use the Ant build system.
49 #****id* ant.cygclass/ANT
51 # Absolute path to the Ant build tool.
55 #****id* ant.cygclass/ANT_HOME
57 # Root datadir for the Ant build tool. This definition is exported to the
60 export ANT_HOME=/usr/share/ant
62 #****iv* ant.cygclass/ANT_OPTS
64 # Options for the Ant build tool to pass to the Java runtime, e.g. -Xmx.
65 # This definition is exported to the build environment.
69 #****iv* ant.cygclass/ANT_BUILD_XML
71 # Name or relative path of the Ant build file. This need only be defined
72 # if it is not build.xml (the default).
75 #****iC* ant.cygclass/cygant
79 # Runs Ant with the given options, if any.
82 local fileargs task taskpath
84 if [ ! -e ${ANT_BUILD_XML:-build.xml} ]
86 error "Ant build.xml file not found"
89 for task in ${ANT_TASKS//,/ }
92 oro|regexp) taskpath+=${JAVA_DIR}/jakarta-${task}.jar: ;;
93 *) taskpath+=${JAVA_DIR}/${task}.jar: ;;
96 taskpath+=${JAVA_DIR}/xalan.jar:${JAVA_DIR}/xercesImpl.jar:${JAVA_DIR}/xml-apis.jar:${CLASSPATH}
98 if defined ANT_BUILD_XML
100 fileargs="-f ${ANT_BUILD_XML}"
104 /usr/bin/ant -lib ${taskpath} ${fileargs} ${@} || error "ant build failed"
107 #****iI* ant.cygclass/doanttask
109 # doanttask JAR_FILE [JAR_FILE] ...
111 # Installs the given .jar file(s) into the Ant task directory.
114 local _insinto_tmp=${_insinto_dir}
116 insinto ${ANT_HOME}/lib
119 _insinto_dir=${_insinto_tmp}
122 #****iv* ant.cygclass/ANT_BUILD_ARGS
124 # Arguments to pass to the Ant build command if this src_compile is used.
126 #****iv* ant.cygclass/ANT_BUILD_TARGETS
128 # Target(s) to be built during the Ant build command if this src_compile is used.
131 #****io* ant.cygclass/src_compile (ant)
136 cygant ${ANT_BUILD_ARGS} ${ANT_BUILD_TARGETS}
140 #****iv* ant.cygclass/ANT_TEST_ARGS
142 # Arguments to pass to Ant during testing if this src_test is used.
144 #****iv* ant.cygclass/ANT_TEST_TARGETS
146 # Target(s) to be built to run the testsuite if this src_test is used.
149 #****io* ant.cygclass/src_test (ant)
153 ANT_TASKS="${ANT_TASKS} junit" cygant ${ANT_TEST_ARGS} ${ANT_TEST_TARGETS:-test}
157 #****iv* ant.cygclass/ANT_INSTALL_JARS
159 # Relative paths of .jar files to be installed by ant_install.
161 #****iv* ant.cygclass/ANT_INSTALL_JAVADOC
163 # Relative paths of javadoc directories to be installed by ant_install.
165 #****iv* ant.cygclass/ANT_INSTALL_TASKS
167 # Relative paths of Ant task .jar files to be installed by ant_install.
169 #****iv* ant.cygclass/ANT_INSTALL_WRAPPERS
171 # ANT_INSTALL_WRAPPERS="name1,name1.jar[,main.class1] name2,name2.jar[,main.class2] ..."
173 # Comma-delineated set of arguments to pass to java_wrapper. Multiple
174 # wrappers can be created by separating the argument sets with spaces.
177 #****iI* ant.cygclass/ant_install
181 # Installs the files and directories specified by ANT_INSTALL_JARS,
182 # ANT_INSTALL_JAVADOC, and/or ANT_INSTALL_TASKS, at least one of which
188 if ! defined ANT_INSTALL_JARS && ! defined ANT_INSTALL_JAVADOC && ! defined ANT_INSTALL_TASKS
190 error "ant_install: ANT_INSTALL_* all undefined; nothing to install"
193 if defined ANT_INSTALL_JARS
195 dojar ${ANT_INSTALL_JARS}
197 if defined ANT_INSTALL_JAVADOC
199 dojavadoc ${ANT_INSTALL_JAVADOC}
201 if defined ANT_INSTALL_TASKS
203 doanttask ${ANT_INSTALL_TASKS}
206 for wrap in ${ANT_INSTALL_WRAPPERS}
208 java_wrapper ${wrap//,/ }
212 #****io* ant.cygclass/src_install (ant)
220 readonly -f cygant doanttask ant_install