git: a1c897de331a - main - devel/maven: improve port for multiple parallel versions

From: Koichiro Iwao <meta_at_FreeBSD.org>
Date: Thu, 17 Aug 2023 04:40:16 UTC
The branch main has been updated by meta:

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

commit a1c897de331a3363f0d74b0decf8d07ae2498f1c
Author:     Michael Osipov <michaelo@apache.org>
AuthorDate: 2023-08-02 18:40:49 +0000
Commit:     Koichiro Iwao <meta@FreeBSD.org>
CommitDate: 2023-08-17 04:39:43 +0000

    devel/maven: improve port for multiple parallel versions
    
    PR:             272899
---
 devel/maven/Makefile  | 23 +++++++++++++----------
 devel/maven/pkg-plist |  3 +--
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/devel/maven/Makefile b/devel/maven/Makefile
index 2946e8d18566..38876c6aace3 100644
--- a/devel/maven/Makefile
+++ b/devel/maven/Makefile
@@ -1,8 +1,9 @@
 PORTNAME=	maven
 DISTVERSION=	3.8.8
+PORTREVISION=	1
 CATEGORIES=	devel java
 MASTER_SITES=	APACHE/maven/maven-3/${DISTVERSION}/binaries
-DISTNAME=	apache-maven-${DISTVERSION}-bin
+DISTNAME=	apache-${PORTNAME}-${DISTVERSION}-bin
 
 MAINTAINER=	michaelo@apache.org
 COMMENT=	Java project management tool
@@ -17,17 +18,19 @@ CPE_VENDOR=	apache
 CPE_PRODUCT=	maven
 USE_JAVA=	yes
 
-DATADIR=	${JAVASHAREDIR}/${PORTNAME}
+DATADIR=	${JAVASHAREDIR}/${INSTANCE_ID}
 NO_ARCH=	yes
 NO_BUILD=	yes
-WRKSRC=		${WRKDIR}/apache-maven-${DISTVERSION}
-PLIST_SUB=	PORTVERSION=${PORTVERSION}
-INSTANCE_FILE=	${PORTNAME}-${PORTVERSION}
-INSTANCES_DIR=	etc/maven-wrapper/instances.d/
+WRKSRC=		${WRKDIR}/${DISTNAME:S/-bin//}
+PLIST_SUB=	PORTVERSION=${PORTVERSION} \
+	INSTANCE_ID=${INSTANCE_ID} \
+	INSTANCES_DIR=${INSTANCES_DIR}
+INSTANCE_ID=	${DISTNAME:S/-bin//:R}
+INSTANCES_DIR=	${LOCALBASE}/etc/maven-wrapper/instances.d
 
 post-extract:
 	${RM} -r ${WRKSRC}/lib/jansi-native ${WRKSRC}/bin/*.cmd
-	${ECHO_CMD} "${DATADIR}" > ${WRKSRC}/${INSTANCE_FILE}
+	${ECHO_CMD} "${DATADIR}" > ${WRKDIR}/${INSTANCE_ID}
 
 post-patch:
 	@${REINPLACE_CMD} \
@@ -47,8 +50,8 @@ do-install:
 	${INSTALL_SCRIPT} ${WRKSRC}/bin/mvn ${STAGEDIR}${DATADIR}/bin
 	${INSTALL_SCRIPT} ${WRKSRC}/bin/mvnDebug ${STAGEDIR}${DATADIR}/bin
 	${INSTALL_SCRIPT} ${WRKSRC}/bin/mvnyjp ${STAGEDIR}${DATADIR}/bin
-	@${MKDIR} ${STAGEDIR}${PREFIX}/${INSTANCES_DIR}
-	${INSTALL_DATA} ${WRKSRC}/${INSTANCE_FILE} \
-		${STAGEDIR}${PREFIX}/${INSTANCES_DIR}
+	@${MKDIR} ${STAGEDIR}${INSTANCES_DIR}
+	${INSTALL_DATA} ${WRKDIR}/${INSTANCE_ID} \
+		${STAGEDIR}${INSTANCES_DIR}
 
 .include <bsd.port.mk>
diff --git a/devel/maven/pkg-plist b/devel/maven/pkg-plist
index 478dcab1dcd5..6bfdd1781c00 100644
--- a/devel/maven/pkg-plist
+++ b/devel/maven/pkg-plist
@@ -1,4 +1,4 @@
-%%ETCDIR%%-wrapper/instances.d/maven-%%PORTVERSION%%
+%%INSTANCES_DIR%%/%%INSTANCE_ID%%
 %%DATADIR%%/LICENSE
 %%DATADIR%%/NOTICE
 %%DATADIR%%/README.txt
@@ -67,4 +67,3 @@
 %%DATADIR%%/lib/wagon-http-3.5.3-shaded.jar
 %%DATADIR%%/lib/wagon-provider-api-3.5.3.jar
 %%DATADIR%%/lib/ext/README.txt
-%%DATADIR%%/maven-%%PORTVERSION%%