Skip to content

Commit

Permalink
Add dependency-analysis-gradle-plugin (#3158)
Browse files Browse the repository at this point in the history
Motivation:

The Dependency Analysis Gradle Plugin (DAGP) detects the following
problems with dependencies: unused dependencies, used transitive
dependencies that should be declared directly, dependencies declared on
the wrong configuration.

Modifications:

- Add new plugin as part of our main `build.gradle` file;
- Make `buildHealth` task part of the `quality` task;
- When run PRQ action on CI, print report to console;
- Make sure `copySourcesForJersey3` task always executes before
dependency-analysis as it depends on copied source code;

Result:

We can automatically detect issues with dependencies.
  • Loading branch information
idelpivnitskiy authored Jan 3, 2025
1 parent 135a994 commit 167012a
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci-prq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Clean Gradle project
run: ./gradlew --parallel clean
- name: Build with Gradle
run: ./gradlew --parallel quality
run: ./gradlew --parallel -Pdependency.analysis.print.build.health=true quality
- name: Upload CheckStyle Results
if: always()
uses: actions/upload-artifact@v4
Expand Down
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,40 @@ if (!repositories) {
print("This machine already has some pre-configured repositories, will use: ${repositories*.name.join(", ")}")
}

buildscript {
if (!repositories) {
repositories {
gradlePluginPortal()
}
}
dependencies {
if (JavaVersion.current().isJava11Compatible()) {
classpath("com.autonomousapps:dependency-analysis-gradle-plugin:$dependencyAnalysisPluginVersion")
}
}
}

apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-root"

// Unfortunately, we can not make this validation part of our servicetalk-gradle-plugin-internal because it requires
// JDK11 while we build and package out plugin with JDK8.
if (JavaVersion.current().isJava11Compatible()) {
apply plugin: "com.autonomousapps.dependency-analysis"

dependencyAnalysis {
issues {
all {
onAny {
severity("warn") // FIXME: switch to "fail" when all issues are addressed
exclude("com.google.code.findbugs:jsr305")
}
}
}
}

quality.dependsOn buildHealth
}

task validateLocalDocSite(type: Exec) {
group 'Documentation'
description 'Generate and validate servicetalk.io site documentation'
Expand All @@ -56,6 +88,8 @@ subprojects {
// mockito 5 only supports jdk11+
if (JavaVersion.current() < JavaVersion.VERSION_11) {
project.setProperty("mockitoCoreVersion", mockitoCorePreJdk11Version)
} else {
apply plugin: "com.autonomousapps.dependency-analysis"
}
// Used by ci-release.yaml to determine which modules need to be built/released with JDK11.
task printJavaTargetCompatibility {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ mockitoCoreVersion=5.14.2
# mockito version is overridden for <jdk11 due to incompatibilities with newer bytebuddy and class format
mockitoCorePreJdk11Version=4.11.0
spotbugsPluginVersion=5.0.13
dependencyAnalysisPluginVersion=2.6.1

apacheDirectoryServerVersion=1.5.7
commonsLangVersion=2.6
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-data-jackson-jersey3-jakarta10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE10}"
def actualJaxRsVersion = "${jaxRsVersionEE10}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-data-jackson-jersey3-jakarta9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE9}"
def actualJaxRsVersion = "${jaxRsVersionEE9}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-data-protobuf-jersey3-jakarta10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.generateTestProto.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE10}"
def actualJaxRsVersion = "${jaxRsVersionEE10}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-data-protobuf-jersey3-jakarta9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.generateTestProto.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE9}"
def actualJavaxActivationVersion = "${javaxActivationVersionEE9}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ task copySourcesForJersey3(type: Copy) {
tasks.processResources.dependsOn(copySourcesForJersey3)
tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE10}"
def actualJaxRsVersion = "${jaxRsVersionEE10}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-http-router-jersey3-jakarta10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE10}"
def actualJavaxActivationVersion = "${javaxActivationVersionEE10}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ task copySourcesForJersey3(type: Copy) {
tasks.processResources.dependsOn(copySourcesForJersey3)
tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE9}"
def actualJaxRsVersion = "${jaxRsVersionEE9}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-http-router-jersey3-jakarta9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE9}"
def actualJavaxActivationVersion = "${javaxActivationVersionEE9}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-http-security-jersey3-jakarta10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE10}"
def actualJaxRsVersion = "${jaxRsVersionEE10}"
Expand Down
7 changes: 7 additions & 0 deletions servicetalk-http-security-jersey3-jakarta9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ tasks.sourcesJar.dependsOn(copySourcesForJersey3)
tasks.compileJava.dependsOn(copySourcesForJersey3)
tasks.processTestResources.dependsOn(copySourcesForJersey3)
tasks.compileTestJava.dependsOn(copySourcesForJersey3)
afterEvaluate {
if (tasks.findByName("projectHealth")) {
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
dependsOn(copySourcesForJersey3)
}
}
}

def actualJerseyVersion = "${jersey3VersionEE9}"
def actualJaxRsVersion = "${jaxRsVersionEE9}"
Expand Down

0 comments on commit 167012a

Please sign in to comment.