Cannot find class provide by compile project(':sth')


(XieEDeHeiShou) #1

( Asked today at Stack Overflow : https://stackoverflow.com/questions/50770721/gradle-cannot-find-class-provide-by-compile-projectsth )

I’ve created a class named as io.dengchao.generic.server.util.IdWorker in project common, and the project 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')
}

and screen-capture for build error:
Execution failed for task ':app:compileJava'

gradle wrapper: both ‘4.6-all’ and ‘4.8-all’ tried.


(XieEDeHeiShou) #2

Help~~ Does it means that I have to move all things from common to app to make a work-around ?