#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

DEB_VERSION_ORIG = $(shell echo ${DEB_VERSION_UPSTREAM} | cut -d + -f 1)

%:
	dh $@ --buildsystem ant --with maven_repo_helper

override_dh_auto_build:
	grep --silent --fixed-strings ${DEB_VERSION_ORIG} debian/poms/xom.pom # ensure POM is up-to-date
	dh_auto_build -- jar samples javadoc
	cp build/xom-$(DEB_VERSION_ORIG).jar build/xom.jar
	cp build/xom-samples.jar build/xom-samples-$(DEB_VERSION_ORIG).jar

override_dh_auto_test:
	dh_auto_build -- test

get-orig-pom:
	mkdir -p debian/poms
	wget -U 'debian/rules of xom Debian package' -O debian/poms/xom.pom \
		https://repo1.maven.org/maven2/xom/xom/$(DEB_VERSION_ORIG)/xom-$(DEB_VERSION_ORIG).pom
	patch debian/poms/xom.pom debian/poms/add-jaxen.patch


DEB_PHONY_RULES += get-orig-pom
