Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/classpath/
build/
.idea
bin/
.vscode/
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ $ ./gradlew gem
Build with integrationTest

```
$ ./gradlew -DenableIntegrationTest=true gem
$ ./gradlew -DenableIntegrationTest=true clean all
```

## Versions

This plugin version 0.4.0 or later can use with Embulk 0.11.


## Note

Expand Down
97 changes: 44 additions & 53 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,77 +1,68 @@
plugins {
id "com.jfrog.bintray" version "1.1"
id "com.github.jruby-gradle.base" version "0.1.5"
id "java"
id "maven-publish"
id "org.embulk.embulk-plugins" version "0.6.2"
}
import com.github.jrubygradle.JRubyExec

apply from: 'https://raw.githubusercontent.com/hata/gradle-plugins/master/embulk-integration-test.gradle'
// apply from: 'https://raw.githubusercontent.com/hata/gradle-plugins/master/embulk-integration-test.gradle'
apply from: 'embulk-integration-test.gradle'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
mavenCentral()
jcenter()
}
configurations {
provided
}

version = "0.3.6"
version = "0.4.0"

dependencies {
compile "org.embulk:embulk-core:0.8.0+"
compile "org.msgpack:msgpack-core:0.7.1"
provided "org.embulk:embulk-core:0.8.0+"
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
testCompile "org.jmockit:jmockit:1.15+"
testCompile "junit:junit:4.+"
}
// https://mvnrepository.com/artifact/org.embulk/embulk-api
compileOnly "org.embulk:embulk-api:0.10.43"
// https://dev.embulk.org/embulk-spi/
compileOnly "org.embulk:embulk-spi:0.10.43"
// https://dev.embulk.org/embulk-util-file/
compile "org.embulk:embulk-util-file:0.1.5"
// https://dev.embulk.org/embulk-util-config/
compile "org.embulk:embulk-util-config:0.3.4"
// https://dev.embulk.org/embulk-util-timestamp/
compile "org.embulk:embulk-util-timestamp:0.2.2"

task classpath(type: Copy, dependsOn: ["jar"]) {
doFirst { file("classpath").deleteDir() }
from (configurations.runtime - configurations.provided + files(jar.archivePath))
into "classpath"
testImplementation "org.embulk:embulk-api:0.10.43"
testImplementation "org.embulk:embulk-spi:0.10.43"
testImplementation "org.embulk:embulk-util-file:0.1.5"
testImplementation "org.embulk:embulk-util-timestamp:0.2.2"
testImplementation "org.jmockit:jmockit:1.15"
testImplementation "junit:junit:4.+"
}
clean { delete 'classpath' }

