Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6623053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:29:13+00:00 2026-05-25T21:29:13+00:00

Disclaimer (I originally asked the question in a very detailed manner over here .

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:29:14+00:00Added an answer on May 25, 2026 at 9:29 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer This question is a repost. I originally asked it here . While there
Disclaimer : I already asked this question , but without the deployment requirement. I
Disclaimer: The author of the question has an average knowledge of Erlang and a
Disclaimer: this question is driven by my personal curiosity more than an actual need
Disclaimer: I am using ExtJS 3, but I don't think it's very relevant to
Disclaimer: This question is not about fixing visual studio So, I've used VSS for
Disclaimer This is not strictly a programming question, but most programmers soon or later
Disclaimer When I wrote this question I was wrong about the behavior of the
Disclaimer: this question is purely informational and does not represent an actual problem I'm
Disclaimer: The author of this post has only theoretical and almost no practical knowledge

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.