Repository: mockito/mockito
Issue: Update Gradle to 3.0
Labels: continuous integration

Gradle 3.0 is released so we can look into upgrading. Potentially we can rewrite our scripts into Kotlin.


Issue comments:
After we branch out `release/2.x` ;)

Kotlin? We need to discuss it before ;)

Yes we can discuss it in this issue. I have not looked into Kotlin at all so have no opinion atm. You do?

There are some limitations in Kotlin scripts. It is highlighted also in the [release notes](https://docs.gradle.org/3.0/release-notes):

> ... we are working intensely to make Gradle Script Kotlin fully production ready by the end of the year ...

In addition we have quite extensive build logic written in Groovy and I don't know it is worth to rewrite it just to have nicer code completion in Idea for those not very often times where there is something to change.

Seem decent arguments to not switch to Kotlin yet :+1: 

However gradle 3.0 still allows groovy, so that's not a blocker to switch

And should "always" will:

> Groovy is still the primary build language for Gradle scripts and will **always** be supported

+1 to keeping groovy build scripts :)

We cannot do it right now because Gradle 3.0 does not build with java6 and current release is still for java6 :( Let's close and revisit later. We won't forget to bump Gradle :)

We will switch from Java 6 soon and this issue has not been resolved yet. Therefore reopening to be tracked in waffle.


Pull request review comments:
I assume we already moved the baseline java8 so this should be safe. Nice.

Yup in https://github.com/mockito/mockito/commit/be755a3d9e8424e8587857390abbc07001644778 :smile: 


Patch that resolved the issue:
diff --git a/build.gradle b/build.gradle
index b432d9b62c..af1eebc19c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -122,7 +122,7 @@ apply from: 'gradle/release.gradle'
 apply from: "gradle/pom.gradle"
 
 task wrapper(type: Wrapper) {
-    gradleVersion = '2.14.1'
+    gradleVersion = '3.0'
 }
 
 task ciBuild {
diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle
index 921589844d..4387c965b1 100644
--- a/gradle/javadoc.gradle
+++ b/gradle/javadoc.gradle
@@ -54,9 +54,7 @@ task mockitoJavadoc(type: Javadoc) {
     """.replaceAll(/\r|\n/, ""))
     options.stylesheetFile file("src/javadoc/stylesheet.css")
 //    options.addStringOption('top', 'some html')
-    if (JavaVersion.current().isJava8Compatible()) {
-        options.addStringOption('Xdoclint:none', '-quiet')
-    }
+    options.addStringOption('Xdoclint:none', '-quiet')
 
     doLast {
         copy {
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 69ef29851a..08b5db1824 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Aug 19 18:41:31 PDT 2016
+#Sat Sep 17 14:22:48 CEST 2016
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
diff --git a/gradlew b/gradlew
index 9d82f78915..27309d9231 100755
--- a/gradlew
+++ b/gradlew
@@ -6,12 +6,30 @@
 ##
 ##############################################################################
 
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
 
 APP_NAME="Gradle"
 APP_BASE_NAME=`basename "$0"`
 
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"
 
@@ -30,6 +48,7 @@ die ( ) {
 cygwin=false
 msys=false
 darwin=false
+nonstop=false
 case "`uname`" in
   CYGWIN* )
     cygwin=true
@@ -40,26 +59,11 @@ case "`uname`" in
   MINGW* )
     msys=true
     ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
 esac
 
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
 # Determine the Java command to use to start the JVM.
@@ -85,7 +89,7 @@ location of your Java installation."
 fi
 
 # Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
     MAX_FD_LIMIT=`ulimit -H -n`
     if [ $? -eq 0 ] ; then
         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
diff --git a/gradlew.bat b/gradlew.bat
index 5f192121eb..832fdb6079 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -8,14 +8,14 @@
 @rem Set local scope for the variables with windows NT shell
 if "%OS%"=="Windows_NT" setlocal
 
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
 set DIRNAME=%~dp0
 if "%DIRNAME%" == "" set DIRNAME=.
 set APP_BASE_NAME=%~n0
 set APP_HOME=%DIRNAME%
 
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
 @rem Find java.exe
 if defined JAVA_HOME goto findJavaFromJavaHome
 


Test patch: