0
votes

I've a multiple module gradle project.

Root has the following modules : core, app (dependent on core), web(dependent on app,core)

From https://plugins.gradle.org/plugin/io.spring.dependency-management

I have used

 plugins {  id "io.spring.dependency-management" version "0.5.4.RELEASE" }

 dependencyManagement {
  imports { 
     mavenBom 'io.spring.platform:platform-bom:+' // 2.0.1.RELEASE
   }
  }

inside the build.gradle of core.

When I triggered

 gradle clean build

from root command prompt, core jar was built successfully, but app failed to resolve the versions of the dependencies.

common.gradle in root directory

repositories {
    mavenCentral()
    maven { url "http://repo.grails.org/grails/repo/" }
    // mavenLocal()
}

build.gradle of Core

plugins {
   id "io.spring.dependency-management" version "0.5.4.RELEASE"
}

apply from: '../common.gradle'
apply plugin: 'java'

dependencyManagement {
   imports {
    mavenBom 'io.spring.platform:platform-bom:+' // 2.0.1.RELEASE
    }
 }

dependencies {
  compile  'javax.jms:javax.jms-api:+' //2.0
  compile  'javax.mail:mail:+' //1.4.6
  compile  'javax.validation:validation-api' //1.0.0.GA
  compile  'org.springframework.security:spring-security-ldap' //4.0.1.RELEASE
  compile  'org.springframework.data:spring-data-jpa'  //1.9.1.RELEASE
  compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:+' //1.0.0.Final    
 }

build.gradle for app module

apply plugin: 'java'
apply from: '../common.gradle'
dependencies {
compile project(':Core')
compile 'org.hibernate:hibernate-validator' //5.1.1.Final
compile 'net.sf.ehcache:ehcache'   //2.9.1
compile 'org.springframework:spring-jms' //4.2.3.RELEASE
 compile 'org.springframework:spring-oxm' //3.0.4.RELEASE }

Error message snippet:

FAILURE: Build failed with an exception.

Environment :

D:\personal>gradle -v


Gradle 2.9

Build time: 2015-11-17 07:02:17 UTC Build number: none Revision: b463d7980c40d44c4657dc80025275b84a29e31f

Groovy: 2.4.4

Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013

JVM: 1.8.0_20 (Oracle Corporation 25.20-b23)

OS: Windows 7 6.1 amd64

1

1 Answers

1
votes

You should add the dependency management plugin to the app module. Right now it's only available in the core module, but you are trying to use it's features in the app module.
It's probably a good idea to apply the plugin to every module. If you want you can add this to your root build.gradle:

buildscript {
    repositories { mavenCentral() }
    dependencies { classpath "io.spring.gradle:dependency-management-plugin:0.5.4.RELEASE" }
}

allprojects {
    apply plugin: "io.spring.dependency-management"
}

Answer to the comment:
Artifacts require explicit version when they are not part of the platform-bom. You can declare your own dependencies and use them without explicit version:

dependencyManagement {
     dependencies {
          dependency 'org.springframework:spring-core:4.0.3.RELEASE'
          dependency group:'commons-logging', name:'commons-logging', version:'1.1.2'
     }
}

dependencies {
     compile 'org.springframework:spring-core'
}

source: plugin documentation