#!/usr/bin/make -f

include /usr/share/dpkg/default.mk
include /usr/share/java/java_defaults.mk

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure
	# Maven fails if the module version has ${revision} and the parent POM
	# has an actual version number instead of "${revision}"; misfeature?
	sed -i -e '/<version>.*<\/version>/ { s/>[^<]\+</>$${revision}</ ; ta } ; p ; d ; :a { n ; s/.*\n// ; ba }' \
		pom.xml

override_dh_auto_install:
	# And now Maven fails even with both module and parent in sync
	sed -i -e '/<version>.*<\/version>/ { s/>[^<]\+</>$(DEB_VERSION_UPSTREAM)</ ; ta } ; p ; d ; :a { n ; s/.*\n// ; ba }' \
		pom.xml
	sed -i -e '/<version>.*<\/version>/ { s/>[^<]\+</>$(DEB_VERSION_UPSTREAM)</ ; ta } ; p ; d ; :a { n ; /<version>.*<\/version>/ { s/>[^<]\+</>$(DEB_VERSION_UPSTREAM)</ ; tb } ; s/.*\n// ; ba } ; :b { n ; s/.*\n// ; bb }' \
		fastdoubleparser-java8/pom.xml \
	        fastdoubleparser-java11/pom.xml \
		fastdoubleparser-java17/pom.xml \
	        fastdoubleparser-java21/pom.xml \
		fastdoubleparser/pom.xml
	dh_auto_install

	# could not figure out how to build these but not install them
	find debian/libfastdoubleparser-java/ -regex '.*/fastdoubleparser-java[0-9].*' -delete
