THRIFT-4746: changes for publishing 0.12.0 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 1e4aed2..de515a5 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..6dd35e4 100644
--- a/lib/java/build.gradle
+++ b/lib/java/build.gradle
@@ -20,6 +20,7 @@
 // Using the legacy plugin classpath for Clover so it can be loaded optionally
 buildscript {
     repositories {
+        mavenCentral()
         google()
         jcenter()
         gradlePluginPortal()
diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties
index 4955b4c..58ca5f8 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=0.12.0
 thrift.groupid=org.apache.thrift
-release=true
+release=false
 
 # Local Install paths
 install.path=/usr/local/lib
@@ -25,9 +25,19 @@
 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
+
+# Signing key information for artifacts PGP signature (values are examples)
+# signing.keyId=ABCD0123
+# signing.password=signingPassword
+# signing.secretKeyRingFile=/root/.gnupg/secring.gpg
+
+# Apache Maven staging repository user credentials
+# mavenUser=mavenUser
+# mavenPassword=mySuperSecretPassword
+
diff --git a/lib/java/gradle/publishing.gradle b/lib/java/gradle/publishing.gradle
index 961d58f..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://git-wip-us.apache.org/repos/asf?p=thrift.git'
-            connection 'scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git'
-            developerConnection 'scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git'
+            url 'https://github.com/apache/thrift'
+            connection '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