task gem(type: JRubyExec, dependsOn: ["build", "gemspec", "classpath"]) {
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
script "build/gemspec"
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
embulkPlugin {
mainClass = "org.embulk.filter.SpeedometerFilterPlugin"
category = "filter"
type = "speedometer"
}

task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
script "pkg/${project.name}-${project.version}.gem"
gem {
authors = [ "hata" ]
email = ["hiroki.ata@gmail.com"]
summary = "Speedometer filter plugin for Embulk"
description = "Write log message of processed bytes and throughput periodically."
homepage = "https://github.com/hata/embulk-filter-speedometer"
licenses = ["MIT"]
}

task "package"(dependsOn: ["gemspec", "classpath"]) << {
println "> Build succeeded."
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
gemPush {
host = "https://rubygems.org"
}

task gemspec << { file("build/gemspec").write($/
Gem::Specification.new do |spec|
spec.name = "${project.name}"
spec.version = "${project.version}"
spec.authors = ["hata"]
spec.summary = %[Speedometer filter plugin for Embulk]
spec.description = %[Write log message of processed bytes and throughput periodically.]
spec.email = ["hiroki.ata@gmail.com"]
spec.licenses = ["MIT"]
spec.homepage = "https://github.com/hata/embulk-filter-speedometer"
// To use integrationTest, run like this:
// ./gradlew -DenableIntegrationTest=true clean all

spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
spec.test_files = spec.files.grep(%r"^(test|spec)/")
spec.require_paths = ["lib"]
gem.dependsOn(check)

#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
spec.add_development_dependency 'bundler', ['~> 1.0']
spec.add_development_dependency 'rake', ['>= 10.0']
end
/$)
}
// integrationTest reference build/gemContents to run the tests.
// So, it is required to depend on gem target to generate the contents.
integrationTest.dependsOn(gem)

task all(dependsOn: ["gem", "check", "integrationTest"])

project.tasks.integrationTest.dependsOn(classpath)
113 changes: 113 additions & 0 deletions embulk-integration-test.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// This part is made based on 'https://raw.github.com/brunodecarvalho/gradle-plugins/master/integration-test.gradle'
// Assumes 'java', 'groovy' or 'scala' plugins have been applied before

// Add integration test source sets
sourceSets {
integrationTest { sourceSet ->
["java", "groovy", "scala", "resources"].each {
if (!sourceSet.hasProperty(it)) return
sourceSet."$it".srcDir file("src/integration-test/${it}")
}
}
}

// Setup dependencies for integration testing
dependencies {
integrationTestCompile sourceSets.main.output
integrationTestCompile sourceSets.test.output
integrationTestCompile configurations.testCompile
integrationTestRuntime configurations.testRuntime
integrationTestCompile configurations.testImplementation
}

// Define integration test task
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}

///// This part is made based on https://raw.githubusercontent.com/hata/gradle-plugins/master/embulk-integration-test.gradle.
//
// If you would like to override embulkDownloadURL, then define
// embulkDownloadURL in gradle.properties or other config.
// And if you use embulk v0.9.x, then change embulkLogPathOption to --log
// because the option is changed.
// e.g.
// def embulkDownloadURL = 'https://dl.embulk.org/embulk-0.9.25.jar'
// def embulkLogPathOption = '--log'

def embulkDownloadURL = 'https://dl.embulk.org/embulk-0.11.4.jar'
def embulkLogPathOption = '--log-path'
def embulkJarPath = ''
def enableIntegrationTestFlag = Boolean.getBoolean('enableIntegrationTest')
def embulkIntegrationTestDir = 'embulk.integrationtest.dir'

task initIntegrationTestProperties {
if (project.hasProperty('embulkDownloadURL')) {
embulkDownloadURL = project.findProperty('embulkDownloadURL')
}
if (project.hasProperty('embulkLogPathOption')) {
embulkLogPathOption = project.findProperty('embulkLogPathOption')
}
if (project.hasProperty('embulkJarPath')) {
embulkJarPath = project.findProperty('embulkJarPath')
} else {
embulkJarPath = "$temporaryDir/embulk/bin/embulk.jar"
}

println("Set download url ${embulkDownloadURL} and jar path ${embulkJarPath}")
}

task downloadEmbulk {
doFirst {
if (!enableIntegrationTestFlag || new File(embulkJarPath).exists()) {
throw new StopExecutionException('Skip downloadEmbulk task.')
}
}

doLast {
println("Try to download embulk from ${embulkDownloadURL} to ${embulkJarPath}")

exec {
executable "sh"
args "-c", "curl --create-dirs -o $embulkJarPath -L $embulkDownloadURL"
}
}
}

integrationTest.doFirst {
// gemContents is generated by gem task. So, this task should be run after gem.
String libDir = file('build/gemContents/lib').absolutePath
String baseDir = "$temporaryDir/embulk"
systemProperty "$embulkIntegrationTestDir", "$baseDir"

if (!enableIntegrationTestFlag) {
throw new StopExecutionException('Skip integrationTest task.')
}

copy {
from 'src/integration-test/resources'
into baseDir
}

fileTree(dir: "$baseDir", include: "*.yml").visit { config ->
['preview', 'run'].each { embulkCommand ->
String logFile = "${config.file.absolutePath}.${embulkCommand}.log"
delete logFile

println("Run integrationTest for ${config.file.absolutePath}")

exec {
workingDir baseDir
executable "sh"
args "-c", "java -jar $embulkJarPath $embulkCommand -I $libDir $config.file.absolutePath $embulkLogPathOption $logFile"
}
}
}
}

project.tasks.downloadEmbulk.dependsOn(initIntegrationTestProperties)
project.tasks.integrationTest.dependsOn(downloadEmbulk)

// Make sure 'check' task calls integration test
// check.dependsOn integrationTest
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Wed Feb 04 13:46:12 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
Loading