-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor top-level build.gradle to avoid enabling unhelpful plugins #6131
Changes from 1 commit
45d3c06
19fbaf6
fb2301e
af77556
b1bb108
84d9109
ee79444
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.github.kt3k.coveralls" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.github.johnrengelman.shadow" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.jmh" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.japicmp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id "application" | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ import net.ltgt.gradle.errorprone.CheckSeverity | |
|
||
subprojects { | ||
apply plugin: "checkstyle" | ||
apply plugin: "java" | ||
apply plugin: "maven" | ||
apply plugin: "idea" | ||
apply plugin: "signing" | ||
|
@@ -20,30 +19,10 @@ subprojects { | |
apply plugin: "ru.vyarus.animalsniffer" | ||
|
||
apply plugin: "net.ltgt.errorprone" | ||
if (rootProject.properties.get('errorProne', true)) { | ||
dependencies { | ||
errorprone 'com.google.errorprone:error_prone_core:2.3.3' | ||
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' | ||
|
||
annotationProcessor 'com.google.guava:guava-beta-checker:1.0' | ||
} | ||
} else { | ||
// Disable Error Prone | ||
allprojects { | ||
afterEvaluate { project -> | ||
project.tasks.withType(JavaCompile) { | ||
options.errorprone.enabled = false | ||
} | ||
} | ||
} | ||
} | ||
|
||
group = "io.grpc" | ||
version = "1.24.0-SNAPSHOT" // CURRENT_GRPC_VERSION | ||
|
||
sourceCompatibility = 1.7 | ||
targetCompatibility = 1.7 | ||
|
||
repositories { | ||
maven { // The google mirror is less flaky than mavenCentral() | ||
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" } | ||
|
@@ -63,31 +42,6 @@ subprojects { | |
} | ||
} | ||
|
||
compileTestJava { | ||
// serialVersionUID is basically guaranteed to be useless in our tests | ||
options.compilerArgs += [ | ||
"-Xlint:-serial" | ||
] | ||
// LinkedList doesn't hurt much in tests and has lots of usages | ||
options.errorprone.check("JdkObsolete", CheckSeverity.OFF) | ||
} | ||
|
||
jar.manifest { | ||
attributes('Implementation-Title': name, | ||
'Implementation-Version': version, | ||
'Built-By': System.getProperty('user.name'), | ||
'Built-JDK': System.getProperty('java.version'), | ||
'Source-Compatibility': sourceCompatibility, | ||
'Target-Compatibility': targetCompatibility) | ||
} | ||
|
||
javadoc.options { | ||
encoding = 'UTF-8' | ||
use = true | ||
links 'https://docs.oracle.com/javase/8/docs/api/' | ||
source = "8" | ||
} | ||
|
||
ext { | ||
def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" | ||
protocPluginBaseName = 'protoc-gen-grpc-java' | ||
|
@@ -233,12 +187,6 @@ subprojects { | |
} | ||
} | ||
|
||
dependencies { | ||
testCompile libraries.junit, | ||
libraries.mockito, | ||
libraries.truth | ||
} | ||
|
||
// Disable JavaDoc doclint on Java 8. It's annoying. | ||
if (JavaVersion.current().isJava8Compatible()) { | ||
allprojects { | ||
|
@@ -268,12 +216,81 @@ subprojects { | |
} | ||
} | ||
|
||
checkstyleMain { | ||
source = fileTree(dir: "src/main", include: "**/*.java") | ||
} | ||
plugins.withId("java") { | ||
sourceCompatibility = 1.7 | ||
targetCompatibility = 1.7 | ||
|
||
dependencies { | ||
testCompile libraries.junit, | ||
libraries.mockito, | ||
libraries.truth | ||
} | ||
|
||
compileTestJava { | ||
// serialVersionUID is basically guaranteed to be useless in our tests | ||
options.compilerArgs += [ | ||
"-Xlint:-serial" | ||
] | ||
} | ||
|
||
jar.manifest { | ||
attributes('Implementation-Title': name, | ||
'Implementation-Version': version, | ||
'Built-By': System.getProperty('user.name'), | ||
'Built-JDK': System.getProperty('java.version'), | ||
'Source-Compatibility': sourceCompatibility, | ||
'Target-Compatibility': targetCompatibility) | ||
} | ||
|
||
javadoc.options { | ||
encoding = 'UTF-8' | ||
use = true | ||
links 'https://docs.oracle.com/javase/8/docs/api/' | ||
source = "8" | ||
} | ||
|
||
checkstyleMain { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and no. checkstyle is always enabled so there's no need to include it in a block. The other things I moved to |
||
source = fileTree(dir: "src/main", include: "**/*.java") | ||
} | ||
|
||
checkstyleTest { | ||
source = fileTree(dir: "src/test", include: "**/*.java") | ||
checkstyleTest { | ||
source = fileTree(dir: "src/test", include: "**/*.java") | ||
} | ||
|
||
// At a test failure, log the stack trace to the console so that we don't | ||
// have to open the HTML in a browser. | ||
test { | ||
testLogging { | ||
exceptionFormat = 'full' | ||
showExceptions true | ||
showCauses true | ||
showStackTraces true | ||
} | ||
maxHeapSize = '1500m' | ||
} | ||
|
||
if (rootProject.properties.get('errorProne', true)) { | ||
dependencies { | ||
errorprone 'com.google.errorprone:error_prone_core:2.3.3' | ||
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' | ||
|
||
annotationProcessor 'com.google.guava:guava-beta-checker:1.0' | ||
} | ||
} else { | ||
// Disable Error Prone | ||
allprojects { | ||
afterEvaluate { project -> | ||
project.tasks.withType(JavaCompile) { | ||
options.errorprone.enabled = false | ||
} | ||
} | ||
} | ||
} | ||
|
||
compileTestJava { | ||
// LinkedList doesn't hurt much in tests and has lots of usages | ||
options.errorprone.check("JdkObsolete", CheckSeverity.OFF) | ||
} | ||
} | ||
|
||
plugins.withId("me.champeau.gradle.jmh") { | ||
|
@@ -300,27 +317,10 @@ subprojects { | |
} | ||
|
||
plugins.withId("maven-publish") { | ||
task javadocJar(type: Jar) { | ||
classifier = 'javadoc' | ||
from javadoc | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
publishing { | ||
publications { | ||
// do not use mavenJava, as java plugin will modify it via "magic" | ||
maven(MavenPublication) { | ||
if (project.name != 'grpc-netty-shaded') { | ||
from components.java | ||
} | ||
|
||
artifact javadocJar | ||
artifact sourcesJar | ||
|
||
pom { | ||
name = project.group + ":" + project.name | ||
url = 'https://github.com/grpc/grpc-java' | ||
|
@@ -400,18 +400,31 @@ subprojects { | |
required false | ||
sign publishing.publications.maven | ||
} | ||
} | ||
|
||
// At a test failure, log the stack trace to the console so that we don't | ||
// have to open the HTML in a browser. | ||
test { | ||
testLogging { | ||
exceptionFormat = 'full' | ||
showExceptions true | ||
showCauses true | ||
showStackTraces true | ||
plugins.withId("java") { | ||
task javadocJar(type: Jar) { | ||
classifier = 'javadoc' | ||
from javadoc | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven { | ||
if (project.name != 'grpc-netty-shaded') { | ||
from components.java | ||
} | ||
|
||
artifact javadocJar | ||
artifact sourcesJar | ||
} | ||
} | ||
} | ||
} | ||
maxHeapSize = '1500m' | ||
} | ||
|
||
// Run with: ./gradlew japicmp --continue | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id "cpp" | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.japicmp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
@@ -7,6 +8,8 @@ plugins { | |
|
||
description = "gRPC: GRPCLB LoadBalancer plugin" | ||
|
||
evaluationDependsOn(project(':grpc-core').path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had trouble with |
||
|
||
dependencies { | ||
compile project(':grpc-core'), | ||
project(':grpc-protobuf'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id "application" | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.japicmp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.github.johnrengelman.shadow" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.japicmp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.japicmp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.google.protobuf" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "me.champeau.gradle.japicmp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id "java" | ||
id "maven-publish" | ||
|
||
id "com.github.johnrengelman.shadow" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move
'maven'
plugin as well? If mavne-publish is a super set of maven plugin, we can remove maven plugin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just assume delete the maven plugin. I couldn't find anything that failed when I removed the maven plugin outright. That seemed suspicious to me, so I just left it in place for now to reduce the risk.