Skip to content

Commit 0044f8c

Browse files
authored
all: migrate gradle build to java-library plugin
- Use gradle configuration `api` for dependencies that are part of grpc public api signatures. - Replace deprecated gradle configurations `compile`, `testCompile`, `runtime` and `testRuntime`. - With minimal change in dependencies: If we need dep X and Y to compile our code, and if X transitively depends on Y, then our build would still pass even if we only include X as `compile`/`implementation` dependency for our project. Ideally we should include both X and Y explicitly as `implementation` dependency for our project, but in this PR we don't add the missing Y if it is previously missing.
1 parent 20f712c commit 0044f8c

File tree

26 files changed

+119
-106
lines changed

26 files changed

+119
-106
lines changed

all/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ for (subproject in rootProject.subprojects) {
3131
}
3232

3333
dependencies {
34-
compile subprojects.minus(project(':grpc-protobuf-lite'))
34+
implementation subprojects.minus(project(':grpc-protobuf-lite'))
3535
}
3636

3737
javadoc {

alts/build.gradle

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44

55
id "com.github.johnrengelman.shadow"
@@ -13,34 +13,35 @@ sourceCompatibility = 1.7
1313
targetCompatibility = 1.7
1414

1515
dependencies {
16-
compile project(':grpc-auth'),
17-
project(':grpc-core'),
16+
api project(':grpc-core')
17+
implementation project(':grpc-auth'),
1818
project(':grpc-grpclb'),
1919
project(':grpc-protobuf'),
2020
project(':grpc-stub'),
2121
libraries.lang,
2222
libraries.protobuf,
2323
libraries.conscrypt
24-
def nettyDependency = compile project(':grpc-netty')
25-
compile (libraries.google_auth_oauth2_http) {
24+
def nettyDependency = implementation project(':grpc-netty')
25+
implementation (libraries.google_auth_oauth2_http) {
2626
// prefer our own versions instead of google-auth-oauth2-http's dependency
2727
exclude group: 'com.google.guava', module: 'guava'
2828
// we'll always be more up-to-date
2929
exclude group: 'io.grpc', module: 'grpc-context'
3030
}
31+
guavaDependency 'implementation'
3132
compileOnly libraries.javax_annotation
3233

33-
shadow configurations.compile.getDependencies().minus(nettyDependency)
34+
shadow configurations.implementation.getDependencies().minus(nettyDependency)
3435
shadow project(path: ':grpc-netty-shaded', configuration: 'shadow')
3536

36-
testCompile project(':grpc-testing'),
37+
testImplementation project(':grpc-testing'),
3738
project(':grpc-testing-proto'),
3839
libraries.guava,
3940
libraries.guava_testlib,
4041
libraries.junit,
4142
libraries.mockito,
4243
libraries.truth
43-
testRuntime libraries.netty_tcnative,
44+
testRuntimeOnly libraries.netty_tcnative,
4445
libraries.netty_epoll
4546
signature 'org.codehaus.mojo.signature:java17:1.0@signature'
4647
}

android-interop-testing/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ dependencies {
6565
implementation (libraries.google_auth_oauth2_http) {
6666
exclude group: 'org.apache.httpcomponents'
6767
}
68+
censusGrpcMetricDependency 'implementation'
6869

6970
compileOnly libraries.javax_annotation
7071

android/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ repositories {
2626
}
2727

2828
dependencies {
29-
implementation project(':grpc-core')
30-
29+
api project(':grpc-core')
30+
guavaDependency 'implementation'
3131
testImplementation project('::grpc-okhttp')
3232
testImplementation libraries.androidx_test
3333
testImplementation libraries.junit

api/build.gradle

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44

55
id "me.champeau.gradle.jmh"
@@ -11,13 +11,11 @@ description = 'gRPC: API'
1111
evaluationDependsOn(project(':grpc-context').path)
1212

1313
dependencies {
14-
compile project(':grpc-context'),
15-
libraries.errorprone,
16-
libraries.jsr305,
17-
libraries.animalsniffer_annotations
18-
guavaDependency 'compile'
14+
api project(':grpc-context'),
15+
libraries.jsr305
16+
guavaDependency 'implementation'
1917

20-
testCompile project(':grpc-context').sourceSets.test.output,
18+
testImplementation project(':grpc-context').sourceSets.test.output,
2119
project(':grpc-testing'),
2220
project(':grpc-grpclb'),
2321
libraries.guava_testlib

auth/build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44

55
id "me.champeau.gradle.japicmp"
@@ -8,9 +8,10 @@ plugins {
88

99
description = "gRPC: Auth"
1010
dependencies {
11-
compile project(':grpc-api'),
11+
api project(':grpc-api'),
1212
libraries.google_auth_credentials
13-
testCompile project(':grpc-testing'),
13+
guavaDependency 'implementation'
14+
testImplementation project(':grpc-testing'),
1415
libraries.google_auth_oauth2_http
1516
signature "org.codehaus.mojo.signature:java17:1.0@signature"
1617
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"

benchmarks/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ configurations {
2121
}
2222

2323
dependencies {
24-
compile project(':grpc-core'),
24+
implementation project(':grpc-core'),
2525
project(':grpc-netty'),
2626
project(':grpc-okhttp'),
2727
project(':grpc-stub'),
@@ -34,7 +34,7 @@ dependencies {
3434
compileOnly libraries.javax_annotation
3535
alpnagent libraries.jetty_alpn_agent
3636

37-
testCompile libraries.junit,
37+
testImplementation libraries.junit,
3838
libraries.mockito
3939
}
4040

census/build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44
}
55

@@ -8,12 +8,12 @@ description = 'gRPC: Census'
88
evaluationDependsOn(project(':grpc-api').path)
99

1010
dependencies {
11-
compile project(':grpc-api')
11+
api project(':grpc-api')
12+
guavaDependency 'implementation'
13+
censusApiDependency 'implementation'
14+
censusGrpcMetricDependency 'implementation'
1215

13-
censusApiDependency 'compile'
14-
censusGrpcMetricDependency 'compile'
15-
16-
testCompile project(':grpc-api').sourceSets.test.output,
16+
testImplementation project(':grpc-api').sourceSets.test.output,
1717
project(':grpc-context').sourceSets.test.output,
1818
project(':grpc-core').sourceSets.test.output,
1919
project(':grpc-testing'),

compiler/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ model {
126126
}
127127

128128
configurations {
129-
testLiteCompile
129+
testLiteImplementation
130130
}
131131

132132
dependencies {
133-
testCompile project(':grpc-protobuf'),
133+
testImplementation project(':grpc-protobuf'),
134134
project(':grpc-stub'),
135135
libraries.javax_annotation
136-
testLiteCompile project(':grpc-protobuf-lite'),
136+
testLiteImplementation project(':grpc-protobuf-lite'),
137137
project(':grpc-stub'),
138138
libraries.javax_annotation
139139
}

context/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
description = 'gRPC: Context'
1111

1212
dependencies {
13-
testCompile libraries.jsr305, libraries.guava_testlib
13+
testImplementation libraries.jsr305, libraries.guava_testlib
1414
signature "org.codehaus.mojo.signature:java17:1.0@signature"
1515
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
1616
}

core/build.gradle

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44

55
id "me.champeau.gradle.japicmp"
@@ -13,12 +13,14 @@ evaluationDependsOn(project(':grpc-context').path)
1313
evaluationDependsOn(project(':grpc-api').path)
1414

1515
dependencies {
16-
compile project(':grpc-api'),
17-
libraries.gson,
16+
api project(':grpc-api')
17+
implementation libraries.gson,
1818
libraries.android_annotations,
19-
libraries.errorprone // prefer our version to perfmark's 2.3.3
20-
perfmarkDependency 'compile'
21-
testCompile project(':grpc-context').sourceSets.test.output,
19+
libraries.animalsniffer_annotations,
20+
libraries.errorprone
21+
guavaDependency 'implementation'
22+
perfmarkDependency 'implementation'
23+
testImplementation project(':grpc-context').sourceSets.test.output,
2224
project(':grpc-api').sourceSets.test.output,
2325
project(':grpc-testing'),
2426
project(':grpc-grpclb'),

cronet/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ android {
3333
}
3434

3535
dependencies {
36-
implementation project(':grpc-core')
36+
api project(':grpc-core'),
37+
libraries.cronet_api
38+
guavaDependency 'implementation'
3739
testImplementation project(':grpc-testing')
3840

39-
implementation libraries.cronet_api
4041
testImplementation libraries.cronet_embedded
4142

4243
testImplementation libraries.junit

gae-interop-testing/gae-jdk8/build.gradle

+8-9
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
4444

4545
dependencies {
4646
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
47-
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59'
48-
// Deps needed by all gRPC apps in GAE
49-
compile libraries.google_api_protos
50-
compile project(":grpc-okhttp")
51-
compile project(":grpc-protobuf")
52-
compile project(":grpc-stub")
53-
compile (project(":grpc-interop-testing")) {
54-
exclude group: "io.grpc", module: "grpc-netty-shaded"
47+
runtimeOnly 'com.google.appengine:appengine-api-1.0-sdk:1.9.59'
48+
implementation project(':grpc-netty')
49+
implementation project(":grpc-stub")
50+
implementation (project(':grpc-interop-testing')) {
51+
exclude group: 'io.grpc', module: 'grpc-alts'
5552
}
56-
compile libraries.netty_tcnative
53+
implementation libraries.junit
54+
implementation libraries.protobuf
55+
runtimeOnly libraries.netty_tcnative
5756
}
5857

5958
compileJava {

grpclb/build.gradle

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ description = "gRPC: GRPCLB LoadBalancer plugin"
1111
evaluationDependsOn(project(':grpc-core').path)
1212

1313
dependencies {
14-
compile project(':grpc-core'),
14+
implementation project(':grpc-core'),
1515
project(':grpc-protobuf'),
1616
project(':grpc-stub'),
1717
libraries.protobuf
18-
compile (libraries.protobuf_util) {
18+
implementation (libraries.protobuf_util) {
1919
// prefer our own versions instead of protobuf-util's dependency
2020
exclude group: 'com.google.guava', module: 'guava'
2121
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
2222
}
23+
guavaDependency 'implementation'
24+
runtimeOnly libraries.errorprone
2325
compileOnly libraries.javax_annotation
24-
testCompile libraries.truth,
26+
testImplementation libraries.truth,
2527
project(':grpc-core').sourceSets.test.output
2628
}
2729

interop-testing/build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ configurations {
1717
evaluationDependsOn(project(':grpc-context').path)
1818

1919
dependencies {
20-
compile project(path: ':grpc-alts', configuration: 'shadow'),
20+
implementation project(path: ':grpc-alts', configuration: 'shadow'),
2121
project(':grpc-auth'),
2222
project(':grpc-census'),
2323
project(':grpc-core'),
@@ -30,12 +30,13 @@ dependencies {
3030
libraries.google_auth_oauth2_http,
3131
libraries.junit,
3232
libraries.truth
33+
censusGrpcMetricDependency 'implementation'
3334
compileOnly libraries.javax_annotation
34-
runtime libraries.opencensus_impl,
35+
runtimeOnly libraries.opencensus_impl,
3536
libraries.netty_tcnative,
3637
project(':grpc-grpclb')
3738
xdsRuntime project(path: ':grpc-xds', configuration: 'shadow')
38-
testCompile project(':grpc-context').sourceSets.test.output,
39+
testImplementation project(':grpc-context').sourceSets.test.output,
3940
libraries.mockito
4041
alpnagent libraries.jetty_alpn_agent
4142
}

netty/build.gradle

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44

55
id "me.champeau.gradle.japicmp"
@@ -16,15 +16,17 @@ configurations {
1616
evaluationDependsOn(project(':grpc-core').path)
1717

1818
dependencies {
19-
compile project(':grpc-core'),
20-
libraries.netty,
21-
libraries.netty_proxy_handler
19+
api project(':grpc-core'),
20+
libraries.netty
21+
implementation libraries.netty_proxy_handler
22+
guavaDependency 'implementation'
23+
perfmarkDependency 'implementation'
2224

2325
// Tests depend on base class defined by core module.
24-
testCompile project(':grpc-core').sourceSets.test.output,
26+
testImplementation project(':grpc-core').sourceSets.test.output,
2527
project(':grpc-testing'),
2628
project(':grpc-testing-proto')
27-
testRuntime libraries.netty_tcnative,
29+
testRuntimeOnly libraries.netty_tcnative,
2830
libraries.conscrypt,
2931
libraries.netty_epoll
3032
signature "org.codehaus.mojo.signature:java17:1.0@signature"

netty/shaded/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ description = "gRPC: Netty Shaded"
1010
sourceSets { testShadow {} }
1111

1212
dependencies {
13-
compile project(':grpc-netty')
14-
runtime libraries.netty_tcnative,
13+
implementation project(':grpc-netty')
14+
runtimeOnly libraries.netty_tcnative,
1515
libraries.netty_epoll
16-
testShadowCompile files(shadowJar),
16+
testShadowImplementation files(shadowJar),
1717
configurations.shadow,
1818
project(':grpc-testing-proto'),
1919
project(':grpc-testing'),

okhttp/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "java"
2+
id "java-library"
33
id "maven-publish"
44

55
id "me.champeau.gradle.japicmp"
@@ -11,16 +11,16 @@ description = "gRPC: OkHttp"
1111
evaluationDependsOn(project(':grpc-core').path)
1212

1313
dependencies {
14-
compile project(':grpc-core'),
15-
libraries.okio
16-
17-
compile (libraries.okhttp) {
14+
api project(':grpc-core')
15+
api (libraries.okhttp) {
1816
// prefer our own versions instead of okhttp's dependency
1917
exclude group: 'com.squareup.okio', module: 'okio'
2018
}
21-
19+
implementation libraries.okio
20+
guavaDependency 'implementation'
21+
perfmarkDependency 'implementation'
2222
// Tests depend on base class defined by core module.
23-
testCompile project(':grpc-core').sourceSets.test.output,
23+
testImplementation project(':grpc-core').sourceSets.test.output,
2424
project(':grpc-testing'),
2525
project(':grpc-netty')
2626
signature "org.codehaus.mojo.signature:java17:1.0@signature"

0 commit comments

Comments
 (0)