Skip to content

Commit

Permalink
Exclude Spark UnusedStubClass from class uniqueness (#2390)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-baker authored Sep 16, 2022
1 parent 95e640e commit 6a9ea8b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2390.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Exclude Spark UnusedStubClass from class uniqueness
links:
- https://github.com/palantir/gradle-baseline/pull/2390
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public final Result hashClasses(ResolvedArtifact resolvedArtifact, Logger logger
continue;
}

if (entry.getName().contains("module-info.class")) {
// Java 9 allows jars to have a module-info.class file in the root,
// we shouldn't complain about these.
if (isExcluded(entry.getName())) {
continue;
}

Expand Down Expand Up @@ -116,4 +114,13 @@ public final void close() {
cache.invalidateAll();
cache.cleanUp();
}

/**
* Java 9 allows jars to have a module-info.class, we shouldn't complain about these.
* Spark contains an 'UnusedStubClass' which generates many false positives, we shouldn't complain about this,
* either.
*/
private static boolean isExcluded(String path) {
return path.endsWith("module-info.class") || path.equals("org/apache/spark/unused/UnusedStubClass.class");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ class BaselineClassUniquenessPluginIntegrationTest extends AbstractPluginTest {
with('checkClassUniqueness', '-s').build()
}

def 'ignores duplicates based on module-info and UnusedStubClass'() {
when:
buildFile << standardBuildFile
buildFile << """
dependencies {
// depends on spark-network-common, which also contains UnusedStubClass. Also depends on versions of Jackson
// that use module-info.java.
api 'org.apache.spark:spark-network-shuffle_2.13:3.3.0'
}
""".stripIndent()

then:
with('checkClassUniqueness', '-s').build()
}

def 'task should be up-to-date when classpath is unchanged'() {
when:
buildFile << standardBuildFile
Expand Down

0 comments on commit 6a9ea8b

Please sign in to comment.