Several ports that build using the jdk and ant have issues with getting
ant to use the correct build jdk. This diff addresses those issues.

javaPathHelper is designed to use JAVA_HOME when provided to pick the
jdk to use. If it is not provided it figures out what jdk satisfied the
run depend at install time and uses that (since it is guaranteed to
work). So if jdk-11 is installed before jdk-1.8.0 and then ant is
installed, ant will default to use jdk-11 when there's no JAVA_HOME
in the env. This can lead to ports building the with wrong jdk and can
result in a package that can't run with jdk 1.8.0 or fail to build
(e.g. graphics/opencv, games/jbrickshooter)

This diff does the following:
* Adds JAVA_HOME to MAKE_ENV and CONFIGURE_ENV for any port that uses
the java module and doesn't also contain NO_BUILD=yes. Previously
this was limited to just MODJAVA_BUILD=ant, but that is not sufficient
for ports that indirectly use ant via makefiles (e.g.
textproc/link-grammar, graphics/opencv).
* Fixes ports that rolled their own do-build for calling ant instead of
using MODJAVA_BUILD=ant (2 got it correct, 2 got it wrong).

I will coordinate this commit with the jdk/1.8 u212 update and REVISION
bumps for all the java ports due to u212 removing the jre and the change
to java.port.mk here. 

Index: devel/jdk/java.port.mk
===================================================================
RCS file: /cvs/ports/devel/jdk/java.port.mk,v
retrieving revision 1.36
diff -u -p -r1.36 java.port.mk
--- devel/jdk/java.port.mk      28 Mar 2019 19:00:47 -0000      1.36
+++ devel/jdk/java.port.mk      5 Jun 2019 18:36:30 -0000
@@ -44,6 +44,8 @@ RUN_DEPENDS+= ${MODJAVA_RUN_DEPENDS}
 
 .if ${NO_BUILD:L} != "yes"
     BUILD_DEPENDS+= ${MODJAVA_BUILD_DEPENDS}
+    CONFIGURE_ENV += JAVA_HOME=${JAVA_HOME}
+    MAKE_ENV += JAVA_HOME=${JAVA_HOME}
 .endif
 
 # Append 'java' to the list of categories.
@@ -55,7 +57,6 @@ CATEGORIES+=  java
 # respectively.
 .if defined(MODJAVA_BUILD) && ${MODJAVA_BUILD:L} == "ant"
     BUILD_DEPENDS += devel/apache-ant
-    MAKE_ENV += JAVA_HOME=${JAVA_HOME}
     MODJAVA_BUILD_TARGET_NAME ?=
     MODJAVA_BUILD_FILE ?= build.xml
     MODJAVA_BUILD_DIR ?= ${WRKSRC}
Index: games/jbrickshooter/Makefile
===================================================================
RCS file: /cvs/ports/games/jbrickshooter/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- games/jbrickshooter/Makefile        24 Mar 2019 22:24:13 -0000      1.15
+++ games/jbrickshooter/Makefile        5 Jun 2019 18:36:30 -0000
@@ -7,21 +7,21 @@ GH_PROJECT=   jbrickshooter
 GH_COMMIT=     0445d9171cc46462970ae8eb08f0c7294c5707df
 DISTNAME=      ${GH_PROJECT}-1.6.0
 CATEGORIES=    games
-REVISION=      1
+REVISION=      2
 
 # GPLv3
 PERMIT_PACKAGE_CDROM=  Yes
 
 MODULES=       java
 MODJAVA_VER=   1.8+
+MODJAVA_BUILD= ant
 
-BUILD_DEPENDS= devel/apache-ant
 RUN_DEPENDS=   java/javaPathHelper
 
 NO_TEST=       Yes
 
-do-build:
-       cd ${WRKSRC} && mkdir -p build && ant build
+pre-build:
+       cd ${WRKSRC} && mkdir -p build
 
 do-install:
        ${SUBST_CMD} -m 555 -c ${FILESDIR}/jbrickshooter \
Index: games/lwjgl/Makefile
===================================================================
RCS file: /cvs/ports/games/lwjgl/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- games/lwjgl/Makefile        24 Mar 2019 22:24:13 -0000      1.7
+++ games/lwjgl/Makefile        5 Jun 2019 18:36:30 -0000
@@ -8,7 +8,7 @@ GH_PROJECT=     lwjgl
 GH_TAGNAME=    ${GH_PROJECT}${V}
 DISTNAME=      lwjgl${V}
 PKGNAME=       lwjgl-${V}
-REVISION=      1
+REVISION=      2
 
 .if ${MACHINE_ARCH} == "i386"
 M_ARCH=                ""
@@ -34,14 +34,10 @@ MODULES=    java
 MODJAVA_VER=   1.8+
 MODJAVA_BUILD= ant
 
-BUILD_DEPENDS= audio/openal \
-               devel/apache-ant
+BUILD_DEPENDS= audio/openal
 
 NO_TEST=       Yes
 
-ANT_CMD=       ${SETENV} ${MAKE_ENV} PATH=${JAVA_HOME}/bin:${PATH} \
-               ${LOCALBASE}/bin/ant
-
 SUBST_VARS+=   M_ARCH
 
 pre-configure:
