THRIFT-4746: changes for publishing java library to maven; fix java debug vs. release build with cmake
diff --git a/lib/java/CMakeLists.txt b/lib/java/CMakeLists.txt
index 46064e6..a67845a 100644
--- a/lib/java/CMakeLists.txt
+++ b/lib/java/CMakeLists.txt
@@ -18,6 +18,7 @@
 #
 
 if(ANDROID)
+
     set(THRIFT_AAR outputs/aar/thrift-debug.aar outputs/aar/thrift-release.aar)
     add_custom_command(
         OUTPUT ${THRIFT_AAR}
@@ -27,7 +28,7 @@
     )
     add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR})
 
-else(ANDROID)
+else()
 
     if(IS_ABSOLUTE "${LIB_INSTALL_DIR}")
         set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java")
@@ -41,11 +42,16 @@
         set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java")
     endif()
 
+    set(PRELEASE "true")
+    if (CMAKE_BUILD_TYPE MATCHES DEBUG)
+        set(PRELEASE "false")
+    endif ()
+
     add_custom_target(ThriftJava ALL
         COMMENT "Building Java library using Gradle Wrapper"
         COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} assemble
             --console=plain --no-daemon
-            -Prelease=true
+            -Prelease=${PRELEASE}
             -Pthrift.version=${thrift_VERSION}
             "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -56,7 +62,7 @@
         COMMENT "Publishing Java Library to Apache Maven staging"
         COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean uploadArchives
             --console=plain --no-daemon
-            -Prelease=true
+            -Prelease=${PRELEASE}
             -Pthrift.version=${thrift_VERSION}
             "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -78,10 +84,11 @@
         add_test(NAME JavaTest
                 COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test
                     --console=plain --no-daemon
-                    -Prelease=true
+                    -Prelease=${PRELEASE}
                     -Pthrift.version=${thrift_VERSION}
                     "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
                     "-Pthrift.compiler=${THRIFT_COMPILER}"
                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
     endif()
-endif(ANDROID)
+
+endif()
diff --git a/lib/java/README.md b/lib/java/README.md
index 5057465..7dca456 100644
--- a/lib/java/README.md
+++ b/lib/java/README.md
@@ -138,11 +138,15 @@
     mavenUser=meMyselfAndI
     mavenPassword=MySuperAwesomeSecretPassword
 
+NOTE: If you do not have a secring.gpg file, see the
+[gradle signing docs](https://docs.gradle.org/current/userguide/signing_plugin.html)
+for instructions on how to generate it.
+
 It is also possible to manually publish using the Gradle build directly.
 With the key information and credentials in place the following will generate
 if needed the build artifacts and proceed to publish the results.
 
-    ./gradlew -Prelease=true -Pthrift.version=0.11.0 uploadArchives
+    ./gradlew -Prelease=true uploadArchives
 
 It is also possible to override the target repository for the Maven Publication
 by using a Gradle property, for example you can publish signed JAR files to your
diff --git a/lib/java/build.gradle b/lib/java/build.gradle
index 4302f77..5f0d278 100644
--- a/lib/java/build.gradle
+++ b/lib/java/build.gradle
@@ -20,13 +20,14 @@
 // Using the legacy plugin classpath for Clover so it can be loaded optionally
 buildscript {
     repositories {
+        mavenCentral()
         google()
         jcenter()
         gradlePluginPortal()
     }
 
     dependencies {
-        classpath 'com.bmuschko:gradle-clover-plugin:2.2.0'
+        classpath 'com.bmuschko:gradle-clover-plugin:2.2.1'
     }
 }
 
@@ -34,7 +35,7 @@
     id 'java'
     id 'maven'
     id 'signing'
-    id 'com.github.johnrengelman.shadow' version '2.0.2'
+    id 'com.github.johnrengelman.shadow' version '4.0.4'
 }
 
 description = 'Apache Thrift Java Library'
@@ -44,12 +45,10 @@
 // Version components for this project
 group = property('thrift.groupid')
 
-// Drop the -dev suffix, we use the SNAPSHOT suffix for non-release versions
-def parsedVersion = property('thrift.version').toString().replace('-dev', '')
 if (Boolean.parseBoolean(project.release)) {
-    version = parsedVersion
+    version = property('thrift.version')
 } else {
-    version = parsedVersion + '-SNAPSHOT'
+    version = property('thrift.version') + '-SNAPSHOT'
 }
 
 // Keeping the rest of the build logic in functional named scripts for clarity
diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties
index 056a96e..5525610 100644
--- a/lib/java/gradle.properties
+++ b/lib/java/gradle.properties
@@ -3,7 +3,7 @@
 # the properties to minimize the changes in the dependencies.
 thrift.version=1.0.0
 thrift.groupid=org.apache.thrift
-release=true
+release=false
 
 # Local Install paths
 install.path=/usr/local/lib
@@ -25,9 +25,9 @@
 maven-repository-id=apache.releases.https
 
 # Dependency versions
-httpclient.version=4.4.1
+httpclient.version=4.5.6
 httpcore.version=4.4.1
-slf4j.version=1.7.12
+slf4j.version=1.7.25
 servlet.version=2.5
 junit.version=4.12
 mockito.version=1.9.5
diff --git a/lib/java/gradle/publishing.gradle b/lib/java/gradle/publishing.gradle
index 6b04043..029bff9 100644
--- a/lib/java/gradle/publishing.gradle
+++ b/lib/java/gradle/publishing.gradle
@@ -61,9 +61,9 @@
         url 'http://thrift.apache.org'
 
         scm {
-            url 'https://github.com/apache/thrift.git'
+            url 'https://github.com/apache/thrift'
             connection 'scm:git:https://github.com/apache/thrift.git'
-            developerConnection 'scm:git:https://github.com/apache/thrift.git'
+            developerConnection 'scm:git:git@github.com:apache/thrift.git'
         }
 
         licenses {
diff --git a/lib/java/gradle/wrapper/gradle-wrapper.properties b/lib/java/gradle/wrapper/gradle-wrapper.properties
index 2c2bbe5..826c82f 100644
--- a/lib/java/gradle/wrapper/gradle-wrapper.properties
+++ b/lib/java/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip