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

safely remove property version when removing dependency #9921

Conversation

renanfranca
Copy link
Contributor

Fix #6977

@renanfranca renanfranca self-assigned this May 27, 2024
@renanfranca renanfranca marked this pull request as draft May 27, 2024 12:24
@murdos murdos changed the title WIP:safety remove property version when removing dependency WIP:safely remove property version when removing dependency May 27, 2024
@renanfranca renanfranca force-pushed the 6977-maven-safety-remove-property-version-when-removing-dependency branch from fc5bab1 to ad82b67 Compare May 31, 2024 13:38
@renanfranca renanfranca changed the title WIP:safely remove property version when removing dependency safely remove property version when removing dependency May 31, 2024
@renanfranca renanfranca marked this pull request as ready for review May 31, 2024 17:50
@renanfranca renanfranca requested a review from murdos May 31, 2024 17:52
@renanfranca
Copy link
Contributor Author

.removeDependency(dependencyId(MOCKITO_GROUP, "mockito-junit-jupiter"))
does not remove <mockito.version>5.4.0</mockito.version> in pom.xml

See https://github.com/jhipster/jhipster-lite-sample-app/blob/0df81108ece4f8838e4236753e006000775b2fb5/pom.xml#L24C6-L24C21

@murdos : I generated a sampleapp with this pull request implementation and it removed the version property as expected 😃👍

Collection<JavaBuildCommand> versionCommands(
JavaDependenciesVersions currentVersions,
ProjectJavaDependencies projectDependencies,
Collection<JavaBuildCommand> dependencyCommands
Copy link
Contributor

Choose a reason for hiding this comment

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

If find that signature a bit strange... to generate version commands, you need other commands.
Out of curiosity, have you thought about an alternative?

…know the version used by the current dependencyId"
…ween removing a dependency and removing its version property.
…nt scopes, applied by different modules, should not remove the version property used by both
…DirectJavaDependency that use the version. This covers the new feature of removing unused version properties.

Scenario: update the only dependency that references an existing version property. As a result, the dependency and version property will be removed. When adding the updated dependency, the version will need to be added again.
…y and AddDirectJavaDependency to ensure the version is set, avoiding unintentional exclusion.
…use it is used by another dependency management
…y management with different scopes, applied by different modules, should not remove the version property used by both
…in dependency management referencing version property
…arameter

Replace Collection<JavaBuildCommand> dependencyCommands with Optional<BuildProfileId> buildProfile and the instance of JavaDependencyCommandsCreator, which is sufficient to retrieve the dependencyCommands
@renanfranca renanfranca force-pushed the 6977-maven-safety-remove-property-version-when-removing-dependency branch from a971a09 to 0fb6e2b Compare June 5, 2024 16:07
@renanfranca renanfranca force-pushed the 6977-maven-safety-remove-property-version-when-removing-dependency branch from f5ca681 to 81d67df Compare June 5, 2024 16:12
…ependency commands

Removed logic from JavaDependency.versionCommands. The logic to generate dependencyCommands is now handled in DirectJavaDependency.versionCommands and JavaDependencyManagement.versionCommands, avoiding code duplication
@renanfranca renanfranca requested a review from murdos June 5, 2024 17:35
@murdos murdos merged commit 7d09065 into jhipster:main Jun 5, 2024
34 checks passed
@murdos
Copy link
Contributor

murdos commented Jun 5, 2024

Thanks @renanfranca :)

@renanfranca renanfranca deleted the 6977-maven-safety-remove-property-version-when-removing-dependency branch June 5, 2024 20:35
@renanfranca
Copy link
Contributor Author

Thanks @renanfranca :)

You are welcome 😊 , thank you for the review!

I am going to create an issue to handle this on Gradle 👍

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

Successfully merging this pull request may close these issues.

Maven: removeDependency doesn't remove property for version
2 participants