#!/usr/bin/make -f

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

MAVEN_ARGS := -f maven/pom.xml -pl '!.'

%:
	dh $@ --buildsystem=maven

execute_before_dh_auto_configure:
	# Replace ${revision} with the actual version in the POMs
	sed -i.orig 's/\$${revision}/$(DEB_VERSION_UPSTREAM)/g' maven/*/pom.xml

override_dh_auto_build:
	dh_auto_build -- $(MAVEN_ARGS) package

override_dh_auto_test:
	dh_auto_test -- $(MAVEN_ARGS) test

override_dh_auto_install:
	dh_auto_install -- $(MAVEN_ARGS)

override_dh_auto_clean:
	dh_auto_clean -- $(MAVEN_ARGS) clean

	# Restore the original POMs
	for pom in maven/*/pom.xml.orig; do [ ! -f $$pom ] || mv $$pom $${pom%.orig}; done
