Gradle:找不到编译项目提供的类(':sth')

时间:2018-06-09 03:47:23

标签: gradle dependency-management

我在项目io.dengchao.generic.server.util.IdWorker和项目common app中创建了一个名为compile project(':common')的类。

root build.gradle:

group 'generic-server'
version '1.0.0-dev'

buildscript {
    repositories {
        maven { url = "http://maven.aliyun.com/nexus/content/groups/public" }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE")
    }
}

subprojects { project ->
    println(project.name)

    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8

    repositories {
        maven { url = "http://maven.aliyun.com/nexus/content/groups/public" }
        jcenter()
        mavenCentral()
    }
}

root settings.gradle:

rootProject.name = 'generic-server'
include 'app', 'common'

common build.gradle:

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'
    testImplementation("org.springframework.boot:spring-boot-starter-test")

    compile 'org.jetbrains:annotations:15.0'
    compile("org.springframework.boot:spring-boot-starter-data-rest")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-boot-starter-aop")
    compile("org.springframework.boot:spring-boot-starter-security")
    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
    compileOnly "org.springframework.boot:spring-boot-configuration-processor"
    annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

    compile 'mysql:mysql-connector-java'
}

compileJava.dependsOn(processResources)
//bootJar.dependsOn(test)

app build.gradle:

bootJar {
    baseName = 'generic-server'
    version = '1.0'
}

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    // http://blog.csdn.net/wm5920/article/details/76566095
    // https://mvnrepository.com/artifact/com.googlecode.log4jdbc/log4jdbc
    testImplementation 'com.googlecode.log4jdbc:log4jdbc:1.2'

    compile project(':common')
}

和构建错误的屏幕截图: Execution failed for task ':app:compileJava'

gradle wrapper:'4.6-all'和'4.8-all'都试过。

0 个答案:

没有答案