2016-07-26 158 views
1

我有一個單個模塊的gradle項目。爲什麼Gradle沒有在IntelliJ 2016的sourceSets下正確應用依賴範圍?

我已經宣佈了「設置」的配置,以使在父build.gradle文件中提供範圍的依賴關係:

subprojects { 
    apply plugin: 'maven' 
    apply plugin: 'java' 
    apply plugin: 'idea' 

    configurations { 
     provided 
    } 

    idea { 
     module { 
      scopes.PROVIDED.plus += [configurations.provided] 
     } 
    } 

    sourceSets { 
     main.compileClasspath += configurations.provided 
     test.compileClasspath += configurations.provided 
     test.runtimeClasspath += configurations.provided 
    } 

    ... other stuff... 
} 

build.gradle我已經宣佈以下相關的模塊:

dependencies { 
    testCompile 'org.elasticsearch:elasticsearch:2.3.1:tests' 
    compile 'org.apache.commons:commons-io:1.3.2' 
    compile 'org.apache.commons:commons-lang3:3.4' 
    compile 'org.elasticsearch:elasticsearch:2.3.1' 
    compile 'org.slf4j:slf4j-api:1.7.12' 
    provided 'org.slf4j:slf4j-simple:1.7.12' 
} 

當我擴展了Gradle工具窗口,它也聲明瞭第二個到最後一個依賴關係,即使它具有編譯範圍:

Screen shot of Gradle tool window

我希望看到的依賴列出(Compile)旁邊這個工具窗口,而不是(Provided)

所以問題是:爲什麼我不是?

是否因爲提供了slf4j(slf4j-simple)的實現,並且依賴於slf4j-api,因此也自動提供了該提供者?我如何阻止?我應該阻止它嗎?我想API作爲一個編譯的依賴項,但我想要項目,使用它來決定自己的實現...

回答

0

我有與IntelliJ IDEA Ultimate版本163.12024.16非常相同的問題。我無法修復它。但是當我升級到171.4249.39時,它神奇地消失了。 (再次使用之前的版本時,示波器會再次返回錯誤的「提供」)。

相關問題