Repository navigation
Move off the Maven API deprecated since Maven 3 - #358
Open
Irasha-Senarathna wants to merge 2 commits into
Open
Irasha-Senarathna wants to merge 2 commits into
Irasha-Senarathna wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #357
getDirectDependencies()called the deprecatedMavenProject.getDependencyArtifacts()inAggregateProcessRemoteResourcesMojo(listed in the issue) and inProcessRemoteResourcesMojo(not listed, same problem). It is only used whenexcludeTransitive=true.Both mojos now take
project.getArtifacts()and keep the artifacts whose dependency trail has two entries. Maven core starts the trail with the project and ends it with the artifact, so two entries means a direct dependency. Both mojos declarerequiresDependencyResolution = TEST, so the artifacts and their trails are always set.The aggregate mojo filters each reactor project before it merges them. An artifact can be direct in one module and transitive in another. The two artifacts are equal, so only one survives the merge, and it can be the transitive one.
Test changes:
excludeTransitive. I added one test forprocessand one foraggregate, and wrote them before the change. They pass on the old and the new code and fail withexcludeTransitive=false. The aggregate test also fails if the mojo merges before it filters.stub/ArtifactStubimplementedArtifact, which forced the deprecatedArtifactMetadataandArtifactRepositorytypes into the tests. It is replaced withDefaultArtifactand deleted.testProjectsDoesNotMutateProjectArtifactVersionsnow uses a timestamped snapshot (1.0-20260926.120000-1). With plain1.0-SNAPSHOT, the base version is the same as the version, so the test would not catch the getProjects() mutates the project's resolved Artifact versions (side effect) #268 regression. I checked that it still fails with that bug reintroduced.MavenProjectBasicStubno longer calls the deprecatedsetDependencyArtifacts,setReportArtifactsorsetExtensionArtifacts.No parameters or behavior change.
Still deprecated, in tests only: Maven 3.9 has no non-deprecated
MavenSessionconstructor. The new aggregate test uses the same constructor as the existingtestGetProjectsBuildsOnlyExternalArtifacts. I can switch both tests to a Mockito mock if you prefer, but that needs a declaredmockito-coretest dependency.mvn -Prun-its verifyon JDK 21 with Maven 3.10.2 passes: 59 unit tests, 12 failsafe ITs and 7 invoker ITs. CI covers Maven 4.To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following: