#!/usr/bin/make -f

# Add here any variable or target overrides you need
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/ant.mk

JAVA_HOME       := /usr/lib/jvm/default-java
LIBRARY_PACKAGE := jcommon
API_VERSION     := $(DEB_UPSTREAM_VERSION)

DEB_JARS := junit servlet-api-3.1

DEB_ANT_BUILDFILE := ant/build.xml
DEB_ANT_BUILD_TARGET := compile compile-xml javadoc
# FIXME: how to run this?
DEB_ANT_CHECK_TARGET := compile-junit-tests
MAVEN_REPO := http://repository.jboss.org/maven2

clean::
	mh_clean
	rm -rf build
	rm -rf javadoc
	rm -f $(LIBRARY_PACKAGE)-$(API_VERSION).jar 
	rm -f $(LIBRARY_PACKAGE)-xml-$(API_VERSION).jar
	rm -f lib/junit.jar lib/jcommon-$(API_VERSION)-junit.jar

install/lib$(LIBRARY_PACKAGE)-java:: 
	bnd wrap -properties debian/jcommon.bnd -output $(LIBRARY_PACKAGE)-$(API_VERSION).jar \
		$(LIBRARY_PACKAGE)-$(API_VERSION).jar
	dh_install -plib$(LIBRARY_PACKAGE)-java $(LIBRARY_PACKAGE)-xml-$(API_VERSION).jar /usr/share/java/
	dh_link -plib$(LIBRARY_PACKAGE)-java /usr/share/java/$(LIBRARY_PACKAGE)-xml-$(API_VERSION).jar /usr/share/java/$(LIBRARY_PACKAGE)-xml.jar
	mh_installpoms -plib$(LIBRARY_PACKAGE)-java
	mh_installjar -plib$(LIBRARY_PACKAGE)-java -l debian/poms/$(LIBRARY_PACKAGE).pom $(LIBRARY_PACKAGE)-$(API_VERSION).jar 

get-orig-pom:
	mkdir -p debian/poms
	wget  -U NoSuchBrowser/1.0 -O debian/poms/$(LIBRARY_PACKAGE).pom \
        $(MAVEN_REPO)/jfree/$(LIBRARY_PACKAGE)/$(DEB_UPSTREAM_VERSION)/$(LIBRARY_PACKAGE)-$(DEB_UPSTREAM_VERSION).pom

