Skip to content

Migrate from maven-dependency-tree to direct use of Resolver API#749

Open
flowerlake wants to merge 11 commits intojenkinsci:masterfrom
flowerlake:migrate-to-Resolver-Api
Open

Migrate from maven-dependency-tree to direct use of Resolver API#749
flowerlake wants to merge 11 commits intojenkinsci:masterfrom
flowerlake:migrate-to-Resolver-Api

Conversation

@flowerlake
Copy link

@flowerlake flowerlake commented Jun 20, 2025

Fixes #511

Testing done

I'm working on migrating the maven-dependency-tree to use Resolver Api. After searching through the repository globally, I identified two class files that involve API calls to this dependency - AssembleDependenciesMojo and AbstractDependencyGraphTraversingMojo.

I'd be very happy if my contribution proves useful to the project.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@flowerlake flowerlake changed the title Migrate from maven-dependency-tree to direct use of Resolver API #511 Migrate from maven-dependency-tree to direct use of Resolver API Jun 20, 2025
@flowerlake flowerlake closed this Jun 20, 2025
@flowerlake flowerlake reopened this Jun 20, 2025
@flowerlake
Copy link
Author

@basil please take a look

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Looks about right at face value. Does it work?

@flowerlake
Copy link
Author

flowerlake commented Jun 22, 2025

Yes, it works good. I've successfully tested the builds for both jira-plugin and saml-plugin on the current fix branch. All are working as expected.

hpi3.66-rc1725.30105a_a_2f65d are from CI-PR-749
jira-hpi-3.65.log
jira_hpi3.66-rc1725.30105a_a_2f65d.log
saml-plugin_hpi3.65.log
saml-plugin_hpi3.66-rc1725.30105a_a_2f65d.log

@basil
Copy link
Member

basil commented Jun 22, 2025

Do those logs show that the code changed in this PR was executed?

@flowerlake
Copy link
Author

flowerlake commented Jun 23, 2025

I have performed additional testing with the command: mvn hpi:assemble-dependencies.Through testing verification of the Jenkins Jira plugin, I compared the execution behavior between two versions of the maven-hpi-plugin (stable release 3.65 and PR version 3.66-rc1725.30105a_a_2f65d). The test results confirm that both versions exhibit identical behavior during the assemble-dependencies phase. The log below confirms that the code changed in this PR was executed.

image

jira-hpi-assemble-dependencies-3.65.log
jira-hpi-assemble-dependencies-3.66-rc1725.30105a_a_2f65d.log

@flowerlake
Copy link
Author

Hi, @basil any other questions?

@basil basil requested a review from Copilot August 4, 2025 21:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the codebase from using the maven-dependency-tree library to the direct use of the Resolver API for dependency graph traversal. This change modernizes the dependency resolution approach by leveraging Eclipse Aether's more direct API instead of the Maven-specific wrapper.

Key changes:

  • Replace maven-dependency-tree with Eclipse Aether Resolver API
  • Update method signatures to include root node tracking
  • Refactor dependency graph building logic to use native Aether components

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pom.xml Removes the maven-dependency-tree dependency
AbstractDependencyGraphTraversingMojo.java Replaces maven-dependency-tree with Aether Resolver API and adds root node tracking
AssembleDependenciesMojo.java Updates method signature and adapts to new Aether-based dependency handling

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

This PR is changing existing behavior, seemingly unintentionally. Before this PR, running the Mojo in workflow-job I get:

"ionicons-api" -> {MavenArtifact@4715} "io.jenkins.plugins:ionicons-api:jar:74.v93d5eb_813d5f"
"caffeine-api" -> {MavenArtifact@4717} "io.jenkins.plugins:caffeine-api:jar:3.1.8-133.v17b_1ff2e0599"
"workflow-support" -> {MavenArtifact@4719} "org.jenkins-ci.plugins.workflow:workflow-support:jar:944.v5a_859593b_98a_"
"workflow-step-api" -> {MavenArtifact@4721} "org.jenkins-ci.plugins.workflow:workflow-step-api:jar:686.v603d058a_e148"
"workflow-api" -> {MavenArtifact@4723} "org.jenkins-ci.plugins.workflow:workflow-api:jar:1363.v03f731255494"
"workflow-job" -> {MavenArtifact@4725} "org.jenkins-ci.plugins.workflow:workflow-job:hpi:999999-SNAPSHOT"

After this PR, I get

