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 7585703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:14:25+00:00 2026-05-30T19:14:25+00:00

In Maven there is a very useful feature where you can define a dependency

  • 0

In Maven there is a very useful feature where you can define a dependency in the <dependencyManagement> section of the parent POM, and reference that dependency from child modules without specifying the version or scope or whatever.

What are the alternatives in Gradle?

  • 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-30T19:14:26+00:00Added an answer on May 30, 2026 at 7:14 pm

    You can declare common dependencies in a parent script:

    ext.libraries = [ // Groovy map literal
        spring_core: "org.springframework:spring-core:3.1",
        junit: "junit:junit:4.10"
    ]
    

    From a child script, you can then use the dependency declarations like so:

    dependencies {
        compile libraries.spring_core
        testCompile libraries.junit
    }
    

    To share dependency declarations with advanced configuration options, you can use DependencyHandler.create:

    libraries = [
        spring_core: dependencies.create("org.springframework:spring-core:3.1") {
            exclude module: "commons-logging"
            force = true
        }
    ]
    

    Multiple dependencies can be shared under the same name:

    libraries = [
        spring: [ // Groovy list literal
            "org.springframework:spring-core:3.1", 
            "org.springframework:spring-jdbc:3.1"
        ]
    ]
    

    dependencies { compile libraries.spring } will then add both dependencies at once.

    The one piece of information that you cannot share in this fashion is what configuration (scope in Maven terms) a dependency should be assigned to. However, from my experience it is better to be explicit about this anyway.

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

Sidebar

Related Questions

I am very new to Maven and running into a problem that I can't
Is there a Maven plugin that allows you to check if there are newer
Is there any to get the entire remote repository, say from http://repo1.maven.org/maven2/ , to
Is there a way to configure Jenkins to resume a (broken) Maven build from
Eclipse has a nice feature I'm using - check out maven projects from SCM
While using the maven-buildnumber-plugin 1.0 beta 4, it seems that I can get the
Spring Roo can be use in existing projects that follow standard maven layout .
Is there way to optionally compile dependency from source (svn) instead of using the
Is there a Maven phase or goal to simply execute the main method of
Is there a Maven alternative or port for the .NET world? I would love

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.