Skip to content

Commit

Permalink
Fixup CI builds
Browse files Browse the repository at this point in the history
Adds various scripts for Travis and gradle integration, and updates
existing settings to support those scripts.

Add CI scripts for Travis integration
Add gradle wrappers
Update gradle files to build against various branches
Increases the wait time for events to be written to the queue to
attempt to fix intermittently failing unit test.
  • Loading branch information
robbavey committed Jul 5, 2017
1 parent f7491a9 commit 1e410f2
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 72 deletions.
20 changes: 20 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,23 @@ require "logstash/devutils/rake"
task :default do
system('rake -T')
end

task :vendor => "gradle.properties" do
exit(1) unless system './gradlew vendor'
end

file "gradle.properties" do
delete_create_gradle_properties
end

def delete_create_gradle_properties
root_dir = File.dirname(__FILE__)
gradle_properties_file = "#{root_dir}/gradle.properties"
lsc_path = `bundle show logstash-core`
FileUtils.rm_f(gradle_properties_file)
File.open(gradle_properties_file, "w") do |f|
f.puts "logstashCoreGemPath=#{lsc_path}"
end
puts "-------------------> Wrote #{gradle_properties_file}"
puts `cat #{gradle_properties_file}`
end
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.2
106 changes: 51 additions & 55 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,77 +1,56 @@
import java.nio.file.Files
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING


group 'co.elastic.logstash.input'

apply plugin: 'java'
apply plugin: 'idea'

version "${new File("VERSION").text.trim()}"

description = "dead letter queue"

repositories {
mavenCentral()
}

project.sourceCompatibility = 1.8
project.targetCompatibility = 1.8

task sourcesJar(type: org.gradle.api.tasks.bundling.Jar, dependsOn: classes) {
from sourceSets.main.allSource
classifier 'sources'
extension 'jar'
}

task javadocJar(type: org.gradle.api.tasks.bundling.Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier 'javadoc'
extension 'jar'
}

// copy jar file into the gem lib dir but without the version number in filename
task copyGemjar(type: org.gradle.api.tasks.Copy, dependsOn: sourcesJar) {
from project.jar
into project.file('lib/')
rename(/(.+)-${project.version}.jar/, '$1.jar')
}

task cleanGemjar {
delete fileTree(project.file('lib/')) {
include '*.jar'
task generateGemJarRequiresFile << {
File jars_file = file('lib/logstash-input-dead_letter_queue_jars.rb')
jars_file.newWriter().withWriter { w ->
w << "# AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.\n\n"
w << "require \'jar_dependencies\'\n"
configurations.runtime.allDependencies.each {
w << "require_jar(\'${it.group}\', \'${it.name}\', \'${it.version}\')\n"
}
w << "require_jar(\'${project.group}\', \'${project.name}\', \'${project.version}\')\n"
}
}

clean.dependsOn(cleanGemjar)
jar.finalizedBy(copyGemjar)

task gemspec_jars << {
File gemspec_jars = file("./gemspec_jars.rb")
gemspec_jars.newWriter().withWriter { w ->
w << "# This file is generated by Gradle as part of the build process. It extracts the build.gradle\n"
w << "# runtime dependencies to generate this gemspec dependencies file to be eval'ed by the gemspec\n"
w << "# for the jar-dependencies requirements.\n\n"
configurations.runtime.allDependencies.each { dependency ->
w << "gem.requirements << \"jar ${dependency.group}:${dependency.name}, ${dependency.version}\"\n"
}
task vendor << {
String vendorPathPrefix = "vendor/jar-dependencies"
configurations.runtime.allDependencies.each { dep ->
File f = configurations.runtime.filter { it.absolutePath.contains("${dep.group}/${dep.name}/${dep.version}") }.singleFile
String groupPath = dep.group.replaceAll('\\.', '/')
File newJarFile = file("${vendorPathPrefix}/${groupPath}/${dep.name}/${dep.version}/${dep.name}-${dep.version}.jar")
newJarFile.mkdirs()
Files.copy(f.toPath(), newJarFile.toPath(), REPLACE_EXISTING)
}
String projectGroupPath = project.group.replaceAll('\\.', '/')
File projectJarFile = file("${vendorPathPrefix}/${projectGroupPath}/${project.name}/${project.version}/${project.name}-${project.version}.jar")
projectJarFile.mkdirs()
Files.copy(file("$buildDir/libs/${project.name}-${project.version}.jar").toPath(), projectJarFile.toPath(), REPLACE_EXISTING)
}
build.finalizedBy(gemspec_jars)

configurations.create('sources')
configurations.create('javadoc')
configurations.archives {
extendsFrom configurations.sources
extendsFrom configurations.javadoc
}
vendor.dependsOn(jar, generateGemJarRequiresFile)

artifacts {
sources(sourcesJar) {
// Weird Gradle quirk where type will be used for the extension, but only for sources
type 'jar'
}
javadoc(javadocJar) {
type 'javadoc'
}
}

configurations {
provided
}

project.sourceSets {
main.compileClasspath += project.configurations.provided
main.runtimeClasspath += project.configurations.provided
Expand All @@ -87,8 +66,25 @@ idea {
}

dependencies {
provided project(':logstash-core')
provided 'org.jruby:jruby-core:1.7.25'
testCompile 'junit:junit:4.12'
testCompile 'joda-time:joda-time:2.9.9'
compileOnly group: "org.apache.logging.log4j", name: "log4j-api", version: "2.6.2"
compileOnly group: "org.apache.logging.log4j", name: "log4j-core", version: "2.6.2"
// Keep Joda version same as JRuby 1.7.25 and 9.1.9.0
compileOnly group: "joda-time", name: "joda-time", version: "2.8.2"
compileOnly 'com.fasterxml.jackson.core:jackson-core:2.7.4'
compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.7.4'
compileOnly 'com.fasterxml.jackson.module:jackson-module-afterburner:2.7.4'
compileOnly 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.7.4'
compileOnly group: 'org.jruby', name: 'jruby-complete', version: "1.7.25"
compileOnly fileTree(dir: logstashCoreGemPath, include: '**/*.jar')

testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: "org.apache.logging.log4j", name: "log4j-api", version: "2.6.2"
testCompile group: "org.apache.logging.log4j", name: "log4j-core", version: "2.6.2"
testCompile group: "joda-time", name: "joda-time", version: "2.8.2"
testCompile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
testCompile 'com.fasterxml.jackson.core:jackson-databind:2.7.4'
testCompile 'com.fasterxml.jackson.module:jackson-module-afterburner:2.7.4'
testCompile 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.7.4'
testCompile group: 'org.jruby', name: 'jruby-complete', version: "1.7.25"
testCompile fileTree(dir: logstashCoreGemPath, include: '**/*.jar')
}
6 changes: 6 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bundle install
bundle exec rake vendor
./gradlew test -i
bundle exec rspec spec
# bundle exec rake test:integration:setup TODO
# bundle exec rspec spec --tag integration TODO
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Jun 29 13:06:17 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
164 changes: 164 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/usr/bin/env bash

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# 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"

warn ( ) {
echo "$*"
}

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

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
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
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
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

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
Loading

0 comments on commit 1e410f2

Please sign in to comment.