Maven says I have a cyclic reference in multi-module project but can't figure out why - maven

I have a multi-module project that looks like this:
module1
pom.xml
module2
pom.xml
pom.xml
The pom.xml in module2 has a dependency on module1.
When I run mvn clean compile I get the following error:
The projects in the reactor contain a cyclic reference.
Here are my dependencies in module1:
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.48</version>
</dependency>
</dependencies>
I can't figure out why it says there is a cyclic reference. Even when I do mvn dependency:tree on module1 I get the following:
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- com.jcraft:jsch:jar:0.1.48:compile
[INFO] \- junit:junit:jar:4.8.2:test
It looks to me like there aren't any references to module2 in module1. So where is the cyclic reference coming from?
Edit: Here is the log with debug on:
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_31
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --> com.myorg:module2 --> com.myorg:module1
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --> com.myorg:module2 --> com.myorg:module1
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:295)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: hidden.org.codehaus.plexus.util.dag.CycleDetectedException: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --> com.myorg:module2 --> com.myorg:module1
at hidden.org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:143)
at hidden.org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:123)
at org.apache.maven.project.ProjectSorter.<init>(ProjectSorter.java:118)
at org.apache.maven.execution.ReactorManager.<init>(ReactorManager.java:99)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:288)
... 11 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Jul 05 17:21:21 EDT 2012
[INFO] Final Memory: 3M/244M
[INFO] ------------------------------------------------------------------------

Ah! It was a misleading error.
The problem wasn't that there both module1 and module2 depended on each other. The problem was that module2 is a Maven plugin and in my root pom.xml I had the plugin in the section. I removed that plugin from the build and it started working.

It happened to me in this circumstances.
The module_child_X was specified 2 times at module_root pom.xml:
- As a module
(pom.xml of the root module)
<dependency>
<groupId>module_root</groupId>
<artifactId>module_child_X</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
- As a dependency
(pom.xml of the root module)
<modules>
<module>module_child_X</module>
...
</modules>
Solution?
Removed the module_child_X as a dependency. It is already specified as a module.

I do nearly the same, and I use IDEA.
I have a project A, which depends on a module B.
In the pom file of A, B was declared as a dependency. This is OK.
In the pom file of B, A was declared as its parent. I removed this information, and as it was requested in the error message I added the version number of B in its pom file.
And now it is OK.

I had exactly the same issue in a multimodule ear project. The ejb pom had a dependency on the web module (compile scope) and the web pom a dependency on the ejb module. As soon as i removed the ejb's pom dependency on the web module, the project build fine.
It makes sense that the intramodule dependencies must be unidirectional after all, in order to avoid cyclic references.

Related

Using maven quarkus:dev target, why would I get an unresolved dep on com.fasterxml.jackson.annotation

