Skip to content

Commit 1ecbdcd

Browse files
RemcoBuddelmeijermfateev
authored andcommitted
Feature/gradle 4 2 to 6 0 openjdk 8 alpine docker base image (#426)
* Upgrade gradle wrapper from 4.2 to 6.0 (#417) To improve compilation time and fix numerous amount of issues alongside other improvements that have been done throughout Gradle 5.0 and 6.0 * Update Gradle wrapper jar and properties (#417) In order to work with the newest Gradle version, the Wrapper jar and properties also have to be updated, so that Gradle knows how to download it's executable Gradle automatically downloads the Gradle executable through the properties * Introduce OpenJDK Alpine Docker base image (#417) In order to have the smallest image possible, the Alpine image has to be used. This will increase performance and will use less disk space and network ingress. This base image will reduce the final image size from 713MB down to 377MB, this all by using as minimum libraries as needed; for example by removing the linux-gnu library. * Update multiple Gradle dependencies+plugins (#417) In order to keep up with the latest technology, benefit from the fastest features and to improve security due to fixed issues and bugs, there has to be a regular update for dependency and plugins. Update multiple Gradle dependencies and plugins: Plugins: - thrift-gradle-plugin (0.4.0 -> 0.4.1) - net.minecrell.licenser (0.3 -> 0.4.1) - com.github.sherter.google-java-format (0.6 -> 0.8) - net.ltgt.errorprone (0.6 -> 1.1.1) - java -> java-library Compile Dependencies: com.google.errorprone:error_prone_core (2.3.1 -> 2.3.3) com.uber.m3 (0.2.3 -> 0.4.0) com.google.guava (27.0.1-jre -> 28.1-jre) * Updated GSON dependency to 2.8.6 (uber#417) In order to keep up with the latest technology, benefit from the fastest features and to improve security due to fixed issues and bugs, there has to be a regular update for dependency and plugins. GSON 2.8.6 deprecates certain methods which will prevent usage of these methods in the future. https://github.com/google/gson/blob/master/CHANGELOG.md#version-286 * Removed deprecated JsonParser#parse (uber#417) JsonParser#parse and the initialization of the JsonParser objects were deprecated in version 2.8.6 of GSON. In order to be complient with the newest version, the code was updated to use the static JsonParser#parseString method. * Updated cron-utils from 8.0.0 -> 9.0.0 (uber#417) It has been over a year since the version of cron-utils has been updated. This update will bring numerous amount of fixes with it of which some will be linked in this commit message. jmrozanec/cron-utils#394 jmrozanec/cron-utils#396 More to be found at: jmrozanec/cron-utils@8.1.1...master * Remove copyright header and jvm args (uber#417) In the previous gradle wrapper file and gradle bat file there were no copyright headers and no default jvm arguments. These have been removed to comply with previous wrapper files. * Re-added Maven publishing (uber#417) * Renamed mavenCustom -> maven (uber#417) * Moved maven publish to publications (uber#417) * Removed * import from JsonDataConverter (#417) The start import is not used anywhere else in the project, in order to keep the code design clean, the start import has to be removed.
1 parent cbe3706 commit 1ecbdcd

File tree

12 files changed

+129
-113
lines changed

12 files changed

+129
-113
lines changed

.buildkite/pipeline.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ steps:
33
agents:
44
queue: "workers"
55
docker: "*"
6-
command: "./gradlew test"
6+
command: "./gradlew --no-daemon test"
77
plugins:
88
- docker-compose#v3.0.0:
99
run: unit-test-test-service
@@ -13,7 +13,7 @@ steps:
1313
agents:
1414
queue: "workers"
1515
docker: "*"
16-
command: "./gradlew test"
16+
command: "./gradlew --no-daemon test"
1717
plugins:
1818
- docker-compose#v3.0.0:
1919
run: unit-test-docker-sticky-on
@@ -23,7 +23,7 @@ steps:
2323
agents:
2424
queue: "workers"
2525
docker: "*"
26-
command: "./gradlew test"
26+
command: "./gradlew --no-daemon test"
2727
plugins:
2828
- docker-compose#v3.0.0:
2929
run: unit-test-docker-sticky-off

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ before_install:
1010
- wget https://www-us.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz
1111
- tar xfz thrift-0.9.3.tar.gz
1212
- cd thrift-0.9.3
13-
- ./configure --enable-libs=no --enable-tests=no --enable-tutorial=no --with-cpp=no --with-c_glib=no --with-java=yes --with-ruby=no --with-erlang=no --with-go=no --with-nodejs=no
13+
- ./configure --enable-libs=no --enable-tests=no --enable-tutorial=no --with-cpp=no --with-c_glib=no --with-java=yes --with-ruby=no --with-erlang=no --with-go=no --with-nodejs=no --with-python=no
1414
- make -j2 && sudo make install
1515
- popd

build.gradle

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
buildscript {
22
dependencies {
3-
classpath "gradle.plugin.org.jruyi.gradle:thrift-gradle-plugin:0.4.0"
3+
classpath 'gradle.plugin.org.jruyi.gradle:thrift-gradle-plugin:0.4.1'
44
}
55
}
66

77
plugins {
8-
id 'net.minecrell.licenser' version '0.3'
9-
id "com.github.sherter.google-java-format" version "0.6"
10-
id "net.ltgt.errorprone" version "0.6"
8+
id 'net.minecrell.licenser' version '0.4.1'
9+
id 'com.github.sherter.google-java-format' version '0.8'
10+
id 'net.ltgt.errorprone' version '1.1.1'
11+
id 'java-library'
1112
}
1213

1314
repositories {
1415
maven {
15-
url "https://plugins.gradle.org/m2/"
16+
url 'https://plugins.gradle.org/m2/'
1617
}
1718
mavenCentral()
1819
}
1920

20-
apply plugin: 'java'
2121
apply plugin: 'maven'
22-
apply plugin: "org.jruyi.thrift"
22+
apply plugin: 'org.jruyi.thrift'
2323
apply plugin: 'maven-publish'
2424
apply plugin: 'com.github.sherter.google-java-format'
2525

26-
if (hasProperty("signing.keyId")) {
26+
if (hasProperty('signing.keyId')) {
2727
apply plugin: 'signing'
2828
signing {
2929
sign configurations.archives
@@ -39,21 +39,25 @@ googleJavaFormat {
3939
group = 'com.uber.cadence'
4040
version = '2.6.3'
4141

42-
description = """Uber Cadence Java Client"""
42+
description = '''Uber Cadence Java Client'''
4343

44-
sourceCompatibility = 1.8
45-
targetCompatibility = 1.8
44+
java {
45+
sourceCompatibility = JavaVersion.VERSION_1_8
46+
targetCompatibility = JavaVersion.VERSION_1_8
47+
}
4648

4749
dependencies {
48-
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
49-
errorprone("com.google.errorprone:error_prone_core:2.3.1")
50+
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
51+
errorprone('com.google.errorprone:error_prone_core:2.3.3')
52+
5053
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.8.5'
5154
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
5255
compile group: 'org.apache.thrift', name: 'libthrift', version: '0.9.3'
53-
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
54-
compile group: 'com.uber.m3', name: 'tally-core', version: '0.2.3'
55-
compile group: 'com.google.guava', name: 'guava', version: '27.0.1-jre'
56-
compile group: 'com.cronutils', name: 'cron-utils', version: '8.0.0'
56+
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
57+
compile group: 'com.uber.m3', name: 'tally-core', version: '0.4.0'
58+
compile group: 'com.google.guava', name: 'guava', version: '28.1-jre'
59+
compile group: 'com.cronutils', name: 'cron-utils', version: '9.0.0'
60+
5761
testCompile group: 'junit', name: 'junit', version: '4.12'
5862
testCompile group: 'com.googlecode.junit-toolbox', name: 'junit-toolbox', version: '2.4'
5963
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
@@ -67,18 +71,24 @@ license {
6771
compileJava {
6872
dependsOn 'googleJavaFormat'
6973
options.encoding = 'UTF-8'
70-
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Werror"
71-
options.errorprone.errorproneArgs << "-XepExcludedPaths:.*/generated-sources/.*"
74+
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror'
75+
options.errorprone.excludedPaths = '.*/generated-sources/.*'
76+
}
77+
78+
compileTestJava {
79+
options.encoding = 'UTF-8'
80+
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror'
81+
options.errorprone.excludedPaths = '.*/generated-sources/.*'
7282
}
7383

7484
// Generation version.properties for value to be included into the request header
7585
task createProperties(dependsOn: processResources) {
7686
doLast {
77-
def subdir = new File("$buildDir/resources/main/com/uber/cadence/")
87+
def subdir = new File('$buildDir/resources/main/com/uber/cadence/')
7888
if( !subdir.exists() ) {
7989
subdir.mkdirs()
8090
}
81-
new File("$buildDir/resources/main/com/uber/cadence/version.properties").withWriter { w ->
91+
new File('$buildDir/resources/main/com/uber/cadence/version.properties').withWriter { w ->
8292
Properties p = new Properties()
8393
p['cadence-client-version'] = project.version.toString()
8494
p.store w, null
@@ -90,12 +100,6 @@ classes {
90100
dependsOn createProperties
91101
}
92102

93-
compileTestJava {
94-
options.encoding = 'UTF-8'
95-
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Werror"
96-
options.errorprone.errorproneArgs << "-XepExcludedPaths:.*/generated-sources/.*"
97-
}
98-
99103
if (JavaVersion.current().isJava8Compatible()) {
100104
allprojects {
101105
tasks.withType(Javadoc) {
@@ -109,60 +113,56 @@ javadoc {
109113
}
110114

111115
task javadocJar(type: Jar) {
112-
classifier = 'javadoc'
113116
from javadoc
114117
}
115118

116119
task sourcesJar(type: Jar, dependsOn: classes) {
117-
classifier = 'sources'
118120
from sourceSets.main.allSource
119121
}
120122

121123
artifacts {
122124
archives javadocJar, sourcesJar
123125
}
124126

125-
def ossrhUsername = hasProperty('ossrhUsername') ? property('ossrhUsername') : ""
126-
def ossrhPassword = hasProperty('ossrhPassword') ? property('ossrhPassword') : ""
127+
def ossrhUsername = hasProperty('ossrhUsername') ? property('ossrhUsername') : ''
128+
def ossrhPassword = hasProperty('ossrhPassword') ? property('ossrhPassword') : ''
127129

128130
publishing {
129-
// Uncomment the following when we can use maven-publish to sign artifacts
130-
// https://github.com/gradle/gradle/issues/4943
131-
132-
// mavenCustom(MavenPublication) {
133-
// pom.withXml {
134-
// asNode().with {
135-
// appendNode('packaging', 'jar')
136-
// appendNode('name', 'cadence-client')
137-
// appendNode('description', description)
138-
// appendNode('url', 'https://github.com/uber-java/cadence-client')
139-
// appendNode('scm').with {
140-
// appendNode('url', 'https://github.com/uber-java/cadence-client')
141-
// appendNode('connection', '[email protected]:uber-java/cadence-client.git')
142-
// }
143-
// appendNode('licenses').with {
144-
// appendNode('license').with {
145-
// appendNode('name', 'The Apache License, Version 2.0')
146-
// appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
147-
// }
148-
// }
149-
// appendNode('developers').with {
150-
// appendNode('maxim').with {
151-
// appendNode('id', 'maxim')
152-
// appendNode('name', 'Maxim Fateev')
153-
// appendNode('email', '[email protected]')
154-
// }
155-
// appendNode('developer').with {
156-
// appendNode('id', 'meiliang')
157-
// appendNode('name', 'Liang Mei')
158-
// appendNode('email', '[email protected]')
159-
// }
160-
// }
161-
// }
162-
// }
163-
// }
164131

165132
publications {
133+
maven(MavenPublication) {
134+
pom.withXml {
135+
asNode().with {
136+
appendNode('packaging', 'jar')
137+
appendNode('name', 'cadence-client')
138+
appendNode('description', description)
139+
appendNode('url', 'https://github.com/uber-java/cadence-client')
140+
appendNode('scm').with {
141+
appendNode('url', 'https://github.com/uber-java/cadence-client')
142+
appendNode('connection', '[email protected]:uber-java/cadence-client.git')
143+
}
144+
appendNode('licenses').with {
145+
appendNode('license').with {
146+
appendNode('name', 'The Apache License, Version 2.0')
147+
appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
148+
}
149+
}
150+
appendNode('developers').with {
151+
appendNode('maxim').with {
152+
appendNode('id', 'maxim')
153+
appendNode('name', 'Maxim Fateev')
154+
appendNode('email', '[email protected]')
155+
}
156+
appendNode('developer').with {
157+
appendNode('id', 'meiliang')
158+
appendNode('name', 'Liang Mei')
159+
appendNode('email', '[email protected]')
160+
}
161+
}
162+
}
163+
}
164+
}
165+
166166
mavenJava(MavenPublication) {
167167
from components.java
168168
artifact javadocJar
@@ -176,9 +176,9 @@ publishing {
176176
password ossrhPassword
177177
}
178178
if(project.version.endsWith('-SNAPSHOT')) {
179-
url "https://oss.sonatype.org/content/repositories/snapshots/"
179+
url 'https://oss.sonatype.org/content/repositories/snapshots/'
180180
} else {
181-
url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
181+
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
182182
}
183183
}
184184
}
@@ -193,8 +193,8 @@ test {
193193
dependsOn 'registerDomain'
194194
dependsOn 'checkLicenseMain'
195195
testLogging {
196-
events "passed", "skipped", "failed"
197-
exceptionFormat "full"
196+
events 'passed', 'skipped', 'failed'
197+
exceptionFormat 'full'
198198
// Uncomment the following line if you want to see test logs in gradlew run.
199199
showStandardStreams true
200200
}
@@ -205,11 +205,11 @@ uploadArchives {
205205
mavenDeployer {
206206
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
207207

208-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
208+
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
209209
authentication(userName: ossrhUsername, password: ossrhPassword)
210210
}
211211

212-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
212+
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
213213
authentication(userName: ossrhUsername, password: ossrhPassword)
214214
}
215215

docker/buildkite/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
FROM openjdk:8
1+
FROM openjdk:8-alpine
22

3+
# Apache Thrift version
34
ENV APACHE_THRIFT_VERSION=0.9.3
45

5-
RUN apt-get update && apt-get -y install build-essential && apt-get install -y wget
6+
# Install dependencies using apk
7+
RUN apk update && apk add --virtual wget ca-certificates wget && apk add --virtual build-dependencies build-base gcc
68

9+
# Compile source
710
RUN set -ex ;\
811
wget http://www-us.apache.org/dist/thrift/${APACHE_THRIFT_VERSION}/thrift-${APACHE_THRIFT_VERSION}.tar.gz ;\
912
tar -xvf thrift-${APACHE_THRIFT_VERSION}.tar.gz ;\
1013
rm thrift-${APACHE_THRIFT_VERSION}.tar.gz ;\
1114
cd thrift-${APACHE_THRIFT_VERSION}/ ;\
12-
./configure --without-python --without-cpp ;\
15+
./configure --enable-libs=no --enable-tests=no --enable-tutorial=no --with-cpp=no --with-c_glib=no --with-java=yes --with-ruby=no --with-erlang=no --with-go=no --with-nodejs=no --with-python=no ;\
1316
make -j2 && make install ;\
1417
cd .. && rm -rf thrift-${APACHE_THRIFT_VERSION}
1518

19+
# Cleanup packages and remove cache
20+
RUN apk del build-dependencies wget && rm -rf /var/cache/apk/*
21+
1622
RUN mkdir /cadence-java-client
1723
WORKDIR /cadence-java-client

docker/buildkite/Dockerfile-local

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
FROM openjdk:8
1+
FROM openjdk:8-alpine
22

3-
COPY --from=thrift:0.9.3 /usr/local/bin/thrift /usr/local/bin/thrift
3+
# Apache Thrift version
4+
ENV APACHE_THRIFT_VERSION=0.9.3
5+
6+
# Install dependencies using apk
7+
RUN apk update && apk add --virtual build-dependencies build-base gcc
8+
9+
# Compile source
10+
COPY --from=thrift:${APACHE_THRIFT_VERSION} /usr/local/bin/thrift /usr/local/bin/thrift
11+
12+
# Cleanup packages and remove cache
13+
RUN apk del build-dependencies wget && rm -rf /var/cache/apk/*
414

515
RUN mkdir /cadence-java-client
616
WORKDIR /cadence-java-client

docker/buildkite/docker-compose-local.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ services:
4444
build:
4545
context: ../../
4646
dockerfile: ./docker/buildkite/Dockerfile-local
47-
command: "./gradlew test"
47+
command: "./gradlew --no-daemon test"
4848
environment:
4949
- "USER=unittest"
5050
- "CADENCE_SEEDS=cadence"
@@ -63,7 +63,7 @@ services:
6363
build:
6464
context: ../../
6565
dockerfile: ./docker/buildkite/Dockerfile-local
66-
command: "./gradlew test"
66+
command: "./gradlew --no-daemon test"
6767
environment:
6868
- "USER=unittest"
6969
- "CADENCE_SEEDS=cadence"
@@ -82,7 +82,7 @@ services:
8282
build:
8383
context: ../../
8484
dockerfile: ./docker/buildkite/Dockerfile-local
85-
command: "./gradlew test"
85+
command: "./gradlew --no-daemon test"
8686
environment:
8787
- "USER=unittest"
8888
- "USE_DOCKER_SERVICE=false"

0 commit comments

Comments
 (0)