Skip to content

Commit dc412fb

Browse files
authored
Merge pull request #21 from isac322/fix/19
update outdated build.gradle
2 parents 454f310 + 228b99f commit dc412fb

File tree

3 files changed

+68
-58
lines changed

3 files changed

+68
-58
lines changed

build.gradle

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
plugins {
2-
id 'java'
2+
id 'java-library'
33
id 'idea'
4-
id 'com.google.osdetector' version '1.4.0'
4+
id 'com.google.osdetector' version '1.6.2'
5+
id 'io.freefair.lombok' version '3.8.4'
6+
id 'maven-publish'
57
}
68

79
group 'org.onedrive'
@@ -10,83 +12,66 @@ version '0.10.0'
1012
compileJava {
1113
sourceCompatibility = 1.7
1214
targetCompatibility = 1.7
13-
14-
options.compilerArgs << "-Xlint:unchecked"
1515
}
1616

1717
compileTestJava {
1818
sourceCompatibility = 1.8
1919
targetCompatibility = 1.8
20-
21-
options.compilerArgs << "-Xlint:unchecked"
2220
}
2321

2422
repositories {
2523
jcenter()
2624
}
2725

26+
ext {
27+
nettyVer = '4.1.38.Final'
28+
jacksonVer = '2.10.0.pr1'
29+
}
30+
2831
dependencies {
29-
compile 'com.fasterxml.jackson.core:jackson-annotations:+'
30-
compile 'com.fasterxml.jackson.core:jackson-core:+'
32+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jacksonVer"
33+
implementation "com.fasterxml.jackson.core:jackson-core:$jacksonVer"
3134

32-
compile 'io.netty:netty-buffer:4.+'
33-
compile 'io.netty:netty-codec:4.+'
34-
compile 'io.netty:netty-codec-http:4.+'
35-
compile 'io.netty:netty-common:4.+'
36-
compile 'io.netty:netty-handler:4.+'
37-
compile 'io.netty:netty-resolver:4.+'
38-
compile 'io.netty:netty-transport:4.+'
35+
api "io.netty:netty-buffer:$nettyVer"
36+
api "io.netty:netty-codec:$nettyVer"
37+
api "io.netty:netty-codec-http:$nettyVer"
38+
api "io.netty:netty-common:$nettyVer"
39+
api "io.netty:netty-handler:$nettyVer"
40+
api "io.netty:netty-resolver:$nettyVer"
41+
api "io.netty:netty-transport:$nettyVer"
3942

4043

41-
if (osdetector.os == 'linux' || osdetector.os == 'osx' || osdetector.os.endsWith('bsd')) {
42-
compile "io.netty:netty-transport-native-epoll:4.+:${osdetector.classifier}"
44+
if (osdetector.os == 'linux') {
45+
implementation "io.netty:netty-transport-native-epoll:4.+:${osdetector.classifier}"
46+
}
47+
else if (osdetector.os == 'osx' || osdetector.os.endsWith('bsd')) {
48+
implementation "io.netty:netty-transport-native-kqueue:4.+:${osdetector.classifier}"
4349
}
4450

51+
api 'org.jetbrains:annotations:+'
4552

46-
compile 'org.projectlombok:lombok:+'
47-
48-
compile 'org.jetbrains:annotations:+'
49-
50-
testCompile 'com.fasterxml.jackson.core:jackson-databind:+'
51-
testCompileOnly 'org.apiguardian:apiguardian-api:+'
53+
testCompile "com.fasterxml.jackson.core:jackson-databind:$jacksonVer"
5254
testCompile 'org.junit.jupiter:junit-jupiter-api:5.+'
5355
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.+'
5456
}
5557

56-
57-
task delombok(dependsOn: compileJava) {
58-
ext.srcDelomboked = file("${buildDir}/delomboked")
59-
outputs.dir(ext.srcDelomboked)
60-
61-
// older version: lombok.delombok.ant.DelombokTask
62-
// recent version: lombok.delombok.ant.Tasks$Delombok
63-
ant.taskdef(name: 'delombok', classname: 'lombok.delombok.ant.Tasks$Delombok',
64-
classpath: configurations.compile.asPath)
65-
66-
sourceSets.main.java.srcDirs.each {
67-
inputs.dir(it)
68-
}
69-
70-
doLast {
71-
sourceSets.main.java.srcDirs.each {
72-
ant.delombok(from: it, to: ext.srcDelomboked, encoding: 'UTF-8', classpath: configurations.compile.asPath)
73-
}
74-
}
58+
test {
59+
useJUnitPlatform()
7560
}
7661

7762
javadoc {
78-
dependsOn delombok
79-
options.addBooleanOption('html5').setValue(true)
80-
source = delombok.srcDelomboked
63+
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
64+
options.addBooleanOption('html5').setValue(true)
65+
}
8166
}
8267

83-
task sourcesJar(type: Jar, dependsOn: classes) {
84-
classifier = 'sources'
85-
from sourceSets.main.allSource
68+
task sourcesJar(type: Jar) {
69+
archiveClassifier = 'sources'
70+
from sourceSets.main.allJava
8671
}
8772

88-
task javadocJar(type: Jar, dependsOn: javadoc) {
89-
classifier = 'javadoc'
73+
task javadocJar(type: Jar) {
74+
archiveClassifier = 'javadoc'
9075
from javadoc.destinationDir
9176
}
9277

@@ -95,3 +80,21 @@ artifacts {
9580
archives sourcesJar
9681
archives javadocJar
9782
}
83+
84+
publishing {
85+
publications {
86+
myLibrary(MavenPublication) {
87+
from components.java
88+
89+
artifact sourcesJar
90+
artifact javadocJar
91+
}
92+
}
93+
94+
repositories {
95+
maven {
96+
name = 'myRepo'
97+
url = "file://${buildDir}/repo"
98+
}
99+
}
100+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Mar 30 22:14:08 KST 2018
1+
#Mon Aug 05 16:40:14 KST 2019
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
23
distributionBase=GRADLE_USER_HOME
34
distributionPath=wrapper/dists
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
zipStoreBase=GRADLE_USER_HOME

src/main/java/com/bhyoo/onedrive/client/RequestTool.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,25 @@ public class RequestTool {
6767
static {
6868
EventLoopGroup tmpGroup;
6969
Class<? extends SocketChannel> tmpClass;
70-
try {
71-
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
70+
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
7271

72+
try {
7373
Class<?> loadClass = classLoader.loadClass("io.netty.channel.epoll.EpollEventLoopGroup");
7474
tmpGroup = (EventLoopGroup) loadClass.getConstructor(int.class).newInstance(4);
7575
tmpClass = (Class<? extends SocketChannel>)
7676
classLoader.loadClass("io.netty.channel.epoll.EpollSocketChannel");
7777
}
7878
catch (Exception e) {
79-
e.printStackTrace();
80-
tmpGroup = new NioEventLoopGroup(4);
81-
tmpClass = NioSocketChannel.class;
79+
try {
80+
Class<?> loadClass = classLoader.loadClass("io.netty.channel.kqueue.KQueueEventLoopGroup");
81+
tmpGroup = (EventLoopGroup) loadClass.getConstructor(int.class).newInstance(4);
82+
tmpClass = (Class<? extends SocketChannel>)
83+
classLoader.loadClass("io.netty.channel.kqueue.KQueueSocketChannel");
84+
}
85+
catch (Exception e1) {
86+
tmpGroup = new NioEventLoopGroup(4);
87+
tmpClass = NioSocketChannel.class;
88+
}
8289
}
8390

8491
group = tmpGroup;

0 commit comments

Comments
 (0)