[ 
https://issues.apache.org/jira/browse/BEAM-8747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16978523#comment-16978523
 ] 

Tomo Suzuki edited comment on BEAM-8747 at 11/20/19 4:33 PM:
-------------------------------------------------------------

Trying https://github.com/nebula-plugins/gradle-lint-plugin. 

Only applying the plugin at sdks/java/io/google-cloud-platform



{noformat}
suztomo@suxtomo24:~/beam6$ git diff
diff --git a/build.gradle b/build.gradle
index 6456a5ebb4..12f58a637a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -31,8 +31,10 @@ plugins {
   id 'net.researchgate.release' version '2.6.0'
   id 'org.apache.beam.module'
   id "org.sonarqube" version "2.7"
+  id 'nebula.lint' version '16.0.2'
 }
 
+
 
/*************************************************************************************************/
 // Configure the root project
 
diff --git a/sdks/java/io/google-cloud-platform/build.gradle 
b/sdks/java/io/google-cloud-platform/build.gradle
index 0c1befd311..0ecc3d0b73 100644
--- a/sdks/java/io/google-cloud-platform/build.gradle
+++ b/sdks/java/io/google-cloud-platform/build.gradle
@@ -24,6 +24,9 @@ applyJavaNature(
   enableSpotbugs: false,
 )
 
+apply plugin: 'nebula.lint'
+gradleLint.rules += 'all-dependency'
+
 description = "Apache Beam :: SDKs :: Java :: IO :: Google Cloud Platform"
 ext.summary = "IO library to read and write Google Cloud Platform systems from 
Beam."
 
@@ -53,7 +56,7 @@ dependencies {
   compile library.java.grpc_netty
   compile library.java.grpc_stub
   compile library.java.grpc_google_cloud_pubsub_v1
-  compile library.java.guava
+//  compile library.java.guava
   compile library.java.jackson_databind
   compile library.java.joda_time
   compile library.java.netty_handler

{noformat}

https://gist.github.com/suztomo/1aa9bf01b9765b6af0652f1c251ca573

This plugin doesn't say the Guava in sdks/java/io/google-cloud-platform is 
unused. Yet, I don't see com.google.common in the source code.

Run the report with debug logging

{code:shell}
 ./gradlew -p sdks/java/io/google-cloud-platform generateGradleLintReport 
--debug |grep com.netflix |tee /tmp/lint.txt

{code}




was (Author: suztomo):
Trying https://github.com/nebula-plugins/gradle-lint-plugin. 


{code}
suztomo@suxtomo24:~/beam6$ git diff
diff --git a/build.gradle b/build.gradle
index 6456a5ebb4..faaf70ea18 100644
--- a/build.gradle
+++ b/build.gradle
@@ -31,6 +31,12 @@ plugins {
   id 'net.researchgate.release' version '2.6.0'
   id 'org.apache.beam.module'
   id "org.sonarqube" version "2.7"
+  id 'nebula.lint' version '16.0.2'
+}
+
+allprojects {
+  apply plugin: 'nebula.lint'
+  gradleLint.rules += 'unused-dependency'
 }
{code}


{code:shell}
suztomo@suxtomo24:~/beam6$ ./gradlew -p sdks/java/io/google-cloud-platform check
{code}
This gave 104 problems (0 errors, 104 warnings).

https://gist.github.com/suztomo/1aa9bf01b9765b6af0652f1c251ca573

This plugin doesn't say the Guava in sdks/java/io/google-cloud-platform is 
unused. Yet, I don't see com.google.common in the source code. The plugin also 
says hamcrest dependencies are unused. True? This seems wrong.


When I removed the guava line from the build.gradle, the plugin reports:


{noformat}
warning   unused-dependency                  one or more classes in 
com.google.guava:guava:20.0 are required by your code directly (no auto-fix 
available)
{noformat}




> Remove Unused non-vendored Guava compile dependencies
> -----------------------------------------------------
>
>                 Key: BEAM-8747
>                 URL: https://issues.apache.org/jira/browse/BEAM-8747
>             Project: Beam
>          Issue Type: Bug
>          Components: build-system
>            Reporter: Tomo Suzuki
>            Assignee: Tomo Suzuki
>            Priority: Major
>         Attachments: Guava used as fully-qualified class name.png
>
>
> [~kenn] says:
> BeamModulePlugin just contains lists of versions to ease coordination across 
> Beam modules, but mostly does not create dependencies. Most of Beam's modules 
> only depend on a few things there. For example Guava is not a core 
> dependency, but here is where it is actually depended upon:
> $ find . -name build.gradle | xargs grep library.java.guava
> ./sdks/java/core/build.gradle:  shadowTest library.java.guava_testlib
> ./sdks/java/extensions/sql/jdbc/build.gradle:  compile library.java.guava
> ./sdks/java/io/google-cloud-platform/build.gradle:  compile library.java.guava
> ./sdks/java/io/kinesis/build.gradle:  testCompile library.java.guava_testlib
> These results appear to be misleading. Grepping for 'import 
> com.google.common', I see this as the actual state of things:
>  - GCP connector does not appear to actually depend on Guava in compile scope
>  - The Beam SQL JDBC driver does not appear to actually depend on Guava in 
> compile scope
>  - The Dataflow Java worker does depend on Guava at compile scope but has 
> incorrect dependencies (and it probably shouldn't)
>  - KinesisIO does depend on Guava at compile scope but has incorrect 
> dependencies (Kinesis libs have Guava on API surface so it is OK here, but 
> should be correctly declared)
>  - ZetaSQL translator does depend on Guava at compile scope but has incorrect 
> dependencies (ZetaSQL has it on API surface so it is OK here, but should be 
> correctly declared)
> We used to have an analysis that prevented this class of error.
> Once the errors are fixed, the guava_version is simply a version that we have 
> discovered that seems to work for both Kinesis and ZetaSQL, libraries we do 
> not control. Kinesis producer is built against 18.0. Kinesis client against 
> 26.0-jre. ZetaSQL against 26.0-android.
> (or maybe I messed up in my analysis)
> Kenn



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to