Skip to content
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

Add dependency-analysis-gradle-plugin #3158

Merged
merged 10 commits into from
Jan 3, 2025

Conversation

idelpivnitskiy
Copy link
Member

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.

More info: https://github.com/autonomousapps/dependency-analysis-gradle-plugin

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 dependency as part of our
`servicetalk-gradle-plugin-internal`;
- Apply it for libraries to enable `projectHealth` task;
- Apply it for root projects to enable `buildHealth` task that generates
full report in a file;
- Add `dependencyAnalysis` task and bundle it as part of `quality` task
to allow validation via CI pipelines;
- Make sure `copySourcesForJersey3` task always executes before
`dependencyAnalysis` as it depends on copied source code;

Result:

We can automatically detect issues with dependencies.
issues {
all {
onAny {
severity("warn") // FIXME: switch to "fail" when all issues are addressed
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change after all issues are resolved, will require a few follow-up PRs

@@ -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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried many different ways to avoid this duplication. Unfortunately, nothing worked without bringing more problems. My gradle-foo is exhausted at this point 😢

@idelpivnitskiy idelpivnitskiy merged commit 167012a into apple:main Jan 3, 2025
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the dependencyAnalysis branch January 3, 2025 22:07
Copy link
Contributor

@bryce-anderson bryce-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post merge 👍

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/out/our

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants