Nikem Nikem - 5 months ago 28
Java Question

spring-boot gradle plugin messes ivy dependency configuration?

Below is my gradle build script:

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'
}


In it I try to add one dependency to
archives
configuration. This is dependency published into Ivy repo and it has several configuration, among them a
dist
configuration. But it does not have
default
configuration.

Now, if I run
gradlew dependencies
I get the following error:

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


When I remove
spring-boot
plugin, then error disappears and I see expected output:

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


Any ideas why
spring-boot
plugin breaks dependency on custom configuration?

Answer

Your custom artifact looks to be another trigger of a bug/limitation in Gradle. The failure's occurring due to some logic in the dependency management plugin that Spring Boot's plugin uses that, among other things, ensures that any exclusions declared in dependencies' poms are applied as intended.

You can work around the problem, at the cost of perhaps having to declare some additional exclusions, by telling the dependency management plugin not to apply Maven exclusion semantics:

dependencyManagement {
    applyMavenExclusions false
}