Git Product home page Git Product logo

Comments (10)

tomix26 avatar tomix26 commented on July 28, 2024

There are several ways to achieve that in Gradle.

  1. You can define a resolution strategy to check and change the version of transitive dependencies manualy:
configurations.all {
     resolutionStrategy.eachDependency { DependencyResolveDetails details ->
         if (details.requested.group == 'io.zonky.test.postgres') {
            details.useVersion '9.6.10'
        }
    }
}
  1. If you use Gradle 5+, Maven BOMs are supported out of the box, so you can import the bom:
dependencies {
     implementation enforcedPlatform('io.zonky.test.postgres:embedded-postgres-binaries-bom:9.6.10')
}
  1. Or, you can use Spring's dependency management plugin that provides Maven-like dependency management to Gradle:
plugins {
    id "io.spring.dependency-management" version "1.0.6.RELEASE"
}

dependencyManagement {
     imports {
          mavenBom 'io.zonky.test.postgres:embedded-postgres-binaries-bom:9.6.10'
     }
}

from embedded-database-spring-test.

tomix26 avatar tomix26 commented on July 28, 2024

Thanks for the question I will update the documentation. Let me know if it helped.

from embedded-database-spring-test.

Siegrift avatar Siegrift commented on July 28, 2024

I didn't try the first approach and unfortunately I am using gradle 4.9.

However the third approach works :) 👍
Thanks for your help :)

from embedded-database-spring-test.

tomix26 avatar tomix26 commented on July 28, 2024

Glad to hear that, thanks for the info.

from embedded-database-spring-test.

drej1 avatar drej1 commented on July 28, 2024

Hi @tomix26, I tried solution 1 and 3 but I get both 9.6.9 and 10.7.0 bineries into my dependencies in gradle and if I debug DefaultPostgresBinaryResolver it retrieved the 10.7.0 binary.
Could you please help?
I am using Gradle 4.10.

from embedded-database-spring-test.

tomix26 avatar tomix26 commented on July 28, 2024

Hi @drej1, could you please provide your build.gradle script?

from embedded-database-spring-test.

drej1 avatar drej1 commented on July 28, 2024

Hi @tomix26 ,

It's a multimodule project but I will try to add the relevant gradle files here:
root project: root_build.gradle
it includes: common.gradle
and there is a submodule which is dependency for other submodules: submodule_build.gradle
gradle_files.zip

from embedded-database-spring-test.

drej1 avatar drej1 commented on July 28, 2024

Hi @tomix26 any update for this? Thx

from embedded-database-spring-test.

tomix26 avatar tomix26 commented on July 28, 2024

I'm so sorry for the late response, this task is already closed, so I forgot about our previous conversation. I think the problem could be caused by the fact that you apply the plugin only to submodules. Try to move it directly into the root_build.gradle script and don't use the apply false syntax for this plugin.

Something like this:

buildscript {

    ext {
        // START for common.gradle
        swaggerCodegenVersion = "2.2.3"
        swaggerAnnotationsVersion = "1.5.21"
        springfoxSwaggerVersion = "2.9.2"
        mapstructMapperVersion = "1.3.0.Final"
        redissonVersion = "3.10.7"
        // END for common.gradle
    }

    repositories {
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        maven { url "http://repo.spring.io/plugins-release" }
        maven {
            url "http://nexus.services.itc.st.sk:8081/repository/maven-central/"
            credentials {
                username "service-hal"
                password "XXX"
            }
        }
    }

    dependencies {
        // START for common.gradle
        classpath("io.spring.gradle:propdeps-plugin:0.0.9.RELEASE") // provides additional optional and provided dependency configurations
        classpath("io.swagger:swagger-codegen:${swaggerCodegenVersion}")
        // END for common.gradle
    }

}

plugins {
    id "io.spring.dependency-management" version "1.0.6.RELEASE"

    // spring boot
    id "org.springframework.boot" version "2.1.5.RELEASE" apply false

    // lombok
    id "io.franzbecker.gradle-lombok" version "3.0.0" apply false

    // for annotation processors | gradle 5 should have native support for annotation processors, so this plugin might be removed from the project after gradle upgrade
    id "net.ltgt.apt" version "0.21" apply false
    id "net.ltgt.apt-idea" version "0.21" apply false

    // flyway gradle plugin
    // please keep this version in sync with spring boot defined ${flyway.version}
    // https://github.com/spring-projects/spring-boot/blob/v2.1.5.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml
    id "org.flywaydb.flyway" version "5.2.4" apply false

    // sonarqube
    id "org.sonarqube" version "2.7.1" apply false
}

dependencyManagement {
     imports {
          mavenBom 'io.zonky.test.postgres:embedded-postgres-binaries-bom:9.6.10'
     }
}

group "sk.telekom.oneapp.hal"
version "1.0-SNAPSHOT"

apply from:"./gradle-common/common.gradle"

from embedded-database-spring-test.

drej1 avatar drej1 commented on July 28, 2024

Hi @tomix26 , it didn't help, but I made some changes... I had to add
{code}
dependencyManagement {
imports {
mavenBom 'io.zonky.test.postgres:embedded-postgres-binaries-bom:9.6.10'
}
}
{code}
into the common.gradle into the subprojects {} closure... this way it was set in all subprojects using your library.

Thanks :)

from embedded-database-spring-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.