Which dependencyManagement is setting my dependency version? - maven

i have a pom that has a number of entries in its <dependencyManagement> section.
How can i figure out which dependencyManagement entry is managing the versions of my dependancies!?
To further clarify my question, sometimes it is obvious -
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>${spring-cloud-gcp.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
, would manage this verion:
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
</dependency>
</dependencies>
But what about dependencies that are declared (without a version) that dont match the groupId, etc.
Thanks

Related

Can a Maven BOM contain another Maven BOM?

Can a Maven BOM(BOM1) contain another BOM(BOM2) in its dependencyManagement? If yes, how could the usage of BOM1 through inclusion in a pom.xml can use the dependencies from BOM2 in a project? Thanks in advance!
To better explain the situation, the below works when i include both of the in the pom.xml of the service:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>my.custom.bom</groupId>
<artifactId>my.custom.bom</artifactId>
<version>${my.custom.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Whereas the following does notwhen I include it in the pom.xml of the service:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.custom.bom</groupId>
<artifactId>my.custom.bom</artifactId>
<version>${my.custom.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
And the my.custom.bom in the second situation includes the spring-boot-dependencies like so:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
To summarize when pom.xml includes BOM1 and BOM2 works, but when pom.xml includes BOM1 and BOM1 includes BOM2 no longer works.

What is the purpose of dependency management tag in pom.xml?

Can someone please explain what this dependency do under dependency management and after adding it why we don't need to mention version of our dependencies?
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
dependencyManagement makes them available, but you need to import them in every submodule you want them loaded into. Works as version control, and avoids a bloated project with all dependencies loaded in every module or child project.
dependencies loads them for every module or child who inherits them.

Why override org.webjars when using org.springframework.cloud dependency management?

Why override org.webjars when using org.springframework.cloud dependency ? there is any dependency vise versa? I am confused .
See below snippet:
In pom.xml file:
override dependencies:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>datatables</artifactId>
<version>1.10.19</version>
</dependency>
when i am using below dependency:
<project>
......
<!-- Some dependencies -->
.....
<dependencies>
......
.......
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
......
<!-- Some dependencies -->
.......
</project>
This post explained exact problem: Overriding managed version 3.2.0 for bootstrap when put <dependencyManagement>
Please help me.

Why including bom doesn't work?

I found something doesn't work that I expected to work.
I imported the org.glassfish.jersey:jersey-bom in my dependencyManagement section.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.26-b03</version>
<type>pom</type>
<scope>include</scope>
</dependency>
</dependencies>
</dependencyManagement>
That pom clearly includes following dependency.
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${project.version}</version>
</dependency>
Now I add my own dependency
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
And mvn complains.
'dependencies.dependency.version' for org.glassfish.jersey.core:jersey-common:jar is missing. # line 33, column 17
What's wrong with my pom?
Did you define project-version as a property? I guess not, since you're not using it to specify the version of your BOM.
Using the literal string, this should work:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.26-b03</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.26-b03</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
</dependency>
</dependencies>
What intrigues me is that you shouldn't need to specify org.glassfish.jersey.core:jersey-common:2.26-b03 in <dependencyManagement> since it is part of the BOM, but the dependency doesn't work if it is not there.

Where is Wildfly 9.0.2.Final BOM?

This builds:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-tools</artifactId>
<version>8.2.1.Final</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
But it doesn't:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-hibernate</artifactId>
<version>9.0.2.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Cannot find org.wildfly.bom:jboss-javaee-7.0-with-hibernate:9.0.2.Final.
Where can I find BOM for Wildfly 9.0.2.Final?
Or if it doesn't exist, why if Wildfly 9 isn't so new? We have WildFly 10 already!
There does not appear to be a version for 9.0.2.Final.
You should be able to use:
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-wildfly-with-hibernate3</artifactId>
<version>9.0.1.Final</version>
</dependency>
without any problems though.
The Central Repository Search Engine is your friend when trying to resolve these kinds of questions.

Resources