Skip to content

Commit d986870

Browse files
committed
Catch up with Embulk v0.10 API/SPI
1 parent cea56c7 commit d986870

File tree

10 files changed

+326
-242
lines changed

10 files changed

+326
-242
lines changed

build.gradle

+106-54
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
plugins {
2-
id "com.jfrog.bintray" version "1.8.4"
32
id "maven-publish"
43
id "java"
4+
id "signing"
55
id "checkstyle"
66
id "jacoco"
7-
id "org.embulk.embulk-plugins" version "0.3.0"
7+
id "org.embulk.embulk-plugins" version "0.4.2"
88
}
99

1010
repositories {
1111
mavenCentral()
12-
jcenter()
1312
}
1413

1514
group = "org.embulk"
@@ -21,27 +20,55 @@ targetCompatibility = 1.8
2120

2221
tasks.withType(JavaCompile) {
2322
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
23+
options.encoding = "UTF-8"
24+
}
25+
26+
java {
27+
withJavadocJar()
28+
withSourcesJar()
2429
}
2530

2631
dependencies {
27-
compileOnly "org.embulk:embulk-core:0.9.23"
28-
compile ("org.apache.commons:commons-vfs2:2.2") {
29-
exclude group: "commons-logging", module: "commons-logging"
30-
}
31-
compile("org.slf4j:jcl-over-slf4j:1.7.12") {
32-
exclude group: "org.slf4j", module: "slf4j-api"
32+
compileOnly "org.embulk:embulk-api:0.10.31"
33+
compileOnly "org.embulk:embulk-spi:0.10.31"
34+
35+
compile("org.embulk:embulk-util-config:0.3.0") {
36+
// They conflict with embulk-core. They are once excluded here,
37+
// and added explicitly with versions exactly the same with embulk-core:0.10.31.
38+
exclude group: "com.fasterxml.jackson.core", module: "jackson-annotations"
39+
exclude group: "com.fasterxml.jackson.core", module: "jackson-core"
40+
exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
41+
exclude group: "com.fasterxml.jackson.datatype", module: "jackson-datatype-jdk8"
42+
exclude group: "javax.validation", module: "validation-api"
3343
}
44+
45+
// They are once excluded from transitive dependencies of other dependencies,
46+
// and added explicitly with versions exactly the same with embulk-core:0.10.31.
47+
compile "com.fasterxml.jackson.core:jackson-annotations:2.6.7"
48+
compile "com.fasterxml.jackson.core:jackson-core:2.6.7"
49+
compile "com.fasterxml.jackson.core:jackson-databind:2.6.7"
50+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.6.7"
51+
compile "javax.validation:validation-api:1.1.0.Final"
52+
53+
compile "org.embulk:embulk-util-file:0.1.3"
54+
compile "org.embulk:embulk-util-retryhelper:0.8.2"
55+
56+
compile "org.apache.commons:commons-vfs2:2.2"
3457
compile "commons-io:commons-io:2.6"
3558
compile "com.jcraft:jsch:0.1.55"
3659

3760
testCompile "junit:junit:4.13"
38-
testCompile "org.embulk:embulk-core:0.9.23:tests"
39-
testCompile "org.embulk:embulk-standards:0.9.23"
40-
testCompile "org.embulk:embulk-deps-buffer:0.9.23"
41-
testCompile "org.embulk:embulk-deps-config:0.9.23"
61+
testCompile "org.embulk:embulk-junit4:0.10.31"
62+
testCompile "org.embulk:embulk-core:0.10.31"
63+
testCompile "org.embulk:embulk-core:0.10.31:tests"
64+
testCompile "org.embulk:embulk-deps:0.10.31"
4265
testCompile "org.apache.sshd:apache-sshd:1.1.0"
4366
testCompile "org.littleshoot:littleproxy:1.1.0-beta1"
4467
testCompile "io.netty:netty-all:4.0.34.Final"
68+
69+
testCompile "org.embulk:embulk-formatter-csv:0.10.31"
70+
testCompile "org.embulk:embulk-output-file:0.10.31"
71+
testCompile "org.embulk:embulk-parser-csv:0.10.31"
4572
}
4673

4774
embulkPlugin {
@@ -52,63 +79,81 @@ embulkPlugin {
5279

5380
javadoc {
5481
options {
55-
locale = 'en_US'
56-
encoding = 'UTF-8'
82+
locale = "en_US"
83+
encoding = "UTF-8"
5784
}
5885
}
5986

60-
// add tests/javadoc/source jar tasks as artifacts to be released
61-
task testsJar(type: Jar, dependsOn: classes) {
62-
classifier = 'tests'
63-
from sourceSets.test.output
87+
jar {
88+
from rootProject.file("LICENSE")
6489
}
65-
task sourcesJar(type: Jar, dependsOn: classes) {
66-
classifier = 'sources'
67-
from sourceSets.main.allSource
90+
91+
sourcesJar {
92+
from rootProject.file("LICENSE")
6893
}
69-
task javadocJar(type: Jar, dependsOn: javadoc) {
70-
classifier = 'javadoc'
71-
from javadoc.destinationDir
94+
95+
javadocJar {
96+
from rootProject.file("LICENSE")
7297
}
7398

7499
publishing {
75100
publications {
76-
embulkPluginMaven(MavenPublication) { // Publish it with "publishEmbulkPluginMavenPublicationTo???Repository".
77-
from components.java
78-
artifact testsJar
79-
artifact sourcesJar
80-
artifact javadocJar
101+
maven(MavenPublication) {
102+
groupId = project.group
103+
artifactId = project.name
104+
105+
from components.java // Must be "components.java". The dependency modification works only for it.
106+
// javadocJar and sourcesJar are added by java.withJavadocJar() and java.withSourcesJar() above.
107+
// See: https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/JavaPluginExtension.html
108+
109+
pom { // https://central.sonatype.org/pages/requirements.html
110+
packaging "jar"
111+
112+
name = project.name
113+
description = project.description
114+
url = "https://www.embulk.org/"
115+
116+
licenses {
117+
license {
118+
// http://central.sonatype.org/pages/requirements.html#license-information
119+
name = "The Apache License, Version 2.0"
120+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
121+
}
122+
}
123+
124+
developers {
125+
}
126+
127+
scm {
128+
connection = "scm:git:git://github.com/embulk/embulk-input-sftp.git"
129+
developerConnection = "scm:git:[email protected]:embulk/embulk-input-sftp.git"
130+
url = "https://github.com/embulk/embulk-input-sftp"
131+
}
132+
}
81133
}
82134
}
83-
}
84135

85-
// bintray
86-
bintray {
87-
// write at your bintray user name and api key to ~/.gradle/gradle.properties file:
88-
user = project.hasProperty('bintray_user') ? bintray_user : ''
89-
key = project.hasProperty('bintray_api_key') ? bintray_api_key : ''
90-
91-
publications = [ "embulkPluginMaven" ]
92-
publish = true
93-
94-
pkg {
95-
userOrg = 'embulk-input-sftp'
96-
repo = 'maven'
97-
name = project.name
98-
desc = 'SFTP file input plugin for Embulk'
99-
websiteUrl = 'https://github.com/embulk/embulk-input-sftp'
100-
issueTrackerUrl = 'https://github.com/embulk/embulk-input-sftp/issues'
101-
vcsUrl = 'https://github.com/embulk/embulk-input-sftp.git'
102-
licenses = ['Apache-2.0']
103-
labels = ['embulk', 'java']
104-
publicDownloadNumbers = true
105-
106-
version {
107-
name = project.version
136+
repositories {
137+
maven { // publishMavenPublicationToMavenCentralRepository
138+
name = "mavenCentral"
139+
if (project.version.endsWith("-SNAPSHOT")) {
140+
url "https://oss.sonatype.org/content/repositories/snapshots"
141+
} else {
142+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
143+
}
144+
145+
credentials {
146+
username = project.hasProperty("ossrhUsername") ? ossrhUsername : ""
147+
password = project.hasProperty("ossrhPassword") ? ossrhPassword : ""
148+
}
108149
}
109150
}
110151
}
111152

153+
signing {
154+
sign publishing.publications.maven
155+
}
156+
112157
gem {
113158
authors = [ "Satoshi Akama" ]
114159
email = [ "[email protected]" ]
@@ -121,6 +166,13 @@ gemPush {
121166
host = "https://rubygems.org"
122167
}
123168

169+
test {
170+
testLogging {
171+
outputs.upToDateWhen { false }
172+
showStandardStreams = true
173+
}
174+
}
175+
124176
checkstyle {
125177
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
126178
toolVersion = '6.14.1'
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# This is a Gradle generated file for dependency locking.
22
# Manual edits can break the build and are not advised.
33
# This file is expected to be part of source control.
4+
com.fasterxml.jackson.core:jackson-annotations:2.6.7
5+
com.fasterxml.jackson.core:jackson-core:2.6.7
6+
com.fasterxml.jackson.core:jackson-databind:2.6.7
7+
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.6.7
48
com.jcraft:jsch:0.1.55
59
commons-io:commons-io:2.6
10+
commons-logging:commons-logging:1.2
11+
javax.validation:validation-api:1.1.0.Final
612
org.apache.commons:commons-vfs2:2.2
7-
org.slf4j:jcl-over-slf4j:1.7.12
13+
org.embulk:embulk-util-config:0.3.0
14+
org.embulk:embulk-util-file:0.1.3
15+
org.embulk:embulk-util-retryhelper:0.8.2

src/main/java/org/embulk/input/sftp/FileList.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import com.fasterxml.jackson.annotation.JsonCreator;
44
import com.fasterxml.jackson.annotation.JsonIgnore;
55
import com.fasterxml.jackson.annotation.JsonProperty;
6-
import com.google.common.base.Throwables;
7-
import org.embulk.config.Config;
8-
import org.embulk.config.ConfigDefault;
96
import org.embulk.config.ConfigSource;
10-
import org.embulk.spi.Exec;
7+
import org.embulk.util.config.Config;
8+
import org.embulk.util.config.ConfigDefault;
119
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
1211

1312
import java.io.BufferedInputStream;
1413
import java.io.BufferedOutputStream;
@@ -76,7 +75,7 @@ public long getSize()
7675

7776
public static class Builder
7877
{
79-
private final Logger log = Exec.getLogger(FileList.class);
78+
private final Logger log = LoggerFactory.getLogger(FileList.class);
8079
private final ByteArrayOutputStream binary;
8180
private final OutputStream stream;
8281
private final List<Entry> entries = new ArrayList<>();
@@ -111,7 +110,7 @@ public Builder()
111110
stream = new BufferedOutputStream(new GZIPOutputStream(binary));
112111
}
113112
catch (IOException ex) {
114-
throw Throwables.propagate(ex);
113+
throw new RuntimeException(ex);
115114
}
116115
}
117116

@@ -166,7 +165,7 @@ public synchronized boolean add(String path, long size)
166165
stream.write(data);
167166
}
168167
catch (IOException ex) {
169-
throw Throwables.propagate(ex);
168+
throw new RuntimeException(ex);
170169
}
171170

172171
last = path;
@@ -179,7 +178,7 @@ public FileList build()
179178
stream.close();
180179
}
181180
catch (IOException ex) {
182-
throw Throwables.propagate(ex);
181+
throw new RuntimeException(ex);
183182
}
184183
return new FileList(binary.toByteArray(), getSplits(entries), Optional.ofNullable(last));
185184
}
@@ -281,7 +280,7 @@ public EntryList(byte[] data, List<Entry> entries)
281280
this.stream = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
282281
}
283282
catch (IOException ex) {
284-
throw Throwables.propagate(ex);
283+
throw new RuntimeException(ex);
285284
}
286285
this.current = 0;
287286
}
@@ -297,7 +296,7 @@ public synchronized String get(int i)
297296
stream = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
298297
}
299298
catch (IOException ex) {
300-
throw Throwables.propagate(ex);
299+
throw new RuntimeException(ex);
301300
}
302301
current = 0;
303302
}
@@ -328,7 +327,7 @@ private byte[] readNext()
328327
return b;
329328
}
330329
catch (IOException ex) {
331-
throw Throwables.propagate(ex);
330+
throw new RuntimeException(ex);
332331
}
333332
}
334333

src/main/java/org/embulk/input/sftp/PluginTask.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.embulk.input.sftp;
22

3-
import org.embulk.config.Config;
4-
import org.embulk.config.ConfigDefault;
5-
import org.embulk.config.ConfigInject;
6-
import org.embulk.config.Task;
7-
import org.embulk.spi.BufferAllocator;
8-
import org.embulk.spi.unit.LocalFile;
3+
import org.embulk.util.config.Config;
4+
import org.embulk.util.config.ConfigDefault;
5+
import org.embulk.util.config.Task;
6+
import org.embulk.util.config.units.LocalFile;
97

108
import java.util.Optional;
119

@@ -64,7 +62,4 @@ public interface PluginTask
6462

6563
FileList getFiles();
6664
void setFiles(FileList files);
67-
68-
@ConfigInject
69-
BufferAllocator getBufferAllocator();
7065
}

src/main/java/org/embulk/input/sftp/ProxyTask.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import com.fasterxml.jackson.annotation.JsonValue;
55
import org.apache.commons.vfs2.FileSystemOptions;
66
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
7-
import org.embulk.config.Config;
8-
import org.embulk.config.ConfigDefault;
97
import org.embulk.config.ConfigException;
10-
import org.embulk.config.Task;
8+
import org.embulk.util.config.Config;
9+
import org.embulk.util.config.ConfigDefault;
10+
import org.embulk.util.config.Task;
1111

1212
import java.util.Locale;
1313
import java.util.Optional;

0 commit comments

Comments
 (0)