2016-07-05 183 views
0

下面是我gradle這個構建腳本:春季啓動gradle插件messes常春藤依賴配置?

buildscript { 
    repositories { 
    jcenter() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE") 
    } 
} 
apply plugin: 'spring-boot' 
apply plugin: 'base' 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.12' 
} 

repositories { 
    ivy { 
    url 'my.url' 
    } 
} 

dependencies { 
    archives group: 'my.group', name: 'artifact.name', version: '16.06.29.5144', configuration: 'dist' 
} 

在這裏面我嘗試一個依賴添加到archives配置。這是依賴發佈到常春藤回購,它有幾個配置,其中一個dist配置。但它沒有default配置。現在

,如果我跑gradlew dependencies我得到以下錯誤:

Execution failed for task ':dependencies'. 
Could not resolve all dependencies for configuration 'detachedConfiguration4'. 
    > Module version :gtest:unspecified, configuration 'detachedConfiguration4' declares a dependency on configuration 'default' which is not declared in the module descriptor for my.group:artifact.name:16.06.29.5144 

當我刪除spring-boot插件,然後錯誤消失了,我看到預期的輸出:

archives - Configuration for archive artifacts. 
\--- my.group:artifact.name:16.06.29.5144 

任何想法,爲什麼spring-boot插件打破對自定義配置的依賴?

回答

1

您的自定義工件看起來是bug/limitation in Gradle的另一個觸發器。失敗的發生是由於Spring Boot的插件使用了一些邏輯dependency management plugin,除此之外,確保在依賴關係的poms中聲明的任何排除都按預期應用。

您可以解決這個問題,在有可能宣佈一些額外的排除,通過告訴依賴管理插件不適用的Maven排除語義成本:

dependencyManagement { 
    applyMavenExclusions false 
}