[
https://issues.apache.org/jira/browse/BEAM-4556?focusedWorklogId=116423&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-116423
]
ASF GitHub Bot logged work on BEAM-4556:
----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Jun/18 14:00
Start Date: 27/Jun/18 14:00
Worklog Time Spent: 10m
Work Description: iemejia closed pull request #5773: [BEAM-4556] Enable
ErrorProne analysis and -Werror for all Java projects.
URL: https://github.com/apache/beam/pull/5773
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
index 807d00e8e1c..d26e2db577a 100644
--- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
@@ -56,12 +56,6 @@ class BeamModulePlugin implements Plugin<Project> {
/** Controls whether the findbugs plugin is enabled and configured. */
boolean enableFindbugs = true
- /** Controls whether the errorprone plugin is enabled and configured. */
- boolean enableErrorProne = true
-
- /** Controls whether compiler warnings are treated as errors. */
- boolean failOnWarning = true
-
/**
* List of additional lint warnings to disable.
* In addition, defaultLintSuppressions defined below
@@ -543,19 +537,15 @@ class BeamModulePlugin implements Plugin<Project> {
project.tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
- options.compilerArgs += ['-parameters', '-Xlint:all']+ (
- defaultLintSuppressions + configuration.disableLintWarnings
- ).collect { "-Xlint:-${it}" }
- if (configuration.enableErrorProne) {
- options.compilerArgs += [
- "-XepDisableWarningsInGeneratedCode",
-
"-XepExcludedPaths:(.*/)?(build/generated.*avro-java|build/generated)/.*",
- "-Xep:MutableConstantField:OFF" // Guava's immutable collections
cannot appear on API surface.
- ]
- }
- if (configuration.failOnWarning) {
- options.compilerArgs += "-Werror"
- }
+ options.compilerArgs += ([
+ '-parameters',
+ '-Xlint:all',
+ '-Werror',
+ '-XepDisableWarningsInGeneratedCode',
+
'-XepExcludedPaths:(.*/)?(build/generated.*avro-java|build/generated)/.*',
+ '-Xep:MutableConstantField:OFF' // Guava's immutable collections
cannot appear on API surface.
+ ]
+ + (defaultLintSuppressions +
configuration.disableLintWarnings).collect { "-Xlint:-${it}" })
}
// Configure the default test tasks set of tests executed
@@ -599,8 +589,12 @@ class BeamModulePlugin implements Plugin<Project> {
testApt auto_service
// These dependencies are needed to avoid error-prone warnings on
package-info.java files,
- // also to include the annotations to supress warnings.
- def findbugs_annotations =
"com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1"
+ // also to include the annotations to suppress warnings.
+ //
+ // findbugs-annotations artifact is licensed under LGPL and cannot be
included in the
+ // Apache Beam distribution, but may be relied on during build.
+ // See: https://www.apache.org/legal/resolved.html#prohibited
+ def findbugs_annotations = "com.google.code.findbugs:annotations:3.0.1"
compileOnly findbugs_annotations
apt findbugs_annotations
testCompileOnly findbugs_annotations
@@ -654,11 +648,9 @@ class BeamModulePlugin implements Plugin<Project> {
}
}
- // Enable errorprone, not by default right now
- if (configuration.enableErrorProne) {
- project.apply plugin: 'net.ltgt.errorprone'
- project.tasks.withType(JavaCompile) { options.compilerArgs +=
"-XepDisableWarningsInGeneratedCode" }
- }
+ // Enable errorprone static analysis
+ project.apply plugin: 'net.ltgt.errorprone'
+ project.tasks.withType(JavaCompile) { options.compilerArgs +=
"-XepDisableWarningsInGeneratedCode" }
// Enables a plugin which can perform shading of classes. See the
general comments
// above about dependency management for Java projects and how the
shadow plugin
diff --git a/model/fn-execution/build.gradle b/model/fn-execution/build.gradle
index ca6c806e438..ea9dd93bc0d 100644
--- a/model/fn-execution/build.gradle
+++ b/model/fn-execution/build.gradle
@@ -17,7 +17,7 @@
*/
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(enableFindbugs: false, enableErrorProne: false)
+applyJavaNature(enableFindbugs: false)
applyGrpcNature()
description = "Apache Beam :: Model :: Fn Execution"
diff --git a/model/job-management/build.gradle
b/model/job-management/build.gradle
index 66ce25b9cda..217a6eedf98 100644
--- a/model/job-management/build.gradle
+++ b/model/job-management/build.gradle
@@ -17,7 +17,7 @@
*/
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(enableFindbugs: false, enableErrorProne: false)
+applyJavaNature(enableFindbugs: false)
applyGrpcNature()
description = "Apache Beam :: Model :: Job Management"
diff --git a/model/pipeline/build.gradle b/model/pipeline/build.gradle
index 9e1c13aeffd..17ded8025cb 100644
--- a/model/pipeline/build.gradle
+++ b/model/pipeline/build.gradle
@@ -17,7 +17,7 @@
*/
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(enableFindbugs: false, enableErrorProne: false)
+applyJavaNature(enableFindbugs: false)
applyGrpcNature()
description = "Apache Beam :: Model :: Pipeline"
diff --git a/runners/flink/job-server/build.gradle
b/runners/flink/job-server/build.gradle
index f9604f35107..a4fd6ff12d0 100644
--- a/runners/flink/job-server/build.gradle
+++ b/runners/flink/job-server/build.gradle
@@ -18,7 +18,6 @@
apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(
- failOnWarning: true,
shadowClosure: {
append "reference.conf"
},
diff --git a/runners/google-cloud-dataflow-java/examples-streaming/build.gradle
b/runners/google-cloud-dataflow-java/examples-streaming/build.gradle
index 0580e660792..30376d046f1 100644
--- a/runners/google-cloud-dataflow-java/examples-streaming/build.gradle
+++ b/runners/google-cloud-dataflow-java/examples-streaming/build.gradle
@@ -19,7 +19,7 @@
import groovy.json.JsonOutput
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(failOnWarning: true, publish: false)
+applyJavaNature(publish: false)
// Evaluate the given project before this one, to allow referencing
// its sourceSets.test.output directly.
evaluationDependsOn(":beam-examples-java")
diff --git a/runners/google-cloud-dataflow-java/examples/build.gradle
b/runners/google-cloud-dataflow-java/examples/build.gradle
index c01e20b0914..b9d5c478b30 100644
--- a/runners/google-cloud-dataflow-java/examples/build.gradle
+++ b/runners/google-cloud-dataflow-java/examples/build.gradle
@@ -19,7 +19,7 @@
import groovy.json.JsonOutput
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(failOnWarning: true, publish: false)
+applyJavaNature(publish: false)
// Evaluate the given project before this one, to allow referencing
// its sourceSets.test.output directly.
evaluationDependsOn(":beam-examples-java")
diff --git a/sdks/java/core/build.gradle b/sdks/java/core/build.gradle
index 89086330469..efb0f3bff0b 100644
--- a/sdks/java/core/build.gradle
+++ b/sdks/java/core/build.gradle
@@ -17,7 +17,7 @@
*/
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(failOnWarning: false, shadowClosure: DEFAULT_SHADOW_CLOSURE <<
{
+applyJavaNature(shadowClosure: DEFAULT_SHADOW_CLOSURE << {
dependencies {
include(dependency(library.java.protobuf_java))
include(dependency(library.java.byte_buddy))
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
index 66f68e53c65..bb4da8b541f 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextIO.java
@@ -582,6 +582,7 @@ private CreateTextSourceFn(byte[] delimiter) {
abstract ValueProvider<ResourceId> getTempDirectory();
/** The delimiter between string records. */
+ @SuppressWarnings("mutable") // this returns an array that can be mutated
by the caller
abstract char[] getDelimiter();
/** An optional header to add to each file. */
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 116423)
Time Spent: 3h (was: 2h 50m)
> Enforce ErrorProne analysis in sdks-java-core project
> -----------------------------------------------------
>
> Key: BEAM-4556
> URL: https://issues.apache.org/jira/browse/BEAM-4556
> Project: Beam
> Issue Type: Improvement
> Components: runner-direct
> Reporter: Scott Wegner
> Assignee: Scott Wegner
> Priority: Minor
> Labels: errorprone, starter
> Fix For: 2.6.0
>
> Time Spent: 3h
> Remaining Estimate: 0h
>
> Java ErrorProne static analysis was [recently
> enabled|https://github.com/apache/beam/pull/5161] in the Gradle build
> process, but only as warnings. ErrorProne errors are generally useful and
> easy to fix. Some work was done to [make sdks-java-core
> ErrorProne-clean|https://github.com/apache/beam/pull/5319] and add
> enforcement, but for unrelated reasons the {{failOnWarning}} setting needed
> to be reverted. This task is clean ErrorProne warnings and add enforcement in
> {{beam-sdks-java-core}}. Additional context discussed on the [dev
> list|https://lists.apache.org/thread.html/95aae2785c3cd728c2d3378cbdff2a7ba19caffcd4faa2049d2e2f46@%3Cdev.beam.apache.org%3E].
> Fixing this issue will involve:
> # Follow instructions in the [Contribution
> Guide|https://beam.apache.org/contribute/] to set up a {{beam}} development
> environment.
> # Run the following command to compile and run ErrorProne analysis on the
> project: {{./gradlew :beam-sdks-java-core:assemble}}
> # Fix each ErrorProne warning from the {{sdks/java/core}} project.
> # In {{sdks/java/core/build.gradle}}, add {{failOnWarning: true}} to the call
> the {{applyJavaNature()}}
> ([example|https://github.com/apache/beam/pull/5319/files#diff-9390c20635aed5f42f83b97506a87333R20]).
> This starter issue is sponsored by [~swegner]. Feel free to [reach
> out|https://beam.apache.org/community/contact-us/] with questions or code
> review:
> * JIRA: [~swegner]
> * GitHub: [@swegner|https://github.com/swegner]
> * Slack: [@Scott Wegner|https://s.apache.org/beam-slack-channel]
> * Email: swegner at google dot com
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)