IntelliJ IDEA может разрешать зависимости, но Gradle не может - PullRequest
0 голосов
/ 19 июня 2019

У меня проблемы со сборкой оболочки Gradle. Моя IntelliJ IDEA способна разрешать зависимости, а Gradle - нет.

У меня есть проект Gradle, структурированный как показано ниже:

service
  |__app-service (Spring Boot Application)
  |__lib
     |__common (Spring Boot Library Modules)

Версия Gradle: 5.4.1

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_212 (Oracle Corporation 25.212-b03)
OS:           Linux 4.15.0-52-generic amd64

сервис / settings.gradle

rootProject.name = "projekt"

include 'lib:common'
include 'app-service'

сервис / приложение-сервис / build.gradle app-service скомпилируйте :lib:common, объявив compile project(':lib:common') зависимостью

buildscript {
    repositories {
        mavenCentral()
    }
}

plugins {
    id 'org.springframework.boot' version '2.1.5.RELEASE'
    id 'java'
    id 'war'
}

apply plugin: 'io.spring.dependency-management'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

test {
    useJUnitPlatform()
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
    }
    compile('org.springframework.boot:spring-boot-starter-jetty')

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    compile project(':lib:common')
    testCompile('org.springframework.boot:spring-boot-starter-test') {
        exclude module: 'junit', group: 'junit'
    }
    testCompile "org.assertj:assertj-core:$assertjCoreVersion"
    testCompile "org.mockito:mockito-all:$mockitoAllVersion"

    testCompileOnly 'org.projectlombok:lombok'
    testAnnotationProcessor('org.projectlombok:lombok')

    testImplementation 'org.junit.jupiter:junit-jupiter-api'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}

сервис / Библиотека / общий / build.gradle

buildscript {
    ext {
        junitPlatformVersion = '1.5.0-M1'
    }
}

plugins {
    id("org.springframework.boot") version '2.1.4.RELEASE'
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'io.spring.dependency-management'

jar {
    version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

test {
    useJUnitPlatform()
}

bootJar { enabled = false }

dependencies {
    compile 'org.springframework.boot:spring-boot-starter'
    compile 'org.springframework.boot:spring-boot-starter-web'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    testCompile('org.springframework.boot:spring-boot-starter-test') {
        exclude module: 'junit'
    }
    testCompile 'org.springframework.boot:spring-boot-test-autoconfigure'
    testCompile 'org.assertj:assertj-core'

    testCompileOnly 'org.projectlombok:lombok'
    testAnnotationProcessor('org.projectlombok:lombok')

    testCompile('org.junit.jupiter:junit-jupiter-api')
    testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine')
}

В IntelliJ IDEA account-service может разрешать все классы lib:common, а ./gradlew build - нет.

Например:

  symbol:   class UserId
  location: class UserRepositoryImpl
..../UserRepositoryImpl.java:28: error: cannot find symbol
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...