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

Handle import scope dependencies in dependencyManagement (multiple goals) (Fixes multiple issues #308, #309, #346, #395) #476

Closed
wants to merge 7 commits into from

Conversation

frode-carlsen
Copy link

@frode-carlsen frode-carlsen commented Aug 2, 2021

Fixes #308, Fixes #309, Fixes #346, Fixes #395 for following goals

  • use-dep-version
  • use-latest-versions
  • use-latest-snapshots
  • use-latest-release
  • use-next-releases
  • use-next-versions
  • use-next-snapshots

@frode-carlsen frode-carlsen changed the title Handle import scope dependencies in dependencyManagement (multiple goals) Fixes #346, #395: Handle import scope dependencies in dependencyManagement (multiple goals) Aug 5, 2021
@frode-carlsen frode-carlsen changed the title Fixes #346, #395: Handle import scope dependencies in dependencyManagement (multiple goals) Fixes #346, Fixes #395: Handle import scope dependencies in dependencyManagement (multiple goals) Aug 5, 2021
@frode-carlsen frode-carlsen changed the title Fixes #346, Fixes #395: Handle import scope dependencies in dependencyManagement (multiple goals) Handle import scope dependencies in dependencyManagement (multiple goals) (Fixes multiple issues #308, #309, #346, #395) Sep 3, 2021
Copy link
Member

@mfriedenhagen mfriedenhagen left a comment

Choose a reason for hiding this comment

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

Hi @frode-carlson,

first of all, thanks for this contribution.
I have added remarks about formatting and it looks like you introduced tabs at a few places if I am not mistaken (before comment // handle normally declared dependencies). And the blank lines before // handle import dependencies specially
It would be mighty helpful if you included an invoker test as well which checks at least some of your changes.

frode-carlsen and others added 4 commits September 10, 2021 07:54
Fix tab issue

Co-authored-by: Mirko Friedenhagen <mfriedenhagen@gmx.de>
@frode-carlsen
Copy link
Author

@mfriedenhagen added test case and applied fixes for tabs

@frode-carlsen
Copy link
Author

frode-carlsen commented Oct 7, 2021

@mfriedenhagen @hboutemy can anyone please review this again?

@nicktindall
Copy link

This would be really handy

@adpriebe
Copy link

Is there any chance of this PR getting merged? The documentation is very clear that the dependencyManagement section is processed by default, and therefore it is surprising that something like mvn versions:use-latest-releases does not also update import scoped dependencies in dependencyManagement to the latest release versions.

@andrzejj0
Copy link
Contributor

It doesn't? Yesterday I checked it and it did update those. I did check that with maven 3.2.5 as well as 3.6.3.

Could you please share a test scenario where it doesn't update those dependencies? By that I understand a test pom.xml, not just a maven command line.

@adpriebe
Copy link

adpriebe commented Nov 12, 2022

Hi @ajarmoniuk thanks for your fast response! Here is a contrived pom.xml that reproduces the issue:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>11</java.version>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-dependencies</artifactId>
				<version>2.7.0</version> <!-- old version -->
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
	</dependencies>
</project>

I have tested the above with both Maven 3.6.0 and 3.8.6 using command mvn versions:use-latest-releases -Dincludes=org.springframework.boot:spring-boot-dependencies. The command succeeds without updating anything.

I would also note that the following pom.xml and command mvn versions:update-properties -Dincludes=org.springframework.boot:spring-boot-dependencies works as expected, with the spring.version property being updated:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>11</java.version>
                <spring.version>2.7.0</spring.version> <!-- old version -->
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-dependencies</artifactId>
				<version>${spring.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
	</dependencies>
</project>

@andrzejj0
Copy link
Contributor

Indeed, I was able to reproduce the issue using your POMs. Thank you. I will now update all mojos to include the fix for this issue.

@andrzejj0
Copy link
Contributor

andrzejj0 commented Nov 13, 2022

For some reason, I wasn't able to create a test using a bom in the it-repo repository, even if I copied the Spring Boot BOM there. Neither did using org.codehaus.mojo:mojo-parent reproduce the problem. In both cases, the BOM was present in project.dependencyManagement.dependencies. Howver, org.apache.maven:maven-parent does work.

Copy link

This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Nov 14, 2023
@github-actions github-actions bot closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants