【问题标题】:IntelliJ does not pick up compileOnly dependencies from gradleIntelliJ 不会从 gradle 中获取 compileOnly 依赖项
【发布时间】:2017-12-23 18:41:00
【问题描述】:

以下是我的 IDEA 插件设置,它似乎没有获取我声明为 compileOnly 的任何依赖项。在运行./gradlew clean cleanIdea idea 后,它们都显示为丢失。

gradle 版本:3.2.1 IntelliJ 版本:2017.1.3 社区版

idea {
    module {
        inheritOutputDirs = false
        outputDir = file("$buildDir/classes/main/")
        testSourceDirs += file("src/test/java")
    }

    project {
        languageLevel = "1.8"
        jdkName = "1.8"
    }
}

【问题讨论】:

标签: java intellij-idea gradle build.gradle gradle-plugin


【解决方案1】:

使用最新版本(Gradle 4.1 和 IntelliJ IDEA 2017.2.1),compileOnly 依赖项被拾取并放入 IDEA 提供的范围内。

【讨论】:

    【解决方案2】:

    您必须使用compileOnly 范围声明依赖项。

    在多项目中,可以这样引用配置:

    
    dependencies {
    
        /**
         * compileOnly here is for Idea, run with deps.
         */
        compileOnly project(':djobi-core')
    
        compileOnly project(path: ':djobi-core', configuration: "spark")
        compileOnly project(path: ':djobi-core', configuration: "sparkAssemblyProvided")
        compileOnly project(path: ':djobi-core', configuration: "djobiCore")
    ....
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-01
      • 2015-02-25
      • 1970-01-01
      • 2016-06-19
      • 2020-10-25
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      相关资源
      最近更新 更多