Gradle Multimodule Project unable to resolve class of depending sub module
Asked Answered
M

0

6

The application works fine in Eclipse. But I am not able to build the application via gradle (gradle clean build)

The structure is like:

financial-calculator (parent)

  • library
  • api

api wants to use classes of library

My parent's settings.gradle file:

rootProject.name = 'financial-calculator'

include 'library'
include 'api'  

rootProject.children.each { it.name = rootProject.name + '-' + it.name }

The parent build.gradle file:

buildscript {
    ext {
        springBootVersion = '2.0.3.RELEASE'
    }
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath "o.s.b:spring-boot-gradle-plugin:${springBootVersion}"
    }
}

allprojects {
    apply plugin: 'eclipse'
    apply plugin: 'maven'
    apply plugin: 'maven-publish'

    group = 'net.hemisoft.financial.calculator'
    version = "0.1.0-SNAPSHOT"
}

subprojects {
    apply plugin: 'groovy'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = JavaVersion.VERSION_1_8

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        compile 'o.c.g:groovy'
        testCompile 'o.s.b:spring-boot-starter-test'
    }

    dependencyManagement {
        imports { mavenBom("o.s.b:spring-boot-dependencies:${springBootVersion}") }
    }
}

project(rootProject.name + '-library') {
    dependencies {
        compile 'o.s.b:spring-boot-starter'
    }
}

project(rootProject.name + '-api') {
    dependencies {
        compile project (':' + rootProject.name + '-library')
        compile 'o.s.b:spring-boot-starter-web'
    }
}

The complete small project you will find under link

Thanks for your hints.

Maturate answered 21/7, 2018 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.