Maven install uploadArchvies pom does not dependencies from configuration extension

(Sridharan Kuppa) #1

I have multi module project. The parent project has defined list of configuration library. Each child module will be extending specific configuration instead of defining the dependencies again. When we execute the gradle task, install or uploadArchives, the generated pom does not have dependencies from configuration extension but it has dependencies from compile section. Example is given below.

repositories {
  group = 'com.test'
version = '0.0.3'
  apply plugin: 'java'
apply plugin: 'maven'
  configurations {
   compile.extendsFrom springLib
  dependencies {
  springLib "org.springframework:spring-core:3.2.2.RELEASE"
    compile "org.slf4j:slf4j-api:1.6.6"

The generate pom is

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="" xmlns=""

The generated pom has “slf4j” library in the dependency list but not the “spring-core”.

Is there any mistake in my gradle script? Is a known problem? If this is working as expected then why does gradle doing like this and how do I solve it.

Thanks, -Sridharan

(Peter Niederwieser) #2

The behavior is expected. Parent configurations won’t be considered when mapping configurations to scopes (doing so wouldn’t work for ‘compile’ and ‘runtime’, for example). I recommend to change the way you share common dependencies, but I’d have to know/see more about your current solution to give concrete recommendations.

(Sridharan Kuppa) #3

There are lot of shared libraries defined and there are about 100+ sub project sharing them. It will be harder to define dependencies in each sub project. Is there any way to resolve this problem?


(Peter Niederwieser) #4

The usual way to deal with this is to declare an extra property in the parent build script that holds a map containing all the dependency information. Then subprojects can make use of this information in their ‘dependencies’ block. For example:


ext.libraries = [
    junit: "junit:junit:4.11",
    spring: [
    // for advanced cases you can use dependencies.create(...) on RHS


dependencies {
    compile libraries.spring
    testCompile libraries.junit

With this solution, you don’t need additional configurations, and you don’t need to do extra work to have the correct POMs generated.

(Sridharan Kuppa) #5

Hi Peter,

Thank you very much. You made my day.

I like this solution for two reason.

  1. It is easier to read than defining custom configuration name and assinging values. 2. Dependencies are declared in dependencies section

I appreciate your quick help.