Gradle 多模块项目无法解析依赖子模块的类

Mic*_*ner 6 groovy dependencies gradle multi-module

该应用程序在 Eclipse 中运行良好。但我无法通过 gradle ( gradle clean build)构建应用程序

结构如下:

financial-calculator(家长)

  • library
  • api

api想要使用的类library

我父母的settings.gradle档案:

rootProject.name = 'financial-calculator'

include 'library'
include 'api'  

rootProject.children.each { it.name = rootProject.name + '-' + it.name }
Run Code Online (Sandbox Code Playgroud)

build.gradle文件:

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'
    }
}
Run Code Online (Sandbox Code Playgroud)

您可以在链接下找到完整的小项目

感谢您的提示。