Skip to content

Commit

Permalink
HAWQ-1645. Use the latest available version of gradle (4.9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Guerrero committed Aug 7, 2018
1 parent 6cd1cf3 commit 7ccbdc0
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 91 deletions.
105 changes: 34 additions & 71 deletions pxf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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=<value>
def hddist = System.properties['hd'] ?: '';
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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') {
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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')
}

Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -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}"
Expand Down
8 changes: 4 additions & 4 deletions pxf/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
# 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
# KIND, either express or implied. See the License for the
# 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
90 changes: 76 additions & 14 deletions pxf/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand All @@ -51,23 +49,35 @@ else
fi
fi

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
exit 1
}

# 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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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' ':')
Expand All @@ -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 "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down
2 changes: 1 addition & 1 deletion pxf/pxf-service/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ under the License.
</filter>
<filter-mapping>
<filter-name>PXF Security Filter</filter-name>
<url-pattern>/@pxfProtocolVersion@/*</url-pattern>
<url-pattern>/v15/*</url-pattern>
</filter-mapping>

<!-- log4j configuration
Expand Down

0 comments on commit 7ccbdc0

Please sign in to comment.