我希望 IntelliJ IDEA 将我的库作为“编译”范围而不是“提供”范围。这是我的 gradle 文件的一部分:
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
// Logging
compile 'ch.qos.logback:logback-classic:1.2.1'
compile 'com.getsentry.raven:raven-logback:7.8.2'
// BigQuery
compile 'com.google.api-client:google-api-client:1.20.0'
compile 'com.google.apis:google-api-services-bigquery:v2-rev227-1.20.0'
// Configuration management
compile 'commons-configuration:commons-configuration:1.10'
//Json
compile 'org.json:json:20160810'
//Kafka
compile "org.apache.kafka:kafka-clients:0.10.1.1"
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'org.assertj:assertj-core:3.0.0'
testCompile 'org.mockito:mockito-all:1.10.19'
}
task wrapper(type: Wrapper) {
gradleVersion = '3.4'
}
范围总是在依赖选项卡中恢复为“提供”,这非常烦人:
我正在运行: IntelliJ IDEA 2016.3.4 构建 #IC-163.12024.16,构建于 2017 年 1 月 31 日 JRE: 1.8.0_112-release-408-b6 x86_64
最佳答案
这是 IntelliJ IDEA 中特定于 Gradle 3.4 的已知问题:
- IDEA-167412 Gradle 3.4-rc-1 将编译依赖更改为提供
- original bug report in the Gradle project with more details
- comment from the responsible developer关于“每个源集创建模块”选项以及 Gradle 集成在 IntelliJ IDEA 中的工作方式
它已在 2017.1 EAP build 中修复.
在 IDEA 2017.1 发布之前,您可以使用 Gradle 3.3 或更早版本作为解决方法。
关于java - 为什么 intelliJ IDEA 依赖范围是 "provided"而不是 "compile"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42443310/