#!/usr/bin/make -f

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

export CLASSPATH = $(shell cat debian/build-classpath | xargs | tr ' ' :)

UPSTREAM_VERSION = $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d '+' -f 1 )

%:
	dh $@ --with javahelper

override_dh_auto_build:
	find . -name internalClusterTest -o -name javaRestTest -o -name test -o -name yamlRestTest | xargs rm -rf
	rm -rf modules/ingest-geoip # Cannot be built due to missing build dependencies
	find distribution/src/ -type f | grep -v '\.exe$$' | xargs debian/fill-gradle-template distribution/build.gradle
	jh_build --javacopts='-source 11 -encoding UTF-8' --no-javadoc opensearch-$(UPSTREAM_VERSION).jar client/ distribution/tools/java-version-checker/ distribution/tools/keystore-cli/ distribution/tools/launchers/ libs/ modules/ server/
	ln -s opensearch-$(UPSTREAM_VERSION).jar opensearch.jar