A colleague posted a quarkus project to our internal git. When I cloned the repo, and did 'mvn compile quarkus:dev', I get:
$ mvn compile quarkus:dev
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.fnorb.api:rest-cloudpoc >------------------
[INFO] Building rest-cloudpoc 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # rest-cloudpoc ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # rest-cloudpoc ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 30 source files to C:\Bitbucket\INT\java-rest-cloudpoc\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Bitbucket/INT/java-rest-cloudpoc/src/main/java/com/fnorb/api/rest/cloudpoc/beans/DeriveTemplate.java:[4,40] package com.fasterxml.jackson.annotation does not exist
The "fasterxml.jackson.annotation" line is repeated N times, capped at 100.
There are also instances of
[ERROR] /C:/Bitbucket/INT/java-rest-cloudpoc/src/main/java/com/fnorb/api/rest/cloudpoc/beans/ObjectType.java:[18,2] cannot find symbol
symbol: class JsonInclude
The dep tree shows:
[INFO] +- io.quarkus:quarkus-resteasy:jar:1.4.2.Final:compile
[INFO] | +- io.quarkus:quarkus-vertx-http:jar:1.4.2.Final:compile
....
[INFO] | | +- io.quarkus:quarkus-vertx-core:jar:1.4.2.Final:compile
[INFO] | | | +- io.quarkus:quarkus-netty:jar:1.4.2.Final:compile
....
[INFO] | | | \- io.vertx:vertx-core:jar:3.8.5:compile
....
[INFO] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.10.3:compile
Is this just a misconfiguration of my host systems? Tried on Win10 and Ubuntu 18.04 headless (Linux subsystem for Windows) and Ubuntu 18.04.4 LTS native.
Technology evidenced above (ie, like 'beans') of which I have added no commentary, assume I have no knowledge of that particular technology. If you think this is related to the problem -- great! but will need hand-holding if you need me to do something with them. Don't just say "huh beans. You need to frog blast the vent core, the reticulator dependency hasn't been frinosticated yet" because I will just nod, rub my chin, shrug and try very hard not to tsk you. Thanky.
Please tell me I missed a step someplace!
Edit 1: Request for POM dependencies
<version>0.1</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.4.2.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.4.2.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
And request for imports in the imports from one of the relevant files:
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
No, no, your hosts are not misconfigured. Maven projects normally work out-of-the-box if they themselves are set up right.
First of all, the com.fasterxml.jackson.annotation package is not in the jackson-core dependency but instead in the jackson-annotations package.
If you're using Quarkus, you'll get the jackson-annotations dependency indirectly if you're using for example quarkus-smallrye-openapi. But to me it seems like the class DeriveTemplate in your project imports something from com.fasterxml.jackson.annotation, so the jackson-annotations should be declared as dependency directly in your pom.xml.
If this doesn't help you, you should post your pom.xml as well as the imports section of DeriveTemplate here.
Hope, I didn't vent the frog capacitor too much ;-)
Most likely, the missing dependency will look like:
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-annotations<artifactId>
<version>${your-desired-jackson-version}</version>
</dependency>

How to update or replace dependencies from other library in Maven probject?

My project is using another library commons-collection, which I have no control of. I run the command:
mvn dependency:tree -Dverbose -Dincludes=commons-collections
Verbose not supported since maven-dependency-plugin 3.0
[INFO] com.jde.jnlu:jnlu-qe-web:war:1.0.0-SNAPSHOT
[INFO] \- com.jde.jimi3.data:jd-jimi3-data-sdk:jar:3.0-SNAPSHOT:compile
[INFO] \- com.jde.jmq:jmq-client-spring:jar:2.1.2:compile
[INFO] \- com.jde.jmq:jmq-client-core:jar:2.1.2:compile
[INFO] \- com.jde.jmq:jmq-client-json:jar:1.2.9:compile
[INFO] \- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] \- commons-collections:commons-
collections:jar:3.2.1:compile
As it can been seen, the "commons-collections" is introduced by jd-jimi3-data-sdk which I can't update. But I was reminded of the current version of "commons-collection" has a potential security issue and needs to be upgraded. How can I achieve that in my project?
In your project, if you declare an explicit dependency on the version of commons-collection that you want, Maven will use that instead. See Maven documentation: Resolving conflicts using the dependency tree.
If you want to be really sure, you can also (in addition to the above) exclude commons-collection from your jd-jimi3-data-sdk dependency. Something like:
<project>
...
<dependencies>
<dependency>
<groupId>com.jde.jimi3.data</groupId>
<artifactId>jd-jimi3-data-sdk</artifactId>
<version>3.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
This is also covered in the Maven documentation: Dependency Exclusions.
Warning: Since the library you are using - jd-jimi3-data-sdk - was not written with this version of commons-collections, and allegedly not tested with it, this may break you project!

HttpSession class not found

