summaryrefslogtreecommitdiff
path: root/devel/maven-wrapper/files/mvn.sh.in
blob: 16506f407246e87ade41e5b615e52d40d2cb31fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

set -e

if [ -f "%%PREFIX%%/etc/maven/setenv.sh" ] ; then
	. "%%PREFIX%%/etc/maven/setenv.sh"
fi

if [ -z "${M2_HOME}" ] ; then
	INSTANCES_DIRECTORY="/usr/local/etc/maven-wrapper/instances.d"
	INSTANCE="`%%FIND%% -s "${INSTANCES_DIRECTORY}" -type f -mindepth 1 -maxdepth 1 | %%TAIL%% -n 1`"

	if [ -z "${INSTANCE}" ] ; then
		echo "could not find a Maven instance! (${INSTANCES_DIRECTORY})" >&2
		exit 1
	fi

	M2_HOME="`%%CAT%% "${INSTANCE}"`"

	if [ ! -d "${M2_HOME}" ] ; then
		echo "not a directory: ${M2_HOME}" >&2
		exit 2
	fi
fi

export M2_HOME
exec "${M2_HOME}/bin/mvn" "$@"