CDBS class for Ant, was Re: [PROPOSAL] dh_ant
- To: Debian Java Mailing List <debian-java@lists.debian.org>
- Subject: CDBS class for Ant, was Re: [PROPOSAL] dh_ant
- From: Stefan Gybas <sgybas@debian.org>
- Date: Thu, 14 Aug 2003 22:27:05 +0200
- Message-id: <[🔎] 3F3BF099.5030305@debian.org>
- In-reply-to: <1059406108.1277.1.camel@localhost>
- References: <20030728.131835.78729656.arnaud-guest@users.alioth.debian.org> <3F251B67.10001@provective.de> <1059406108.1277.1.camel@localhost>
Ross Burton wrote:
Excellent plan. CDBS is a godsend for packaging GNOME software (2
includes).
I think it is now also for Ant-based java software. :-) Attached is the
first version of ant.mk and ant-vars.mk for CDBS. I have tested it with
some packages, for example debian/rules for Commons Beanutils can now
look like this:
--- cut here ---
#!/usr/bin/make -f
# debian/rules for Commons Beanutils (uses CDBS)
include /usr/share/cdbs/1/rules/debhelper.mk
include debian/ant.mk
JAVA_HOME_DIRS := /usr/lib/j2se/1.3 /usr/lib/j2sdk1.3
ANT_HOME := /usr/share/ant
DEB_JARS := commons-collections commons-logging
#DEB_ANT_COMPILER := jikes
DEB_ANT_BUILD_TARGET := dist javadoc
LIBRARY=commons-beanutils
VERSION=1.6
install/lib${LIBRARY}-java::
install -m 644 dist/${LIBRARY}.jar \
$(CURDIR)/debian/lib${LIBRARY}-java/usr/share/java/...
...${LIBRARY}-${VERSION}.jar [line manually splitted]
dh_movefiles --sourcedir=debian/lib${LIBRARY}-java
--- cut here ---
If you are maintaining a package which uses Ant please test the new
build system and send me feedback. I'll submit the two files to the CDBS
authors if I don't receive any compaints or suggestions for major
changes in the next days.
Stefan
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2003 Stefan Gybas <sgybas@debian.org>
# Description: Builds and cleans packages which have an Ant build.xml file
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
ifndef _cdbs_bootstrap
_cdbs_scripts_path ?= /usr/lib/cdbs
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
_cdbs_class_path ?= /usr/share/cdbs/1/class
endif
ifndef _cdbs_class_ant
_cdbs_class_ant := 1
include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
# TODO: include $(_cdbs_class_path)/ant-vars.mk$(_cdbs_makefile_suffix)
include debian/ant-vars.mk
DEB_PHONY_RULES += ant-sanity-check
ant-sanity-check:
@if ! test -d "$(JAVA_HOME)"; then \
echo "You must specify a valid JAVA_HOME directory!"; \
exit 1; \
fi
@if ! test -d "$(ANT_HOME)"; then \
echo "You must specify a valid ANT_HOME directory!"; \
exit 1; \
fi
common-build-arch common-build-indep:: debian/stamp-ant-build
debian/stamp-ant-build: ant-sanity-check
$(DEB_ANT_INVOKE) $(DEB_ANT_BUILD_TARGET)
touch debian/stamp-ant-build
clean:: ant-sanity-check
$(DEB_ANT_INVOKE) $(DEB_ANT_CLEAN_TARGET) || true
rm -f debian/stamp-ant-build
common-install-arch common-install-indep:: common-install-impl
common-install-impl::
@if test -n "$(DEB_ANT_INSTALL_TARGET)"; then \
echo $(DEB_ANT_INVOKE) $(DEB_ANT_INSTALL_TARGET); \
$(DEB_ANT_INVOKE) $(DEB_ANT_INSTALL_TARGET); \
else \
echo "DEB_ANT_INSTALL_TARGET unset, skipping default ant.mk common-install target"; \
fi
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
common-post-build-arch common-post-build-indep:: common-post-build-impl
common-post-build-impl::
@if test -n "$(DEB_ANT_CHECK_TARGET)"; then \
echo $(DEB_ANT_INVOKE) $(DEB_ANT_CHECK_TARGET); \
$(DEB_ANT_INVOKE) $(DEB_ANT_CHECK_TARGET); \
else \
echo "DEB_ANT_CHECK_TARGET unset, not running checks"; \
fi
endif
endif
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2003 Stefan Gybas <sgybas@debian.org>
# Description: Defines useful variables for packages which use Ant
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
ifndef _cdbs_bootstrap
_cdbs_scripts_path ?= /usr/lib/cdbs
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
_cdbs_class_path ?= /usr/share/cdbs/1/class
endif
ifndef _cdbs_class_ant_vars
_cdbs_class_ant_vars := 1
# The home directory of the Java Runtime Environment (JRE) or Java Development
# Kit (JDK). You can either directly set JAVA_HOME in debian/rules or set
# JAVA_HOME_DIRS to multilpe possbile home directories. The first existing
# directory from this list is used for JAVA_HOME. You can also override
# JAVACMD in case you don't want to use the default.
JAVA_HOME = $(shell for jh in $(JAVA_HOME_DIRS); do if [ -d "$$jh" ]; then \
echo $${jh}; exit 0; fi; done)
JAVACMD = $(JAVA_HOME)/bin/java
# You can list all Java ARchives (JARs) to be added to the class path in
# DEB_JARS, either with their full path or just the basename if the JAR is
# in /usr/share/java. You may also ommit the ".jar" extension. Non-existing
# files will silently be ignored. tools.jar is automatically added to the
# end of the class path if it exists in the JDK's lib directory.
# You can override the complete class path using DEB_CLASSPATH.
DEB_JARS_BASE := /usr/share/java
DEB_CLASSPATH = $(ANT_HOME)/lib/ant.jar:$(shell for jar in $(DEB_JARS); do \
if [ -f "$$jar" ]; then echo -n "$${jar}:"; fi; \
if [ -f "$$jar".jar ]; then echo -n "$${jar}.jar:"; fi; \
if [ -f $(DEB_JARS_BASE)/"$$jar" ]; then echo -n "$(DEB_JARS_BASE)/$${jar}:"; fi; \
if [ -f $(DEB_JARS_BASE)/"$$jar".jar ]; then echo -n "$(DEB_JARS_BASE)/$${jar}.jar:"; fi; \
done; \
if [ -f "$(JAVA_HOME)/lib/tools.jar" ]; then echo -n "$(JAVA_HOME)/lib/tools.jar"; fi)
# Options for Ant: compile.debug, compile.optimize and build.compiler
# depending on DEB_BUILD_OPTION and DEB_ANT_COMPILER
# You can specify additional Ant options in ANT_OPTS or override the default
# options. ANT_OPTS_<package> can also be definied for each package.
DEB_ANT_DEFAULT_OPTIONS = -Dcompile.debug=true
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
DEB_ANT_DEFAULT_OPTIONS += -Dcompile.optimize=false
else
DEB_ANT_DEFAULT_OPTIONS += -Dcompile.optimize=true
endif
ifneq (,$(DEB_ANT_COMPILER))
DEB_ANT_DEFAULT_OPTIONS += -Dbuild.compiler=$(DEB_ANT_COMPILER)
endif
# Property file for Ant, defaults to debian/ant.properties. You may define
# additional properties that are referenced from build.xml there so you don't
# have to modify upstream's build.xml. Please note that command line options,
# e.g. compile.optimize or build.compiler override the settins in build.xml
# and the properties file.
DEB_ANT_PROPERTY_FILE := $(CURDIR)/debian/ant.properties
DEB_ANT_INVOKE = cd $(DEB_BUILDDIR) && $(JAVACMD) -classpath $(DEB_CLASSPATH) $(DEB_JVM_ARGS) -Dant.home=$(ANT_HOME) org.apache.tools.ant.Main $(DEB_ANT_DEFAULT_OPTIONS) $(if $(ANT_OPTS_$(cdbs_curpkg)),$(ANT_OPTS_$(cdbs_curpkg)),$(ANT_OPTS)) $(if $(shell test -f $(DEB_ANT_PROPERTY_FILE)),-propertyfile $(DEB_ANT_PROPERTY_FILE),)
# Targets to invoke for building, installing, testing and cleaning up.
# Building uses the default target from build.xml, installing and testing is
# only called if the corresponding variable is set. You can # also specify
# multiple targets for each step.
DEB_ANT_BUILD_TARGET =
DEB_ANT_INSTALL_TARGET =
DEB_ANT_TEST_TARGET =
DEB_ANT_CLEAN_TARGET = clean
endif
Reply to: