2016-05-11 24 views
9

Tôi đang gặp sự cố với sự phụ thuộc chuyển tiếp của plugin grails-flyway của tôi. org.grails.plugins:grails-flyway:0.2.1 tuyên bố phụ thuộc vào org.flywaydb:flyway-core:4.0.1. Khi tôi đưa plugin vào dự án Grails 3.1.6 của tôi Gradle hạ cấp Flyway xuống phiên bản 3.2.1.Tại sao Gradle hạ cấp phụ thuộc transitive của tôi trong ứng dụng Grails 3.1?

+--- org.grails.plugins:grails-flyway:0.2.1 
| \--- org.flywaydb:flyway-core:4.0.1 -> 3.2.1 

My Gradle xây dựng tập tin trông như thế này

buildscript { 
    ext { 
     grailsVersion = project.grailsVersion 
    } 
    repositories { 
     maven { url "https://repo.grails.org/grails/core" } 
    } 
    dependencies { 
     classpath "org.grails:grails-gradle-plugin:$grailsVersion" 
     classpath "com.bertramlabs.plugins:asset-pipeline-gradle:${assetPipelinePluginVersion}" 
     classpath "org.grails.plugins:hibernate5:5.0.5" 
     classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0' 
    } 
} 

version "0.40.15" 
group "zsc.supporter" 

apply plugin: "war" 
apply plugin: "org.grails.grails-web" 
apply plugin: "org.grails.grails-gsp" 
apply plugin: "org.grails.grails-doc" 
apply plugin: "asset-pipeline" 
apply plugin: 'com.github.ben-manes.versions' 

ext { 
    grailsVersion = project.grailsVersion 
    gradleWrapperVersion = project.gradleWrapperVersion 
} 

repositories { 
    maven { url "https://repo.grails.org/grails/core" } 
    maven { url "https://dl.bintray.com/saw303/plugins" } 
} 

dependencyManagement { 
    imports { 
     mavenBom "org.grails:grails-bom:$grailsVersion" 
    } 
    applyMavenExclusions false 
} 

dependencies { 
    compile "org.springframework.boot:spring-boot-starter-logging" 
    compile "org.springframework.boot:spring-boot-autoconfigure" 
    compile "org.grails:grails-core" 
    compile "org.springframework.boot:spring-boot-starter-actuator" 
    compile "org.springframework.boot:spring-boot-starter-tomcat" 
    compile "org.grails:grails-dependencies" 
    compile "org.grails:grails-web-boot" 
    compile "org.grails.plugins:cache" 
    compile "org.grails.plugins:scaffolding" 
    compile "org.grails.plugins:hibernate4" 
    compile "org.hibernate:hibernate-ehcache" 
    console "org.grails:grails-console" 
    profile "org.grails.profiles:web:3.1.6" 
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:${assetPipelinePluginVersion}" 
    runtime "com.h2database:h2" 
    testCompile "org.grails:grails-plugin-testing" 
    testCompile "org.grails.plugins:geb" 
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.52.0" 
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.21" 

    compile "org.grails.plugins:spring-security-core:3.0.4" 
    compile "org.grails.plugins:quartz:2.0.8" 
    compile "org.grails.plugins:mail:2.0.0.RC4" 
    compile "eu.bitwalker:UserAgentUtils:1.18" 
    compile 'org.mnode.ical4j:ical4j:1.0.7' 
    compile 'org.grails.plugins:browser-detection:3.1.0' 
    compile "com.googlecode.libphonenumber:libphonenumber:7.3.1" 
    runtime 'org.grails.plugins:grails-flyway:0.2.1' 

    testCompile "org.grails.plugins:grails-wizer:0.3" 
    testCompile 'org.grails:grails-datastore-test-support:5.0.5.RELEASE' 

    runtime 'mysql:mysql-connector-java:5.1.29' 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = gradleWrapperVersion 
} 

assets { 
    minifyJs = true 
    minifyCss = true 
} 

Hiện nay tôi không hiểu tại sao Gradle downgrades phụ thuộc bắc cầu của tôi. Ai đó có thể cung cấp về điều này?

Tôi biết rằng tôi có thể bắt buộc phụ thuộc flyway-core:4.0.1 trong số build.gradle của mình nhưng tôi muốn hiểu nguyên nhân hạ cấp.

CẬP NHẬT-1

Khi tôi chạy gradle dependencies | grep flyway tôi nhận được kết quả như sau.

+--- org.grails.plugins:grails-flyway:0.2.1 
| \--- org.flywaydb:flyway-core:4.0.1 -> 3.2.1 
+--- org.grails.plugins:grails-flyway:0.2.1 
| \--- org.flywaydb:flyway-core:4.0.1 -> 3.2.1 
+--- org.grails.plugins:grails-flyway:0.2.1 
| \--- org.flywaydb:flyway-core:4.0.1 -> 3.2.1 
+--- org.grails.plugins:grails-flyway:0.2.1 
| \--- org.flywaydb:flyway-core:4.0.1 -> 3.2.1 

Vui lòng tìm đầu ra hoàn chỉnh tại pastebin. Bạn có thể tìm thấy plugin grails-flyway và tệp pom.xml tại Bintray.

CẬP NHẬT-2

tôi đã cố gắng để buộc Gradle sử dụng org.flywaydb:flyway-core:4.0.1 theo Gradles Reference.

configurations.all { 
    resolutionStrategy.force 'org.flywaydb:flyway-core:4.0.1' 
} 

Điều đó không ảnh hưởng đến sự cố. Cây phụ thuộc vẫn sử dụng phiên bản 3.2.1 của flyway-core.

+--- org.grails.plugins:grails-flyway:0.2.1 
| \--- org.flywaydb:flyway-core:4.0.1 -> 3.2.1 

CẬP NHẬT-3

Gradles dependencyInsight lệnh

gradle dependencyInsight --dependency flyway-core --configuration runtime 

kết quả trong

:dependencyInsight 
org.flywaydb:flyway-core:3.2.1 (selected by rule) 

org.flywaydb:flyway-core:4.0.1 -> 3.2.1 
\--- org.grails.plugins:grails-flyway:0.2.1 
    \--- runtime 

gì có nghĩa (selected by rule)?

"Giải pháp" - hoặc làm thế nào để làm việc xung quanh nó

tôi đã không thể tìm ra quy tắc gây Gradle sử dụng flyway-core:3.2.1 thay vì flyway-core:4.0.1. Nhưng tôi đã tìm ra cách để giải quyết vấn đề.

Tôi đã thêm thông tin sau vào số build.gradle để sửa đổi chiến lược phân giải Gradle runtime của mình.

configurations.runtime.resolutionStrategy { 

    eachDependency { DependencyResolveDetails det -> 

     if (det.requested.name == 'flyway-core' && det.requested.group == 'org.flywaydb') { 
      det.useVersion(det.requested.version) 
     } 
    } 
} 
+0

Có bất kỳ sự phụ thuộc khác, đó là phụ thuộc vào 'org.flywaydb: đường bay lõi: 3.2.1 '? Cũng giống như giả sử, có một số lib, với sự phụ thuộc vào phiên bản cũ và Gradle chỉ giải quyết điều này bằng cách hạ cấp phiên bản của plugin, bởi vì nó dường như là cách rõ ràng nhất – Stanislav

+0

Tôi không thể tìm thấy bất kỳ phiên bản đường bay nào khác với cây phụ thuộc. :( – saw303

+0

Bạn có thể cố gắng đảo ngược tìm kiếm của mình bằng cách chạy './gradlew dependencyInsight - phụ thuộc vào đường bay-cốt lõi'. Sau đó, bạn sẽ có thể xem ai requieres flyway-core. – TobiSH

Trả lời

8

Điều làm cho nó là spring-boot-dependencies-1.3.3.RELEASE.pom

này buộc các phiên bản đường bay đến 3,2.1

Theo Spring Boot docs bạn sẽ có thể để thêm một dòng như thế này để bạn build.gradle: ext['flyway.version'] = '4.0.1'

Các vấn đề liên quan