From 7ccbdc087e71d435a640f6a0966ec3ecdf656dab Mon Sep 17 00:00:00 2001 From: Francisco Guerrero Date: Tue, 7 Aug 2018 15:24:07 -0700 Subject: [PATCH] HAWQ-1645. Use the latest available version of gradle (4.9) --- pxf/build.gradle | 105 ++++++------------ pxf/gradle/wrapper/gradle-wrapper.properties | 8 +- pxf/gradlew | 90 ++++++++++++--- .../pxf/service/rest/VersionResource.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- 5 files changed, 116 insertions(+), 91 deletions(-) diff --git a/pxf/build.gradle b/pxf/build.gradle index 32059677cd..d92ff6a951 100644 --- a/pxf/build.gradle +++ b/pxf/build.gradle @@ -19,35 +19,39 @@ import org.apache.tools.ant.filters.ReplaceTokens -// Get database property, use HAWQ as a default database -def database = System.getProperty("database", "hawq"); -def databaseFileName = "gradle/profiles/" + database + ".properties"; -assert file(databaseFileName).exists() -def databaseProperties = new Properties() -file(databaseFileName).withInputStream { databaseProperties.load(it) } - buildscript { - repositories { - // mavenCentral without https: - maven { - url 'http://repo1.maven.org/maven2' - } - mavenLocal() - jcenter { - url 'http://jcenter.bintray.com/' - } - maven { - url 'http://repository.jboss.org/nexus/content/groups/public' - } - } dependencies { classpath "com.netflix.nebula:gradle-ospackage-plugin:2.2.6" - classpath "de.undercouch:gradle-download-task:2.1.0" classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+' - } + } +} + +plugins { + id "de.undercouch.download" version "3.4.3" } +repositories { + // mavenCentral without https: + maven { + url 'http://repo1.maven.org/maven2' + } + mavenLocal() + jcenter { + url 'http://jcenter.bintray.com/' + } + maven { + url 'http://repository.jboss.org/nexus/content/groups/public' + } +} + +// Get database property, use HAWQ as a default database +def database = System.getProperty("database", "hawq"); +def databaseFileName = "gradle/profiles/" + database + ".properties"; +assert file(databaseFileName).exists() +def databaseProperties = new Properties() +file(databaseFileName).withInputStream { databaseProperties.load(it) } + // Hadoop distribution (can be hdp or null which would default to apache) - needed to set correct classpaths // can be set with -Dhd= def hddist = System.properties['hd'] ?: ''; @@ -153,46 +157,6 @@ subprojects { subProject -> project('pxf-service') { -// Copy existing sources and replace any occurrences of @tokenName@ with desired values - task generateSources { - doFirst { - copy { - from('src/main/java') { - include '**/*.java' - filter(ReplaceTokens, - tokens:['pxfProtocolVersion': project.pxfProtocolVersion ])} - into "tmp/generatedSources" - } - } - } - -// Call cleanup taskAfter Java code compilation - compileJava.doLast { - tasks.cleanGeneratedSources.execute() - } - -// Delete "tmp" directory under current project directory -// rm -r pxf-service/tmp - task cleanGeneratedSources() { - doFirst { - delete "tmp" - } - } - -// Call generateSources task before Java compilation - gradle.projectsEvaluated { - compileJava.dependsOn(generateSources) - } - -// Use custom sources directory with generated sources - sourceSets { - main { - java { - srcDirs = ["tmp/generatedSources"] - } - } - } - apply plugin: 'war' tasks.war { archiveName = 'pxf.war' @@ -256,7 +220,7 @@ project('pxf-service') { from("src/main/resources/pxf-private${hddist}.classpath") { into("/etc/pxf-${project.version}/conf") - rename("pxf-private${hddist}.classpath", "pxf-private.classpath") + rename("pxf-private${hddist}.classpath", "pxf-private.classpath") } from('src/main/resources/pxf-public.classpath') { @@ -275,7 +239,7 @@ project('pxf-service') { 'pxfDefaultUserImpersonation': (databaseProperties.pxfDefaultUserImpersonation == null ? "" : databaseProperties.pxfDefaultUserImpersonation)]) into "/etc/pxf-${project.version}/conf" } - + from('src/main/resources/pxf-log4j.properties') { fileType CONFIG | NOREPLACE into "/etc/pxf-${project.version}/conf" @@ -288,7 +252,7 @@ project('pxf-service') { from(jar.outputs.files) { into "/usr/lib/pxf-${project.version}" } - + //tomcat configuration files from('src/configs/tomcat') { fileType CONFIG | NOREPLACE @@ -449,7 +413,7 @@ project('pxf-json') { task create_tweets_tgz(type: Exec){ commandLine 'tar', '-zcf', 'src/test/resources/tweets.tar.gz', '-C', 'src/test/resources', 'tweets-pp.json' } - + tasks['test'].dependsOn('create_tweets_tgz') } @@ -544,10 +508,11 @@ def buildNumber() { System.getenv('BUILD_NUMBER') ?: System.getProperty('user.name') } -task wrapper(type: Wrapper) { - gradleVersion = '2.13' +wrapper { + gradleVersion = '4.9' } + def distSubprojects = subprojects - project(':pxf-api') task release(type: Copy, dependsOn: [subprojects.build, subprojects.javadoc, distSubprojects.buildRpm, distSubprojects.distTar]) { @@ -581,14 +546,12 @@ task rpm(type: Copy, dependsOn: [subprojects.build, distSubprojects.buildRpm]) { } } -// tomcat +// tomcat def tomcatName = "apache-tomcat-${tomcatVersion}" def tomcatTargetDir = "tomcat/build" task tomcatGet << { - apply plugin: 'de.undercouch.download' - def TarGzSuffix = ".tar.gz" def tomcatTar = "${tomcatName}${TarGzSuffix}" def tomcatUrl = "http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcatVersion}/bin/${tomcatTar}" diff --git a/pxf/gradle/wrapper/gradle-wrapper.properties b/pxf/gradle/wrapper/gradle-wrapper.properties index ef410fd05a..925562861c 100644 --- a/pxf/gradle/wrapper/gradle-wrapper.properties +++ b/pxf/gradle/wrapper/gradle-wrapper.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. -#Wed Aug 05 16:07:21 PDT 2015 +#Mon Aug 06 15:07:48 PDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-2.13-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip diff --git a/pxf/gradlew b/pxf/gradlew index 48f44a9cf9..c87fcee175 100755 --- a/pxf/gradlew +++ b/pxf/gradlew @@ -15,13 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +############################################################################## ## -## Tries to recreate Gradle's gradlew command in pure bash. -## This way you don't have to worry about binaries in your build. -## -## Depdencies -## unzip +## Gradle start up script for UN*X ## +############################################################################## set -e set -o pipefail @@ -30,10 +28,10 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. - MAX_FD="maximum" +MAX_FD="maximum" # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="-Dorg.gradle.appname=$APP_BASE_NAME" +DEFAULT_JVM_OPTS="" bin=`dirname "$0"` bin=`cd "$bin">/dev/null; pwd` @@ -51,11 +49,11 @@ else fi fi -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -63,11 +61,23 @@ die ( ) { } # OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false darwin=false +nonstop=false case "`uname`" in + CYGWIN* ) + cygwin=true + ;; Darwin* ) darwin=true ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; esac # Attempt to set APP_HOME @@ -84,9 +94,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -113,7 +123,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$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 @@ -133,6 +143,51 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + # does not match gradle's hash # waiting for http://stackoverflow.com/questions/26642077/java-biginteger-in-bash-rewrite-gradlew hash() { @@ -195,6 +250,12 @@ lib_path() { echo "$base_path/$file_name/lib" } +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} + classpath() { local dir=$(lib_path) local cp=$(ls -1 $dir/*.jar | tr '\n' ':') @@ -211,10 +272,11 @@ main() { download fi + APP_ARGS=$(save "$@") + eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - - $JAVACMD "${JVM_OPTS[@]}" -cp $(classpath) org.gradle.launcher.GradleMain "$@" + exec "$JAVACMD" "${JVM_OPTS[@]}" -cp $(classpath) org.gradle.launcher.GradleMain "$@" } main "$@" diff --git a/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java b/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java index c9f4d20bc3..32779d815b 100644 --- a/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java +++ b/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java @@ -39,7 +39,7 @@ class Version { * actual value on build stage, using pxfProtocolVersion parameter from * gradle.properties */ - final static String PXF_PROTOCOL_VERSION = "@pxfProtocolVersion@"; + final static String PXF_PROTOCOL_VERSION = "v15"; public Version() { } diff --git a/pxf/pxf-service/src/main/webapp/WEB-INF/web.xml b/pxf/pxf-service/src/main/webapp/WEB-INF/web.xml index 8d033e17ea..4719f788a7 100644 --- a/pxf/pxf-service/src/main/webapp/WEB-INF/web.xml +++ b/pxf/pxf-service/src/main/webapp/WEB-INF/web.xml @@ -67,7 +67,7 @@ under the License. PXF Security Filter - /@pxfProtocolVersion@/* + /v15/*