Skip to content

Commit 4215b80

Browse files
committed
Apply java plugin explicitly when needed
1 parent e13221b commit 4215b80

File tree

21 files changed

+122
-84
lines changed

21 files changed

+122
-84
lines changed

all/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "com.github.kt3k.coveralls"

alts/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "com.github.johnrengelman.shadow"

api/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "me.champeau.gradle.jmh"

auth/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "me.champeau.gradle.japicmp"

benchmarks/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id "application"
3+
id "java"
34
id "maven-publish"
45

56
id "com.google.protobuf"

build.gradle

Lines changed: 97 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import net.ltgt.gradle.errorprone.CheckSeverity
99

1010
subprojects {
1111
apply plugin: "checkstyle"
12-
apply plugin: "java"
1312
apply plugin: "maven"
1413
apply plugin: "idea"
1514
apply plugin: "signing"
@@ -20,30 +19,10 @@ subprojects {
2019
apply plugin: "ru.vyarus.animalsniffer"
2120

2221
apply plugin: "net.ltgt.errorprone"
23-
if (rootProject.properties.get('errorProne', true)) {
24-
dependencies {
25-
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
26-
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
27-
28-
annotationProcessor 'com.google.guava:guava-beta-checker:1.0'
29-
}
30-
} else {
31-
// Disable Error Prone
32-
allprojects {
33-
afterEvaluate { project ->
34-
project.tasks.withType(JavaCompile) {
35-
options.errorprone.enabled = false
36-
}
37-
}
38-
}
39-
}
4022

4123
group = "io.grpc"
4224
version = "1.25.0-SNAPSHOT" // CURRENT_GRPC_VERSION
4325

44-
sourceCompatibility = 1.7
45-
targetCompatibility = 1.7
46-
4726
repositories {
4827
maven { // The google mirror is less flaky than mavenCentral()
4928
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
@@ -63,31 +42,6 @@ subprojects {
6342
}
6443
}
6544

66-
compileTestJava {
67-
// serialVersionUID is basically guaranteed to be useless in our tests
68-
options.compilerArgs += [
69-
"-Xlint:-serial"
70-
]
71-
// LinkedList doesn't hurt much in tests and has lots of usages
72-
options.errorprone.check("JdkObsolete", CheckSeverity.OFF)
73-
}
74-
75-
jar.manifest {
76-
attributes('Implementation-Title': name,
77-
'Implementation-Version': version,
78-
'Built-By': System.getProperty('user.name'),
79-
'Built-JDK': System.getProperty('java.version'),
80-
'Source-Compatibility': sourceCompatibility,
81-
'Target-Compatibility': targetCompatibility)
82-
}
83-
84-
javadoc.options {
85-
encoding = 'UTF-8'
86-
use = true
87-
links 'https://docs.oracle.com/javase/8/docs/api/'
88-
source = "8"
89-
}
90-
9145
ext {
9246
def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
9347
protocPluginBaseName = 'protoc-gen-grpc-java'
@@ -233,12 +187,6 @@ subprojects {
233187
}
234188
}
235189

236-
dependencies {
237-
testCompile libraries.junit,
238-
libraries.mockito,
239-
libraries.truth
240-
}
241-
242190
// Disable JavaDoc doclint on Java 8. It's annoying.
243191
if (JavaVersion.current().isJava8Compatible()) {
244192
allprojects {
@@ -268,12 +216,81 @@ subprojects {
268216
}
269217
}
270218

271-
checkstyleMain {
272-
source = fileTree(dir: "src/main", include: "**/*.java")
273-
}
219+
plugins.withId("java") {
220+
sourceCompatibility = 1.7
221+
targetCompatibility = 1.7
222+
223+
dependencies {
224+
testCompile libraries.junit,
225+
libraries.mockito,
226+
libraries.truth
227+
}
228+
229+
compileTestJava {
230+
// serialVersionUID is basically guaranteed to be useless in our tests
231+
options.compilerArgs += [
232+
"-Xlint:-serial"
233+
]
234+
}
235+
236+
jar.manifest {
237+
attributes('Implementation-Title': name,
238+
'Implementation-Version': version,
239+
'Built-By': System.getProperty('user.name'),
240+
'Built-JDK': System.getProperty('java.version'),
241+
'Source-Compatibility': sourceCompatibility,
242+
'Target-Compatibility': targetCompatibility)
243+
}
244+
245+
javadoc.options {
246+
encoding = 'UTF-8'
247+
use = true
248+
links 'https://docs.oracle.com/javase/8/docs/api/'
249+
source = "8"
250+
}
251+
252+
checkstyleMain {
253+
source = fileTree(dir: "src/main", include: "**/*.java")
254+
}
274255

275-
checkstyleTest {
276-
source = fileTree(dir: "src/test", include: "**/*.java")
256+
checkstyleTest {
257+
source = fileTree(dir: "src/test", include: "**/*.java")
258+
}
259+
260+
// At a test failure, log the stack trace to the console so that we don't
261+
// have to open the HTML in a browser.
262+
test {
263+
testLogging {
264+
exceptionFormat = 'full'
265+
showExceptions true
266+
showCauses true
267+
showStackTraces true
268+
}
269+
maxHeapSize = '1500m'
270+
}
271+
272+
if (rootProject.properties.get('errorProne', true)) {
273+
dependencies {
274+
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
275+
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
276+
277+
annotationProcessor 'com.google.guava:guava-beta-checker:1.0'
278+
}
279+
} else {
280+
// Disable Error Prone
281+
allprojects {
282+
afterEvaluate { project ->
283+
project.tasks.withType(JavaCompile) {
284+
options.errorprone.enabled = false
285+
}
286+
}
287+
}
288+
}
289+
290+
compileTestJava {
291+
// LinkedList doesn't hurt much in tests and has lots of usages
292+
options.errorprone.check("JdkObsolete", CheckSeverity.OFF)
293+
}
277294
}
278295

279296
plugins.withId("me.champeau.gradle.jmh") {
@@ -300,27 +317,10 @@ subprojects {
300317
}
301318

302319
plugins.withId("maven-publish") {
303-
task javadocJar(type: Jar) {
304-
classifier = 'javadoc'
305-
from javadoc
306-
}
307-
308-
task sourcesJar(type: Jar) {
309-
classifier = 'sources'
310-
from sourceSets.main.allSource
311-
}
312-
313320
publishing {
314321
publications {
315322
// do not use mavenJava, as java plugin will modify it via "magic"
316323
maven(MavenPublication) {
317-
if (project.name != 'grpc-netty-shaded') {
318-
from components.java
319-
}
320-
321-
artifact javadocJar
322-
artifact sourcesJar
323-
324324
pom {
325325
name = project.group + ":" + project.name
326326
url = 'https://github.com/grpc/grpc-java'
@@ -400,18 +400,31 @@ subprojects {
400400
required false
401401
sign publishing.publications.maven
402402
}
403-
}
404403

405-
// At a test failure, log the stack trace to the console so that we don't
406-
// have to open the HTML in a browser.
407-
test {
408-
testLogging {
409-
exceptionFormat = 'full'
410-
showExceptions true
411-
showCauses true
412-
showStackTraces true
404+
plugins.withId("java") {
405+
task javadocJar(type: Jar) {
406+
classifier = 'javadoc'
407+
from javadoc
408+
}
409+
410+
task sourcesJar(type: Jar) {
411+
classifier = 'sources'
412+
from sourceSets.main.allSource
413+
}
414+
415+
publishing {
416+
publications {
417+
maven {
418+
if (project.name != 'grpc-netty-shaded') {
419+
from components.java
420+
}
421+
422+
artifact javadocJar
423+
artifact sourcesJar
424+
}
425+
}
426+
}
413427
}
414-
maxHeapSize = '1500m'
415428
}
416429

417430
// Run with: ./gradlew japicmp --continue

compiler/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id "cpp"
3+
id "java"
34
id "maven-publish"
45

56
id "com.google.protobuf"

context/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "me.champeau.gradle.japicmp"

core/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "me.champeau.gradle.japicmp"
@@ -7,6 +8,9 @@ plugins {
78

89
description = 'gRPC: Core'
910

11+
evaluationDependsOn(project(':grpc-context').path)
12+
evaluationDependsOn(project(':grpc-api').path)
13+
1014
dependencies {
1115
compile project(':grpc-api'),
1216
libraries.gson,

grpclb/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "java"
23
id "maven-publish"
34

45
id "com.google.protobuf"
@@ -7,6 +8,8 @@ plugins {
78

89
description = "gRPC: GRPCLB LoadBalancer plugin"
910

11+
evaluationDependsOn(project(':grpc-core').path)
12+
1013
dependencies {
1114
compile project(':grpc-core'),
1215
project(':grpc-protobuf'),

0 commit comments

Comments
 (0)