"ionicons-api" -> {MavenArtifact@4981} "io.jenkins.plugins:ionicons-api:jar:74.v93d5eb_813d5f"
"structs" -> {MavenArtifact@4983} "org.jenkins-ci.plugins:structs:jar:338.v848422169819"
"asm-api" -> {MavenArtifact@4985} "io.jenkins.plugins:asm-api:jar:9.7.1-97.v4cc844130d97"
"caffeine-api" -> {MavenArtifact@4987} "io.jenkins.plugins:caffeine-api:jar:3.1.8-133.v17b_1ff2e0599"
"scm-api" -> {MavenArtifact@4989} "org.jenkins-ci.plugins:scm-api:jar:703.v72ff4b_259600"
"script-security" -> {MavenArtifact@4998} "org.jenkins-ci.plugins:script-security:jar:1369.v9b_98a_4e95b_2d"
"workflow-support" -> {MavenArtifact@4991} "org.jenkins-ci.plugins.workflow:workflow-support:jar:944.v5a_859593b_98a_"
"workflow-step-api" -> {MavenArtifact@4993} "org.jenkins-ci.plugins.workflow:workflow-step-api:jar:686.v603d058a_e148"
"workflow-api" -> {MavenArtifact@4996} "org.jenkins-ci.plugins.workflow:workflow-api:jar:1363.v03f731255494"
"workflow-job" -> {MavenArtifact@4927} "org.jenkins-ci.plugins.workflow:workflow-job:hpi:999999-SNAPSHOT"

@flowerlake flowerlake closed this Nov 29, 2025
@flowerlake flowerlake reopened this Nov 29, 2025
@flowerlake
Copy link
Author

This PR is changing existing behavior, seemingly unintentionally. Before this PR, running the Mojo in workflow-job I get:

"ionicons-api" -> {MavenArtifact@4715} "io.jenkins.plugins:ionicons-api:jar:74.v93d5eb_813d5f"
"caffeine-api" -> {MavenArtifact@4717} "io.jenkins.plugins:caffeine-api:jar:3.1.8-133.v17b_1ff2e0599"
"workflow-support" -> {MavenArtifact@4719} "org.jenkins-ci.plugins.workflow:workflow-support:jar:944.v5a_859593b_98a_"
"workflow-step-api" -> {MavenArtifact@4721} "org.jenkins-ci.plugins.workflow:workflow-step-api:jar:686.v603d058a_e148"
"workflow-api" -> {MavenArtifact@4723} "org.jenkins-ci.plugins.workflow:workflow-api:jar:1363.v03f731255494"
"workflow-job" -> {MavenArtifact@4725} "org.jenkins-ci.plugins.workflow:workflow-job:hpi:999999-SNAPSHOT"

After this PR, I get

"ionicons-api" -> {MavenArtifact@4981} "io.jenkins.plugins:ionicons-api:jar:74.v93d5eb_813d5f"
"structs" -> {MavenArtifact@4983} "org.jenkins-ci.plugins:structs:jar:338.v848422169819"
"asm-api" -> {MavenArtifact@4985} "io.jenkins.plugins:asm-api:jar:9.7.1-97.v4cc844130d97"
"caffeine-api" -> {MavenArtifact@4987} "io.jenkins.plugins:caffeine-api:jar:3.1.8-133.v17b_1ff2e0599"
"scm-api" -> {MavenArtifact@4989} "org.jenkins-ci.plugins:scm-api:jar:703.v72ff4b_259600"
"script-security" -> {MavenArtifact@4998} "org.jenkins-ci.plugins:script-security:jar:1369.v9b_98a_4e95b_2d"
"workflow-support" -> {MavenArtifact@4991} "org.jenkins-ci.plugins.workflow:workflow-support:jar:944.v5a_859593b_98a_"
"workflow-step-api" -> {MavenArtifact@4993} "org.jenkins-ci.plugins.workflow:workflow-step-api:jar:686.v603d058a_e148"
"workflow-api" -> {MavenArtifact@4996} "org.jenkins-ci.plugins.workflow:workflow-api:jar:1363.v03f731255494"
"workflow-job" -> {MavenArtifact@4927} "org.jenkins-ci.plugins.workflow:workflow-job:hpi:999999-SNAPSHOT"

I fixed this to maintain consistency with the previous behavior, the inconsistency is due to the incorrect use of the setRoot method.

@flowerlake
Copy link
Author

@basil Also close #781 , as that PR made the same mistake.

@flowerlake flowerlake requested a review from basil December 24, 2025 10:46
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.

Migrate from maven-dependency-tree to direct use of Resolver API

2 participants