Skip to content

fix(locker): omit scope in locked deps#52

Merged
ia3andy merged 1 commit intomvnpm:mainfrom
frederikb:remove-scope-from-dependency-management
Feb 5, 2026
Merged

fix(locker): omit scope in locked deps#52
ia3andy merged 1 commit intomvnpm:mainfrom
frederikb:remove-scope-from-dependency-management

Conversation

@frederikb
Copy link
Contributor

Drop dependencyManagement entries for locked dependencies since they do not influence resolution and add noise.

Update ITs to assert that no scope is emitted in locker BOM and in-profile modes.

This will cause changes in the generated POM for all consumers who have specified for org.mvnpm and org.webjars dependencies.

Fixes #23


@ia3andy Did I understand your issue and reasoning correctly? That <scope> is transiently inherited anyway and thus specifying it in <dependencyManagement> is henceforth just noise?

I opted to simply adjust the existing ITs to ensure this behavior. One could of course explicitly check for the absence of <scope>, if you want.

for example via:

XmlAssert.assertThat(Files.readString(lockedPom))
    .withNamespaceContext([pom: "http://maven.apache.org/POM/4.0.0"])
    .as("check that dependency scopes are not added to the 'locker' dependencies")
    .doesNotHaveXPath("//pom:profile[normalize-space(pom:id)='locker']/pom:dependencyManagement/pom:dependencies/pom:dependency/pom:scope")

Drop dependencyManagement <scope> entries for locked dependencies since
they do not influence resolution and add noise.

Update ITs to assert that no scope is emitted in locker BOM and in-profile modes.

This will cause changes in the generated POM for all consumers who have specified <scope> for `org.mvnpm` and `org.webjars` dependencies.

Fixes mvnpm#23
Copy link
Contributor

@ia3andy ia3andy left a comment

Choose a reason for hiding this comment

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

Thanks!

<groupId>org.mvnpm</groupId>
<artifactId>lit</artifactId>
<version>3.1.2</version>
<scope>runtime</scope>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are they added and not removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are the original dependencies, not the "locked versions". Here, we must not change the defined scope as this is an explicit intent of the developer depending on how they will use the dependencies, i.e. served at runtime or transformed/bundled during build time.

I adjusted the original input pom.xml to therefore explicitly state <scope>s in order to showcase that with the applied template change we ensure that these scopes are not transferred to the definitions of the "locked versions" in the locker profile/POM <dependencyManagement> section.

Does that answer your question?

Copy link
Contributor

@ia3andy ia3andy left a comment

Choose a reason for hiding this comment

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

Cool thanks!

@ia3andy ia3andy merged commit 7af4db0 into mvnpm:main Feb 5, 2026
1 check passed
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.

Remove scope from the generated locker

2 participants