git: 5f0ee47286fc - main - devel/maven-wrapper: massively update port, align with devel/maven

From: Kurt Jaeger <pi_at_FreeBSD.org>
Date: Thu, 28 Jul 2022 15:55:43 UTC
The branch main has been updated by pi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5f0ee47286fc1f0350efda5e88bd114a9a9b80a5

commit 5f0ee47286fc1f0350efda5e88bd114a9a9b80a5
Author:     Michael Osipov <michaelo@apache.org>
AuthorDate: 2022-07-28 15:53:13 +0000
Commit:     Kurt Jaeger <pi@FreeBSD.org>
CommitDate: 2022-07-28 15:55:11 +0000

    devel/maven-wrapper: massively update port, align with devel/maven
    
    - Submitter changes MAINTAINER to his @apache.org address
    - Bump version to 2
    - Use ETCDIR wherever possible
    - Also install mvnDebug
    - Burry long dead M2_HOME in favor of MAVEN_HOME which
      will *never* be propagated
    
    PR: 265028, 265025
---
 UPDATING                            |  7 ++++++
 devel/maven-wrapper/files/mvn.sh.in | 21 ++++++++---------
 devel/maven-wrapper/pkg-descr       |  4 ++--
 devel/maven-wrapper/pkg-plist       |  3 ++-
 devel/maven/files/mvn.sh.in         | 46 -------------------------------------
 5 files changed, 20 insertions(+), 61 deletions(-)

diff --git a/UPDATING b/UPDATING
index 6d76e6add9b7..d73e9010cf42 100644
--- a/UPDATING
+++ b/UPDATING
@@ -18,6 +18,13 @@ you update your ports collection, before attempting any port upgrades.
   # pkill stunnel;service stunnel start
   after the upgrade has been completed.
 
+202207XYZ:
+  AFFECTS: users of devel/maven-wrapper and devel/maven
+  AUTHOR: michaelo@apache.org
+
+  The environment variable M2_HOME has been replaced with more common
+  MAVEN_HOME which can be used to pass a custom Maven home directory.
+
 20220628:
   AFFECTS: users of Erlang and Elixir
   AUTHOR: dch@FreeBSD.org
diff --git a/devel/maven-wrapper/files/mvn.sh.in b/devel/maven-wrapper/files/mvn.sh.in
index 16506f407246..a822dfef5819 100644
--- a/devel/maven-wrapper/files/mvn.sh.in
+++ b/devel/maven-wrapper/files/mvn.sh.in
@@ -2,26 +2,23 @@
 
 set -e
 
-if [ -f "%%PREFIX%%/etc/maven/setenv.sh" ] ; then
-	. "%%PREFIX%%/etc/maven/setenv.sh"
-fi
+SCRIPT_NAME="$(basename $0)"
 
-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 "${MAVEN_HOME}" ] ; then
+	INSTANCES_DIRECTORY="%%ETCDIR%%/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
+		echo "Could not find a Maven instance in ${INSTANCES_DIRECTORY}" >&2
 		exit 1
 	fi
 
-	M2_HOME="`%%CAT%% "${INSTANCE}"`"
+	MAVEN_HOME="$(%%CAT%% "${INSTANCE}")"
 
-	if [ ! -d "${M2_HOME}" ] ; then
-		echo "not a directory: ${M2_HOME}" >&2
+	if [ ! -d "${MAVEN_HOME}" ] ; then
+		echo "Not a directory: ${MAVEN_HOME}" >&2
 		exit 2
 	fi
 fi
 
-export M2_HOME
-exec "${M2_HOME}/bin/mvn" "$@"
+exec "${MAVEN_HOME}/bin/${SCRIPT_NAME}" "$@"
diff --git a/devel/maven-wrapper/pkg-descr b/devel/maven-wrapper/pkg-descr
index a75f8cd0d9a7..febfe74f39ac 100644
--- a/devel/maven-wrapper/pkg-descr
+++ b/devel/maven-wrapper/pkg-descr
@@ -1,7 +1,7 @@
 The maven-wrapper provides a convenient way to switch between several Maven
 installations.
 
-- By setting the M2_HOME environment variable the user can select the Maven
+- By setting the MAVEN_HOME environment variable the user can select the Maven
   instance to use.
 - A default Maven instance is selected according to the files in
-  /usr/local/etc/maven/instances.d/
+  /usr/local/etc/maven-wrapper/instances.d/
diff --git a/devel/maven-wrapper/pkg-plist b/devel/maven-wrapper/pkg-plist
index 08a1b2b15539..01389ee11108 100644
--- a/devel/maven-wrapper/pkg-plist
+++ b/devel/maven-wrapper/pkg-plist
@@ -1,2 +1,3 @@
 bin/mvn
-@dir etc/maven-wrapper/instances.d
+bin/mvnDebug
+@dir %%ETCDIR%%/instances.d
diff --git a/devel/maven/files/mvn.sh.in b/devel/maven/files/mvn.sh.in
deleted file mode 100644
index cb8111acfea2..000000000000
--- a/devel/maven/files/mvn.sh.in
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-#
-
-if [ -f /etc/mavenrc ] ; then
-	. /etc/mavenrc
-fi
-
-if [ -f "${HOME}/.mavenrc" ] ; then
-	. "${HOME}/.mavenrc"
-fi
-
-M2_HOME=${M2_HOME:-"%%DATADIR%%"}
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir()
-{
-  local basedir=$(pwd)
-  local wdir=$(pwd)
-  while [ "$wdir" != '/' ] ; do
-    wdir=$(cd "$wdir/.."; pwd)
-    if [ -d "$wdir"/.mvn ] ; then
-      basedir=$wdir
-      break
-    fi
-  done
-  echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines()
-{
-  if [ -f "$1" ]; then
-    echo "$(tr -s '\n' ' ' < "$1")"
-  fi
-}
-
-MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-exec "%%LOCALBASE%%/bin/java" $MAVEN_OPTS \
-	-classpath "${M2_HOME}/boot/%%CLASSWORLDS_JAR%%" \
-	"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
-	"-Dmaven.home=${M2_HOME}" \
-	"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
-	org.codehaus.classworlds.Launcher "$@"