[Build-common-hackers] Bug#206408: cdbs: Please include Ant class

Stefan Gybas Stefan Gybas <sgybas@debian.org>, 206408@bugs.debian.org
Wed, 20 Aug 2003 17:52:00 +0200


This is a multi-part message in MIME format.
--------------080503090301060001080102
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Package: cdbs
Version: 0.4.5.2
Severity: wishlist
Tags: patch

Please include the attached CDBS class for Ant. Ant is a Java-based 
build system like make and is used by over 30 Debian source packages. I 
plan to migrate some of them to CDBS while they move from contrib to main.

If you want me to maintain this class directly in your CVS repository, 
please add me to your project on Alioth. I promise not to change any 
files that I don't understand. :-)

Stefan

--------------080503090301060001080102
Content-Type: text/plain;
 name="ant-vars.mk.in"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="ant-vars.mk.in"

# -*- 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
@PATH_RULES@
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

# 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 property file.
DEB_ANT_PROPERTYFILE := $(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)

# Add package-specific (or general) $ANT_OPTS and build.compiler if specified
DEB_ANT_INVOKE += $(if $(ANT_OPTS_$(cdbs_curpkg)),$(ANT_OPTS_$(cdbs_curpkg)),$(ANT_OPTS))
DEB_ANT_INVOKE += $(if $(DEB_ANT_COMPILER),-Dbuild.compiler=$(DEB_ANT_COMPILER),)

# Add property file if it exists and build file if set
DEB_ANT_INVOKE += $(if $(shell test -f $(DEB_ANT_PROPERTYFILE)),-propertyfile $(DEB_ANT_PROPERTYFILE),)
DEB_ANT_INVOKE += $(if $(DEB_ANT_BUILDFILE),-buildfile $(DEB_ANT_BUILDFILE),)

# 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

--------------080503090301060001080102
Content-Type: text/plain;
 name="ant.mk.in"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="ant.mk.in"

# -*- 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
@PATH_RULES@
endif

ifndef _cdbs_class_ant
_cdbs_class_ant := 1

include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
include $(_cdbs_class_path)/ant-vars.mk$(_cdbs_makefile_suffix)

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 ant-sanity-check
debian/stamp-ant-build:
	$(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

--------------080503090301060001080102
Content-Type: text/plain;
 name="cdbs-makefile.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cdbs-makefile.diff"

Index: Makefile.am
===================================================================
RCS file: /cvsroot/build-common/cdbs/Makefile.am,v
retrieving revision 1.23
diff -u -r1.23 Makefile.am
--- Makefile.am	6 Jul 2003 00:02:56 -0000	1.23
+++ Makefile.am	20 Aug 2003 15:43:08 -0000
@@ -36,6 +36,8 @@
 		1/rules/simple-patchsys.mk	\
 		1/rules/utils.mk		\
 		1/rules/tarball.mk		\
+		1/class/ant-vars.mk		\
+		1/class/ant.mk			\
 		1/class/autotools-vars.mk	\
 		1/class/autotools-files.mk	\
 		1/class/autotools.mk		\

--------------080503090301060001080102--