Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong configuration assigned to dependency 'org.moduliths:moduliths-core' when used with the dependency-management-plugin #296

Closed
odiolog opened this issue Feb 16, 2021 · 4 comments

Comments

@odiolog
Copy link

odiolog commented Feb 16, 2021

I cannot use 'org.moduliths:moduliths-core' dependency together with 'io.spring.dependency-management'. When resolving the dependencies, io.spring.gradle.dependencymanagement.internal.DependencyManagementContainer seems to assign it to a wrong configuration:

2021-02-16T23:16:37.717+0700 [DEBUG] [io.spring.gradle.dependencymanagement.internal.VersionConfiguringAction] Processing dependency 'org.moduliths:moduliths-core:1.1.0-M1'
2021-02-16T23:16:37.717+0700 [DEBUG] [io.spring.gradle.dependencymanagement.internal.DependencyManagementContainer] Found managed version '1.1.0-M1' for dependency 'org.moduliths:moduliths-core' in dependency management for configuration 'compileProtoPath'

The problem can be reproduced with this build.gradle:

plugins {
    id 'org.springframework.boot' version '2.5.0-M1'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'com.google.protobuf' version '0.8.14'
    id 'java'
}

group = 'com.odiolog'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '15'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/milestone' }
    maven { url 'https://repo.spring.io/libs-snapshot' }
    maven { url 'https://repo.maven.apache.org/maven2/' }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    implementation 'org.moduliths:moduliths-core:1.1.0-M1'
    implementation group: 'org.moduliths', name: 'moduliths-test', version: '1.1.0-M1'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation group: 'org.foundationdb', name: 'fdb-record-layer-core-pb3', version: '2.8.110.0'
    compile 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
}

test {
    useJUnitPlatform()
}

protobuf {
    generatedFilesBaseDir = "${projectDir}/src/main/generated"
    protoc {
        artifact = 'com.google.protobuf:protoc:3.6.1'
    }
}

sourceSets {
    main {
        java {
            srcDir 'src/main/generated/main/java'
        }
    }
}
@wilkinsona
Copy link
Contributor

The output looks to be correct to me as the compileProtoPath configuration extends from the implementation configuration. Beyond the debug output, what's the problem that you're seeing?

@odiolog
Copy link
Author

odiolog commented Feb 16, 2021

The dependency 'org.moduliths' is not accessible from the project i.e. not visible in the External Libraries. In fact, it is as if the moduliths library was not there at all.

If I look at the gradle output, for another dependency spring-boot-starter-web, which is also in implementation configuration, it is assigned to 'global dependency management'. Why the difference?

2021-02-17T00:03:47.348+0700 [DEBUG] [io.spring.gradle.dependencymanagement.internal.VersionConfiguringAction] Processing dependency 'org.springframework.boot:spring-boot-starter-web:'
2021-02-17T00:03:47.348+0700 [DEBUG] [io.spring.gradle.dependencymanagement.internal.DependencyManagementContainer] Found managed version '2.5.0-M1' for dependency 'org.springframework.boot:spring-boot-starter-web' in global dependency management

@wilkinsona
Copy link
Contributor

There's a difference as the dependency management is coming from two different sources.

The dependency management for spring-boot-starter-web comes from the import of Spring Boot's spring-boot-dependencies bom that's done implicitly when you apply both Spring Boot's plugin and the dependency management plugin. The dependency management for org.moduliths:moduliths-core is inferred from the declaration of the dependency in the implementation configuration which is then inherited by the compileProtoPath configuration.

The dependency 'org.moduliths' is not accessible from the project i.e. not visible in the External Libraries. In fact, it is as if the moduliths library was not there at all.

I've just imported into Eclipse a project that uses your build.gradle above and a settings.gradle to make milestone plugins available. Project and External Dependencies contains three moduliths jars:

  • moduliths-api
  • moduliths-core
  • moduliths-test

This is what I'd expect. It aligns with the output from ./gradlew dependencies:

+--- org.moduliths:moduliths-core:1.1.0-M1
|    +--- org.moduliths:moduliths-api:1.1.0-M1
|    +--- com.tngtech.archunit:archunit:0.14.1
|    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    \--- org.springframework:spring-core:5.2.11.RELEASE -> 5.3.3 (*)
+--- org.moduliths:moduliths-test:1.1.0-M1
|    +--- org.moduliths:moduliths-core:1.1.0-M1 (*)
|    +--- org.springframework.boot:spring-boot-test-autoconfigure:2.3.6.RELEASE -> 2.5.0-M1
|    |    +--- org.springframework.boot:spring-boot:2.5.0-M1 (*)
|    |    +--- org.springframework.boot:spring-boot-test:2.5.0-M1
|    |    |    \--- org.springframework.boot:spring-boot:2.5.0-M1 (*)
|    |    \--- org.springframework.boot:spring-boot-autoconfigure:2.5.0-M1 (*)
|    +--- org.springframework:spring-test:5.2.11.RELEASE -> 5.3.3
|    |    \--- org.springframework:spring-core:5.3.3 (*)
|    \--- org.assertj:assertj-core:3.16.1 -> 3.18.1

@odiolog
Copy link
Author

odiolog commented Feb 17, 2021

I replaced org.moduliths:moduliths-core:1.1.0-M1 dependency with an slightly older one but with a different organisation: de.olivergierke.moduliths:moduliths-core:1.0.0-SNAPSHOT and everything works. So it seems the problem is coming from the new library version published maven artifact itself or in my way of handling things somehow.

I will look into the difference in the poms to see if there is anything they missed, but the problem is definitely not coming from the dependency-management-plugin.

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants