Public bug reported:

The script at:
> ls -l /usr/share/gradle/bin/gradle
-rwxr-xr-x 1 root root 5114 Sep  9  2013 /usr/share/gradle/bin/gradle

incorretly overrides the setting of the JAVA_HOME environment variable
at line 70.  Simply assuming it's OK to override JAVA_HOME is bad form.
Also, why check in the very next line if it's been set?   It looks like
someone added duct tape with that export statement.  At the very least,
it shold NOT alter the value if it was set priror to runnig the script.
e.g. someting like:

```
> diff /usr/share/gradle/bin/gradle /usr/share/gradle/bin/gradle.PATCHED
70c70
< export JAVA_HOME=/usr/lib/jvm/default-java
---
> export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/default-java}
```


Snip from /usr/share/gradle/bin/gradle starting at line 70:

```
export JAVA_HOME=/usr/lib/jvm/default-java

# Determine the Java command to use to start the JVM.
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"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 
'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
```

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: gradle 1.4-2ubuntu1
ProcVersionSignature: Ubuntu 3.13.0-103.150-generic 3.13.11-ckt39
Uname: Linux 3.13.0-103-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.21
Architecture: amd64
Date: Thu Dec  1 21:05:57 2016
Ec2AMI: ami-9a29cea9
Ec2AMIManifest: (unknown)
Ec2AvailabilityZone: us-west-2c
Ec2InstanceType: c3.large
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
PackageArchitecture: all
SourcePackage: gradle
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: gradle (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug ec2-images trusty

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1646623

Title:
  gradle scrpt breaks JAVA_HOME environment setting

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gradle/+bug/1646623/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to