You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2021/07/25 20:31:54 UTC

[maven] branch MNG-7195 updated (d32819a -> 99333d5)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MNG-7195
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard d32819a  [MNG-7195] Rework JAVA_HOME handling
     new 99333d5  [MNG-7195] Rework JAVA_HOME handling

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d32819a)
            \
             N -- N -- N   refs/heads/MNG-7195 (99333d5)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 apache-maven/src/assembly/maven/bin/mvnDebug     | 2 +-
 apache-maven/src/assembly/maven/bin/mvnDebug.cmd | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

[maven] 01/01: [MNG-7195] Rework JAVA_HOME handling

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-7195
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 99333d5aa697ce4d474158706c03577f6ab00ac2
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Jul 25 15:39:33 2021 +0200

    [MNG-7195] Rework JAVA_HOME handling
    
    Dramatically simplify/rework handling by leaving setting JAVA_HOME to
    the user and try to load java(1) command from it. Technically Maven itself does
    not require JAVA_HOME to be set. If not set, use java(1) command from
    PATH on both Windows and POSIX-like systems.
    
    This closes #514
---
 apache-maven/src/assembly/maven/bin/mvnDebug     |  2 +-
 apache-maven/src/assembly/maven/bin/mvnDebug.cmd |  4 +-
 apache-maven/src/assembly/shared/init            | 53 +++++++-----------------
 apache-maven/src/assembly/shared/validate        | 19 +--------
 apache-maven/src/assembly/shared/validate.cmd    | 19 +++++----
 5 files changed, 30 insertions(+), 67 deletions(-)

diff --git a/apache-maven/src/assembly/maven/bin/mvnDebug b/apache-maven/src/assembly/maven/bin/mvnDebug
index 67bd4cf..7c8d327 100644
--- a/apache-maven/src/assembly/maven/bin/mvnDebug
+++ b/apache-maven/src/assembly/maven/bin/mvnDebug
@@ -22,7 +22,7 @@
 #
 # Environment Variable Prerequisites
 #
-#   JAVA_HOME           Must point at your Java Development Kit installation.
+#   JAVA_HOME           (Optional) Points to a Java installation.
 #   MAVEN_OPTS          (Optional) Java runtime options used when Maven is executed.
 #   MAVEN_SKIP_RC       (Optional) Flag to disable loading of mavenrc files.
 #   MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000
diff --git a/apache-maven/src/assembly/maven/bin/mvnDebug.cmd b/apache-maven/src/assembly/maven/bin/mvnDebug.cmd
index 23fdd93..f02e89c 100644
--- a/apache-maven/src/assembly/maven/bin/mvnDebug.cmd
+++ b/apache-maven/src/assembly/maven/bin/mvnDebug.cmd
@@ -20,7 +20,7 @@
 @REM
 @REM Environment Variable Prerequisites
 @REM
-@REM   JAVA_HOME           Must point at your Java Development Kit installation.
+@REM   JAVA_HOME           (Optional) Points to a Java installation.
 @REM   MAVEN_BATCH_ECHO    (Optional) Set to 'on' to enable the echoing of the batch commands.
 @REM   MAVEN_BATCH_PAUSE   (Optional) set to 'on' to wait for a key stroke before ending.
 @REM   MAVEN_OPTS          (Optional) Java runtime options used when Maven is executed.
@@ -37,7 +37,7 @@ title %0
 
 @setlocal
 
-IF "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=localhost:8000
+if "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=localhost:8000
 
 @set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS%
 
diff --git a/apache-maven/src/assembly/shared/init b/apache-maven/src/assembly/shared/init
index 9a4fadb..5b476ca 100755
--- a/apache-maven/src/assembly/shared/init
+++ b/apache-maven/src/assembly/shared/init
@@ -16,47 +16,26 @@ if $mingw ; then
     JAVA_HOME=`(cd "$JAVA_HOME"; pwd)`
 fi
 
-if [ -z "$JAVA_HOME" ]; then
-  javaExecutable="`which javac`"
-  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
-    # readlink(1) is not available as standard on Solaris 10.
-    readLink=`which readlink`
-    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
-      if $darwin ; then
-        javaHome="`dirname \"$javaExecutable\"`"
-        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
-      else
-        javaExecutable="`readlink -f \"$javaExecutable\"`"
-      fi
-      javaHome="`dirname \"$javaExecutable\"`"
-      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
-      JAVA_HOME="$javaHome"
-      export JAVA_HOME
-    fi
-  fi
-fi
+if [ -n "$JAVA_HOME" ] ; then
+  if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+    # IBM's JDK on AIX uses strange locations for the executables
+    JAVACMD="$JAVA_HOME/jre/sh/java"
+  else
+    JAVACMD="$JAVA_HOME/bin/java"
 
