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

dependencies.dependency.version for testcontainers is missing #16

Open
shelajev opened this issue Mar 7, 2023 · 1 comment
Open

dependencies.dependency.version for testcontainers is missing #16

shelajev opened this issue Mar 7, 2023 · 1 comment
Assignees

Comments

@shelajev
Copy link

shelajev commented Mar 7, 2023

I'm trying springboot-testresources on a Spring Boot Petclinic app, and I think I followed the instructions properly, but when i try to build it, or run the individual test from my IDE (PetClinicIntegrationTests), then it fails with the following error:

> Task :internalStartTestResourcesService
Errors occurred while build effective model from /Users/shelajev/.gradle/caches/modules-2/files-2.1/io.cloudflight.testresources.springboot/springboot-testresources-jdbc-postgres/0.2.0/133bd2af448e4f364498b889a8d5e6847e3881a9/springboot-testresources-jdbc-postgres-0.2.0.pom:
        'dependencies.dependency.version' for org.testcontainers:postgresql:jar is missing. in io.cloudflight.testresources.springboot:springboot-testresources-jdbc-postgres:0.2.0
Errors occurred while build effective model from /Users/shelajev/.gradle/caches/modules-2/files-2.1/io.cloudflight.testresources.springboot/springboot-testresources-jdbc/0.2.0/fe2291622201c55906afb3fc811c7dc5450fcc3a/springboot-testresources-jdbc-0.2.0.pom:
        'dependencies.dependency.version' for org.testcontainers:jdbc:jar is missing. in io.cloudflight.testresources.springboot:springboot-testresources-jdbc:0.2.0

Do you know what can I try to resolve? I added Testcontainers BOM to explicitly provide the versions, but it doesn't seem to help.

The project if you want to try it is here: Github repo

@klu2 klu2 self-assigned this Mar 29, 2023
@klu2
Copy link
Contributor

klu2 commented Mar 29, 2023

Hey, sorry for the late reply, I missed your ticket.

Your issue seems to be related with the Spring Dependency Plugin, see spring-gradle-plugins/dependency-management-plugin#319, and r2dbc/r2dbc-bom#44

Unfortunately I couldn't fix it using this plugin, but I found a probable even better approach without the plugin at all. If you change your build.gradle to the following:

plugins {
  id 'org.springframework.boot' version '3.0.1'
  id 'java'
  id("io.micronaut.test-resources") version "3.6.7"
}

apply plugin: 'java'

group = 'org.springframework.samples'
version = '3.0.0'
sourceCompatibility = '17'

repositories {
  mavenCentral()
}

ext.webjarsFontawesomeVersion = "4.7.0"
ext.webjarsBootstrapVersion = "5.1.3"
ext.springBootVersion = "3.0.1"

dependencies {
    implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
    developmentOnly platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")

    implementation 'org.springframework.boot:spring-boot-starter-cache'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'javax.cache:cache-api'
    implementation 'jakarta.xml.bind:jakarta.xml.bind-api'
    runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator'
    runtimeOnly "org.webjars.npm:bootstrap:${webjarsBootstrapVersion}"
    runtimeOnly "org.webjars.npm:font-awesome:${webjarsFontawesomeVersion}"
    runtimeOnly 'com.github.ben-manes.caffeine:caffeine'
    runtimeOnly 'com.mysql:mysql-connector-j'
    runtimeOnly 'org.postgresql:postgresql'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    testRuntimeOnly("io.cloudflight.testresources.springboot:springboot-testresources-client:0.2.0")
    testResourcesImplementation ("io.cloudflight.testresources.springboot:springboot-testresources-jdbc-postgres:0.2.0")
    testImplementation "org.testcontainers:postgresql"
}

tasks.named('test') {
  useJUnitPlatform()
}

Then you're participating in Gradle's native platform functionality and dependency resolution works fine.

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

No branches or pull requests

2 participants