@@ -49,9 +45,6 @@ pre-configure:
                ${WRKSRC}/platform_build/bsd_ant/build.xml
        perl -pi -e 's,/usr/local,${LOCALBASE},g' \
                ${WRKSRC}/platform_build/bsd_ant/build.xml
-
-do-build:
-       cd ${WRKSRC} && ${ANT_CMD}
 
 do-install:
        ${INSTALL_DATA_DIR} ${LWJGL_HOME}
Index: lang/jruby/Makefile
===================================================================
RCS file: /cvs/ports/lang/jruby/Makefile,v
retrieving revision 1.78
diff -u -p -r1.78 Makefile
--- lang/jruby/Makefile 18 May 2019 16:03:47 -0000      1.78
+++ lang/jruby/Makefile 5 Jun 2019 18:36:30 -0000
@@ -6,7 +6,7 @@ ONLY_FOR_ARCHS = amd64
 COMMENT =      pure-Java implementation of the Ruby language
 
 V =            9.2.7.0
-REVISION =     0
+REVISION =     1
 DISTNAME =     jruby-dist-${V}-bin
 PKGNAME =      jruby-${V}
 CATEGORIES =   lang lang/ruby
@@ -27,30 +27,28 @@ MASTER_SITES1 =     ${MASTER_SITE_RUBYGEMS}
 
 MODULES =      java
 MODJAVA_VER =  1.8+
+MODJAVA_BUILD =        ant
 USE_GMAKE =    Yes
 
 WANTLIB =      c m pthread ${COMPILER_LIBCXX}
 
 COMPILER =             base-clang ports-gcc base-gcc
 
-BUILD_DEPENDS =        devel/apache-ant \
-               shells/bash \
-               ${RUN_DEPENDS}
+BUILD_DEPENDS = shells/bash
 RUN_DEPENDS =  java/javaPathHelper
 
-MAKE_ENV =     JAVA_HOME=${JAVA_HOME} MAKE=${MAKE_PROGRAM}
-
 JRUBY_HOME =   ${PREFIX}/jruby
 
 WRKDIST =      ${WRKDIR}/jruby-${V}
-ANT_CMD =      ${SETENV} ${MAKE_ENV} PATH=${JAVA_HOME}/bin:${PATH} \
-                       ${LOCALBASE}/bin/ant
 JFFI_HOME =    ${WRKDIST}/jffi
 JFFI_ARCH =    ${MACHINE_ARCH:S/amd64/x86_64/}-OpenBSD
 FFI_ARCH =     ${JFFI_ARCH:L}
 JRUBY_LAUNCHER_GEM = jruby-launcher-1.1.9-java.gem
 SUBST_VARS =   JRUBY_HOME JFFI_ARCH FFI_ARCH RAKE_V RDOC_V JAVA_HOME
 
+MODJAVA_BUILD_DIR = ${JFFI_HOME}
+MODJAVA_BUILD_TARGET_NAME = jar
+
 post-extract:
        mv ${WRKDIR}/jffi-jffi* ${JFFI_HOME}
        # Unpack the jruby-launcher gem, since it needs to be patched
@@ -68,7 +66,7 @@ do-configure:
                 -e 'close ARGV if eof;' ${WRKSRC}/bin/!(*.*)
 
 do-build:
-       cd ${JFFI_HOME} && ${ANT_CMD} jar
+       ${MODJAVA_BUILD_TARGET}
        rm -rf ${WRKSRC}/lib/jni
        mkdir -p ${WRKSRC}/lib/jni/${JFFI_ARCH}
        cp ${JFFI_HOME}/build/jni/libjffi-1.2.so \
Index: textproc/pdftk/Makefile
===================================================================
RCS file: /cvs/ports/textproc/pdftk/Makefile,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile
--- textproc/pdftk/Makefile     3 Jun 2019 16:06:58 -0000       1.21
+++ textproc/pdftk/Makefile     5 Jun 2019 18:36:30 -0000
@@ -5,6 +5,7 @@ COMMENT=        pdf swiss army knife
 V=             v3.0.3
 DISTNAME=      pdftk-$V
 PKGNAME=       ${DISTNAME:S/-v/-/}
+REVISION=      0
 EXTRACT_ONLY=  pdftk-$V.tar.gz \
                commons-lang3-3.8.1-bin.tar.gz
 
@@ -27,6 +28,7 @@ DISTFILES=    pdftk-$V.tar.gz \
 MODULES=       java
 MODJAVA_VER=   1.8+
 MODJAVA_BUILD= ant
+MODJAVA_BUILD_TARGET_NAME= jar
 
 RUN_DEPENDS+=  java/javaPathHelper
 
@@ -34,9 +36,6 @@ post-extract:
        mkdir ${WRKSRC}/lib
        cp ${FULLDISTDIR}/bcprov-jdk15on-160.jar ${WRKSRC}/lib/bcprov.jar
        cp ${WRKDIR}/commons-lang3-3.8.1/commons-lang3-3.8.1.jar 
${WRKSRC}/lib/commons-lang3.jar
-
-do-build:
-       cd ${WRKSRC}; ant jar
 
 do-install:
        ${INSTALL_DATA_DIR} ${PREFIX}/share/pdftk

Reply via email to