Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Dec 2003 23:18:45 GMT
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/59997: /usr/local/bin/ant ignores USE_JAVA settings
Message-ID:  <200312062318.hB6NIjif002563@happy-idiot-talk.infracaninophile.co.uk>
Resent-Message-ID: <200312062320.hB6NKNxB055337@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         59997
>Category:       ports
>Synopsis:       /usr/local/bin/ant ignores USE_JAVA settings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 06 15:20:23 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Seaman
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
Infracaninophile
>Environment:
System: FreeBSD happy-idiot-talk.infracaninophile.co.uk 4.9-STABLE FreeBSD 4.9-STABLE #43: Sat Dec 6 20:03:44 GMT 2003 root@happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK i386


>Description:

If you have multiple Java JDKs or JREs installed, and you install a
port that uses devel/apache-ant to compile java sources, you may well
end up using a different JVM version to compile than would be
indicated by the USE_JAVA variable in the port Makefile.

While bsd.java.mk uses it's own JAVA_HOME make variable to provide an
explicit path to any java-related binaries, ant uses a shell script
wrapper which can't see the make variables, instead using the value of
JAVA_HOME from the environment to generate the full path to one of the
possible java binaries.

>How-To-Repeat:

This Makefile illustrates the problem.  Try running it with various
values of JAVA_HOME in your environment (or unset JAVA_HOME), plus
try various USE_JAVA settings:

    % env JAVA_HOME=/usr/local/jdk1.4.2 make USE_JAVA=1.3

--- Makefile.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X
XPORTNAME=	foo
XPORTVERSION=	0.0
XCATEGORIES=	none
XCOMMENT=	No comment
X
XUSE_JAVA=	1.3+
XNEED_JAVAC=	YES
X
XJAVA_ENV=	JAVA_HOME=${JAVA_HOME}
X
Xall: good bad
X
Xcommon:
X	@${ECHO} '$${USE_JAVA} = ${USE_JAVA}'
X	@${ECHO} '$${JAVA_HOME} = ${JAVA_HOME}'
X
Xbad: common
X	@${ECHO} "Bah! Humbug! -----------------------------------------"
X	@${ECHO} "------------------------------------------------------"
X	ant -diagnostics
X	@${ECHO} "------------------------------------------------------"
X
Xgood: common
X	@${ECHO} "As it should be --------------------------------------"
X	@${ECHO} "------------------------------------------------------"
X	${SETENV} ${JAVA_ENV} ant -diagnostics
X	@${ECHO} "------------------------------------------------------"
X
X.include <bsd.port.mk>
END-of-Makefile
exit
--- Makefile.shar ends here ---

>Fix:

All the ports that use ant do so in much the same way.  Factor out the
common code, and provide a 'USE_ANT' variable to enable a slightly
modified version of it that propagates ${JAVA_HOME} into the ant
environment.

--- bsd.java.mk.diff begins here ---
--- bsd.java.mk-bak	Sat Dec  6 22:29:42 2003
+++ bsd.java.mk	Sat Dec  6 23:06:38 2003
@@ -473,6 +473,17 @@
 .			endif
 .		endif
 
+# Compilation using Apache ant: propagate JAVA_HOME value to
+# ant environment
+
+.       if defined(USE_ANT)
+.           if (${USE_ANT} == "YES") || (${USE_ANT} == "yes")
+ANTCMD??=		${LOCALBASE}/bin/ant
+ANT=			${SETENV} JAVA_HOME=${JAVA_HOME} ${ANTCMD}
+BUILD_DEPENDS+=	${ANTCMD}:${PORTSDIR}/devel/apache-ant
+.           endif
+.       endif
+
 # Define the location of some more executables.
 APPLETVIEWER=	${JAVA_HOME}/bin/appletviewer
 JAR=			${JAVA_HOME}/bin/jar
--- bsd.java.mk.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312062318.hB6NIjif002563>