I am building a project using groovy on grails 2.3.7. Rather that using the default grails plugins I want to configure the plugins as maven dependencies.
I also want to use jetty server instead of tomcat server and mongodb instead of the regular relational databases.
After creating the project I executed 'grails create-pom' to create the pom.xml file for the project.
I have added the following changes to the pom.xml.
Removed the dependency for hibernate and added the following dependency for mongodb
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>mongodb</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
Removed the default plugin for tomcat and added the following plugin for jetty.
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>jetty</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
I have also configured the repository for grails plugins.
While executing the code I get the following error.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.mycompany:grails-mongodb-demo:grails-app:0.1
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. # line 200, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building grails-mongodb-demo 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # grails-mongodb-demo ---
[INFO] Deleting /mnt/data/Work/Tutorials/Practice/grails/grails-mongodb-demo/target
[INFO] Deleting /mnt/data/Work/Tutorials/Practice/grails/grails-mongodb-demo/plugins (includes = [**/*], excludes = [])
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:clean (default-clean) # grails-mongodb-demo ---
[WARNING] Grails Start with out fork
|Loading Grails 2.3.7
|Configuring classpath
|Running pre-compiled script
.
|Environment set to development
....................
|Application cleaned.
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:validate (default-validate) # grails-mongodb-demo ---
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:init (default-init) # grails-mongodb-demo ---
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:config-directories (default-config-directories) # grails-mongodb-demo ---
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:maven-compile (default-maven-compile) # grails-mongodb-demo ---
[WARNING] Grails Start with out fork
|Loading Grails 2.3.7
|Configuring classpath
|Running pre-compiled script
..........
|Compiling 12 source files
.Error
|
Fatal error during compilation org.apache.tools.ant.BuildException: java.lang.NoClassDefFoundError: javax/servlet/http/HttpSession (Use --stacktrace to see the full trace)
Can anyone please tell me, what plugin I am missing or is there some thing I have configured incorrectly.
Add this to you pom.xml and see if it helps:-
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>

Maven Could not resolve dependencies for hadoop project

I wanted to build the sample projects from hadoop book but I got "Could not resolve dependencies error".
Here is my Error during build:
[INFO] Building Chapter 2: MapReduce 3.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.hadoop:hadoop-core:jar:0.23.10 is missing, no dependency information available
[WARNING] The POM for org.apache.hadoop:hadoop-test:jar:0.23.10 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Chapter 2: MapReduce .............................. FAILURE [1.409s]
[INFO] Hadoop: The Definitive Guide, Example Code ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.819s
[INFO] Finished at: Wed May 14 12:19:14 EEST 2014
[INFO] Final Memory: 6M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ch02: Could not resolve dependencies for project com.hadoopbook:ch02:jar:3.0: The following artifacts could not be resolved: org.apache.hadoop:hadoop-core:jar:0.23.10, org.apache.hadoop:hadoop-test:jar:0.23.10: Failure to find org.apache.hadoop:hadoop-core:jar:0.23.10 in https://repository.apache.org/content/repositories/releases/ was cached in the local repository, resolution will not be reattempted until the update interval of apache.releases has elapsed or updates are forced -> [Help 1]
and here is my pom.xml for ch02 project
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.hadoopbook</groupId>
<artifactId>hadoop-meta</artifactId>
<version>3.0</version>
<relativePath>../hadoop-meta/pom.xml</relativePath>
</parent>
<groupId>com.hadoopbook</groupId>
<artifactId>ch02</artifactId>
<packaging>jar</packaging>
<version>3.0</version>
<name>Chapter 2: MapReduce</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</dependency>
</dependencies>
</project>
Any idea how can I build this code using maven and what the problem is ?
Thanks
What's happening is that Maven can't find the what it is looking for in the remote repository. So when it reaches out to Apache's Maven repository it's just not finding the resources for version 0.23.10 hadoop-test.
Particularly line #8 of the pom file in the question <relativePath>../hadoop-meta/pom.xml</relativePath> is directing Maven to look at hadoop-meta/pom.xml. On line #48 through #50 you'll see the specification for the hadoop-test repository:
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>${hadoop.version}</version>
That ${hadoop.version} is the value that you specify in your maven command, ie 0.23.10.
So then maven goes out to the Apache repo and looks for hadoop-test v0.23.10, which isn't present. So then Maven falls over.
Now if you used a version that is present in the hadoop-test, or if you altered the pom files so that hadoop-test isn't a dependency.
I had this problem as well, it turned out it was because of NetBeans adding something to my pom.xml file. Double check nothing was added since previous successful deployments.

Maven dependency resolution and scope overriding

Disclaimer
(I originally asked the question in a very detailed manner over here. I've excerpted it here as the maven-users mailing list has gone quiet on this question.) (not just another newbie question)
Reference
My reference material is
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management; please let me know in this discussion if this is outdated or wrong.
Question
There is a section in that document that begins with "A second, and very important...". In what follows I'll refer to that section's projects A and B, and will excerpt from them.
In that section, you will see that project A has a <dependencyManagement> section that--among other things--defines an artifact, c, as having scope compile:
<!-- In A's pom.xml; condensed for brevity -->
<dependencyManagement>
<dependency>
<groupId>test</groupId>
<artifactId>c</artifactId>
<version>1.0</version>
<scope>compile</scope> <!-- look: compile scope -->
</dependency>
</dependencyManagement>
Then you will see a pom.xml for project B that (a) inherits from project A (thus inheriting its dependencyManagement section) and (b) establishes a dependency on artifact c, without having to specify its version. You will also notice that the dependency on artifact c overrides the scope of c to be runtime, not compile:
<!-- In B's pom.xml, whose parent is A's pom.xml (above); condensed for brevity -->
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>c</artifactId>
<scope>runtime</scope> <!-- look: runtime scope -->
</dependency>
</dependencies>
Again, you'll note that there is no <version> element, but there is a <scope>runtime</scope> element.
My interpretation of this is that when all is said and done, B will depend on version 1.0 of artifact c in runtime scope, not compile scope.
Is that correct? My maven-ear-plugin bug rests on the fact that this is the expected behavior. It is not what happens when the maven-ear-plugin builds an .ear file.
Next, if that's correct, I would also expect that if artifact c had any transitive runtime dependencies they would be available in B's runtime classpath (as defined by the somewhat baffling table in http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope).
Is that correct?
Running mvn dependency:tree on the sample project posted in the bug link specified above,
[INFO] Building MEAR-143 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143 ---
[INFO] ljnelson:mear-143:pom:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:4.8.2:test
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MEAR-143 Leaf 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143-leaf ---
[INFO] ljnelson:mear-143-leaf:jar:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:4.8.2:test
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MEAR-143 Middle 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143-middle ---
[INFO] ljnelson:mear-143-middle:jar:1.0-SNAPSHOT
[INFO] +- ljnelson:mear-143-leaf:jar:1.0-SNAPSHOT:runtime
[INFO] \- junit:junit:jar:4.8.2:test
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MEAR-143 EAR 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143-ear ---
[INFO] ljnelson:mear-143-ear:ear:1.0-SNAPSHOT
[INFO] +- ljnelson:mear-143-middle:jar:1.0-SNAPSHOT:runtime
[INFO] | \- ljnelson:mear-143-leaf:jar:1.0-SNAPSHOT:test (scope managed from ru
ntime)
[INFO] \- junit:junit:jar:4.8.2:test
The dependency scope of mear-143-leaf in mear-143-middle, where the dependency is explicitly defined is indeed runtime, overriding the test scope defined in the dependencyManagement section of parent pom, mear-143.
In mear-143-ear, mear-143-leaf gets included transitively. Here the test scope defined in dependencyManagement of mear-143 takes precedence over the inherited runtime scope.
This, I guess is in line with what is specified in the second bullet point in the section you have referred above. Quoting it here and highlighting in bold and italics the relevant parts:
b is defined in B's parent's dependency management section and since
dependency management takes precedence over dependency mediation for
transitive dependencies, version 1.0 will be selected should it be
referenced in a or c's pom. b will also have compile scope
The selected answer is good enough to clarify the key point that whether dependencyManagement takes precedence relies on whether the child dependency is declared explicitly or transitively.
As a plus, I just created a summary concerned with version & scope resolution to kill this problem totally:
Assuming that a dependency A is declared eight times in different ways, and each with a different version... which version will win last?
just remember the three rules in the picture:
explicit declaration > dependency-management declaration > implicit transitive declaration
1st declaration > 2nd declaration
child declaration > parent declaration
and you will figure out the priority sequence shown as red numbered list in the picture.

Resources