Date: Thu, 5 Feb 2026 09:52:13 +0100 From: Ronald Klop <ronald@FreeBSD.org> To: java@freebsd.org Subject: maven and java_home? Message-ID: <bde85b52-e406-4f20-bf4c-3b646ad90ac9@FreeBSD.org>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hi,
When a port defines JAVA_VERSION but during the build multiple jdk versions are installed, maven does not use the defined version if JAVA_HOME is not set in the environment.
I found this while pinning ports to openjdk8 and defining JAVA_DEFAULT=21 [1]. Dependencies install openjdk21 as run_dep which is picked up by maven, although JAVA_VERSION of the current build is 8.
The patch in the attachment makes sure JAVA_HOME is set. This fixes the builds.
I used this to find the relevant ports.
find . -name Makefile | xargs grep -l bin/mvn | xargs grep -L JAVA_HOME
NB: for ant we set a similar MAKE_ENV in Mk/Uses/java.mk. It might be a nice follow up task to add maven support to java.mk. I first want to get JAVA_DEFAULT=21 in the ports tree.
Is it possible to get some java@ approval for such a change without going through the hassle of creating separate PRs for every port?
Regards,
Ronald.
[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272855
[-- Attachment #2 --]
commit 0025e6c8ffafad37809be41045aa8463860becdc
Author: Ronald Klop <ronald@FreeBSD.org>
Date: Wed Feb 4 20:53:30 2026 +0100
many: pass JAVA_HOME to maven
When a port defines JAVA_VERSION but during the build multiple
jdk versions are installed, maven does not use the defined version
if JAVA_HOME is not set in the environment.
PR: 272855
Approved-by: java@
diff --git a/cad/digital/Makefile b/cad/digital/Makefile
index dd8b15511961..9f8979b088d9 100644
--- a/cad/digital/Makefile
+++ b/cad/digital/Makefile
@@ -31,7 +31,8 @@ NO_ARCH= yes
DEV_UPDATE_MODE= no
-MAKE_ENV= MAVEN_HOME=/usr/local/share/java/apache-maven-3.8 # workaround for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283883
+MAKE_ENV= JAVA_HOME=${JAVA_HOME} \
+ MAVEN_HOME=/usr/local/share/java/apache-maven-3.8 # workaround for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283883
.if (${DEV_UPDATE_MODE} == "yes")
post-build:
diff --git a/games/lizzie/Makefile b/games/lizzie/Makefile
index 9595a72adb69..404bc66979b4 100644
--- a/games/lizzie/Makefile
+++ b/games/lizzie/Makefile
@@ -19,6 +19,8 @@ USE_GITHUB= yes
GH_ACCOUNT= featurecat
JAVA_VERSION= 8 # because of Bug 292662 - games/lizzie: does not build with jdk11+
+MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
+
NO_ARCH= yes
# to rebuild the deps archive:
diff --git a/math/jacop/Makefile b/math/jacop/Makefile
index e721b75b6893..fd3977e58634 100644
--- a/math/jacop/Makefile
+++ b/math/jacop/Makefile
@@ -19,6 +19,8 @@ USE_GITHUB= yes
GH_ACCOUNT= radsz
JAVA_VERSION= 8 11 17
+MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
+
NO_ARCH= yes
SUB_FILES= ${PORTNAME}.sh
diff --git a/math/jts/Makefile b/math/jts/Makefile
index e8204f77e97c..3a4b5a500adb 100644
--- a/math/jts/Makefile
+++ b/math/jts/Makefile
@@ -17,6 +17,8 @@ JAVA_VERSION= 11+
USE_GITHUB= yes
GH_ACCOUNT= locationtech
+MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
+
NO_ARCH= yes
VER= ${PORTVERSION:tl}
diff --git a/science/cdk/Makefile b/science/cdk/Makefile
index 28b3256a1f7a..3d6f0447be2a 100644
--- a/science/cdk/Makefile
+++ b/science/cdk/Makefile
@@ -17,6 +17,8 @@ USES= java
USE_GITHUB= yes
JAVA_VERSION= 17 # Java 8 fails on aarch64: Internal Error (assembler_aarch64.hpp:237), pid=68892, tid=0x000000000002b995 guarantee(val < (1U << nbits)) failed: Field too big for insn
+MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
+
NO_ARCH= yes
PLIST_FILES= ${JAVAJARDIR}/${PORTNAME}-${PORTVERSION}.jar
diff --git a/science/opsin/Makefile b/science/opsin/Makefile
index b9c6e1f5da9d..c98ba8814dba 100644
--- a/science/opsin/Makefile
+++ b/science/opsin/Makefile
@@ -16,6 +16,8 @@ BUILD_DEPENDS= maven>0:devel/maven
USES= java
+MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
+
NO_ARCH= yes
BB_ACCOUNT= dan2097
diff --git a/security/owasp-dependency-check/Makefile b/security/owasp-dependency-check/Makefile
index 2bbf67b3aaac..708f1d44ac43 100644
--- a/security/owasp-dependency-check/Makefile
+++ b/security/owasp-dependency-check/Makefile
@@ -28,6 +28,8 @@ GH_ACCOUNT= jeremylong
GH_PROJECT= DependencyCheck
JAVA_VERSION= 8
+MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
+
NO_ARCH= yes
SUB_FILES= owasp-dependency-check
SUB_LIST= PORTVERSION=${PORTVERSION}
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bde85b52-e406-4f20-bf4c-3b646ad90ac9>