-if [ -z "$JAVACMD" ] ; then
-  if [ -n "$JAVA_HOME"  ] ; then
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
-      # IBM's JDK on AIX uses strange locations for the executables
-      JAVACMD="$JAVA_HOME/jre/sh/java"
-    else
-      JAVACMD="$JAVA_HOME/bin/java"
+    if [ ! -x "$JAVACMD" ] ; then
+      echo "The JAVA_HOME environment variable is not defined correctly, so Apache Maven cannot be started." >&2
+      echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" does not exist." >&2
+      exit 1
     fi
-  else
-    JAVACMD="`which java`"
   fi
-fi
+else
+  JAVACMD="`which java`"
 
-if [ ! -x "$JAVACMD" ] ; then
-  echo "The JAVA_HOME environment variable is not defined correctly," >&2
-  echo "this environment variable is needed to run this program." >&2
-  exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
-  echo "Warning: JAVA_HOME environment variable is not set." >&2
+  if [ ! -x "$JAVACMD" ] ; then
+    echo "The java(1) command does not exist in PATH nor is JAVA_HOME set, so Apache Maven cannot be started." >&2
+    exit 1
+  fi
 fi
 
 # traverses directory structure from process work directory to filesystem root
diff --git a/apache-maven/src/assembly/shared/validate b/apache-maven/src/assembly/shared/validate
index e722289..20603f1 100644
--- a/apache-maven/src/assembly/shared/validate
+++ b/apache-maven/src/assembly/shared/validate
@@ -22,7 +22,7 @@
 #
 # Environment Variable Prerequisites
 #
-#   JAVA_HOME       Must point at your Java Development Kit installation.
+#   JAVA_HOME       (Optional) Points to a Java installation.
 #   MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
 #   MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
 # -----------------------------------------------------------------------------
@@ -46,26 +46,9 @@ fi
 # OS specific support. $var _must_ be set to either true or false.
 cygwin=false;
 mingw=false;
-darwin=false;
 case "`uname`" in
   CYGWIN*) cygwin=true;;
   MINGW*) mingw=true;;
-  Darwin*) darwin=true
-    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
-    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
-    if [ -z "$JAVA_HOME" ]; then
-      if [ -x "/usr/libexec/java_home" ]; then
-        export JAVA_HOME="`/usr/libexec/java_home`"
-      else
-        export JAVA_HOME="/Library/Java/Home"
-      fi
-    fi
-    ;;
 esac
 
-if [ -z "$JAVA_HOME" ] ; then
-  if [ -r /etc/gentoo-release ] ; then
-    JAVA_HOME=`java-config --jre-home`
-  fi
-fi
 
diff --git a/apache-maven/src/assembly/shared/validate.cmd b/apache-maven/src/assembly/shared/validate.cmd
index d7e8dfa..9b31a8c 100644
--- a/apache-maven/src/assembly/shared/validate.cmd
+++ b/apache-maven/src/assembly/shared/validate.cmd
@@ -20,7 +20,7 @@
 @REM
 @REM Environment Variable Prerequisites
 @REM
-@REM   JAVA_HOME          Must point at your Java Development Kit installation.
+@REM   JAVA_HOME         (Optional) Points to a Java installation.
 @REM   MAVEN_BATCH_ECHO  (Optional) Set to 'on' to enable the echoing of the batch commands.
 @REM   MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
 @REM   MAVEN_OPTS        (Optional) Java runtime options used when Maven is executed.
@@ -46,20 +46,21 @@ if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
 set ERROR_CODE=0
 
 @REM ==== START VALIDATION ====
-if not "%JAVA_HOME%"=="" goto OkJHome
+if not "%JAVA_HOME%"=="" goto javaHomeSet
 for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i"
-goto checkJCmd
+goto checkJavaCmd
 
-:OkJHome
+:javaHomeSet
 set "JAVACMD=%JAVA_HOME%\bin\java.exe"
 
-:checkJCmd
 if not exist "%JAVACMD%" (
-  echo The JAVA_HOME environment variable is not defined correctly, >&2
-  echo this environment variable is needed to run this program. >&2
+  echo The JAVA_HOME environment variable is not defined correctly, so Apache Maven cannot be started. >&2
+  echo JAVA_HOME is set to "%JAVA_HOME%", but "%%JAVA_HOME%%\bin\java.exe" does not exist. >&2
   goto error
 )
 
-if "%JAVA_HOME%"=="" (
-  echo Warning: JAVA_HOME environment variable is not set. >&2
+:checkJavaCmd
+if not exist "%JAVACMD%" (
+  echo The java.exe command does not exist in PATH nor is JAVA_HOME set, so Apache Maven cannot be started. >&2
+  goto error
 )