运行Liquibase 4和Gradle 8导致错误无法找到参数的方法getMain()[]

xfyts7mz  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(145)

我正在使用Liquibase 4和Gradle 8设置Sping Boot 3项目,无论我尝试在build.gradle中配置Liquibase,在运行任何Liquibase Gradle脚本时,我总是得到以下错误:

> Task :update FAILED
liquibase-plugin: Running the 'main' activity...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':update'.
> Could not find method getMain() for arguments [] on task ':update' of type org.liquibase.gradle.LiquibaseTask.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 1s
1 actionable task: 1 executed

我的build.gradle.kts如下:

plugins {
    id("java")
    id("org.springframework.boot") version "3.1.2"
    id("org.liquibase.gradle") version "2.0.4"
}

group = "com.example"

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

configurations {
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

liquibase {
    activities.register("main") {
        this.arguments = mapOf(
                "changelogFile" to "src/test/resources/db/changelog/db.changelog-master.yaml",
                "classpath" to "src/test/resources",
                "url" to "jdbc:postgresql://localhost:5432/test",
                "username" to "gpadmin",
                "password" to "gpadmin",
                "driver" to "org.postgresql.Driver",
        )
    }
    runList = "main"
}

configurations.configureEach {
    exclude(group = "org.springframework.boot", module = "spring-boot-starter-json")
    exclude(group = "com.sun.xml.bind")
}

repositories {
    mavenLocal()
    mavenCentral()
}

val springBootVersion = "3.1.2"
val springCloudVersion = "2022.0.3"
val springCloudStarterVersion = "4.0.3"
val pivotalSpringCloudServicesVersion = "4.0.3"
val springCloudContractVersion = "4.0.3"
val springdocVersion = "2.1.0"
val restAssuredVersion = "5.3.1"
val rdf4jVersion = "3.7.7"
val lombokVersion = "1.18.28"

dependencies {
    // Spring boot dependencies
    implementation("org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}")
    implementation("org.springframework.boot:spring-boot-starter-data-r2dbc:${springBootVersion}")
    implementation("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")

    // Database / service related dependencies
    implementation("org.postgresql:r2dbc-postgresql:1.0.2.RELEASE")
    runtimeOnly("org.postgresql:postgresql:42.6.0")

    // Other dependencies
    implementation("org.springdoc:springdoc-openapi-starter-webflux-ui:${springdocVersion}")
    implementation("com.google.guava:guava:32.1.1-jre")
    implementation("org.eclipse.rdf4j:rdf4j-model:${rdf4jVersion}")

    // Lombok
    compileOnly("org.projectlombok:lombok:${lombokVersion}")
    annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
    testCompileOnly("org.projectlombok:lombok:${lombokVersion}")
    testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}")

    // Test Dependencies
    testImplementation("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
    testImplementation("org.springframework.security:spring-security-test:6.1.1")
    testImplementation("org.springframework.cloud:spring-cloud-starter-contract-verifier:${springCloudContractVersion}")
    testImplementation("io.rest-assured:spring-web-test-client:${restAssuredVersion}")
    testImplementation("io.rest-assured:rest-assured-common:${restAssuredVersion}")
    testImplementation("io.projectreactor:reactor-test:3.5.8")

    // Dependencies required for running liquibase for tests
    liquibaseRuntime("org.liquibase:liquibase-core:4.23.0")
    liquibaseRuntime("info.picocli:picocli:4.7.4")
    liquibaseRuntime("org.liquibase.ext:liquibase-hibernate5:4.22.0")
}

tasks.withType<JavaCompile>().configureEach {
    options.encoding = "UTF-8"
    options.compilerArgs.addAll(listOf("-Xlint:unchecked", "-Xlint:deprecation"))
}

tasks.named<Test>("test") {
    useJUnitPlatform()
}

如果有人能告诉我我做错了什么导致了这个错误,我将非常感激。对于我的生活,我在网上找不到任何关于这方面的信息。
我已经创建了一个GitHub存储库,可以在其中重现这个问题:https://github.com/favna/congenial-fishstick/tree/liquibase-issue。请注意,您 checkout 这个liquibase-issue分支,因为我正在重用早期版本中的同一个存储库。

bbuxkriu

bbuxkriu1#

我可以再把它关上。真的,我不知道到底发生了什么,因为我已经面临这个问题几天了,但刚才我更新了Gradle插件从2.0.4到2.2.0,这似乎已经修复了它。问题是,我100%确定我以前有v2.2.0,尽管当时我的build.gradle仍然使用Groovy语法,所以Liquibase配置是一种非常不同的方式。
从现在开始,我仍然会使用build.gradle.kts,我很高兴这个问题得到了解决。
我已经添加了一个提交到GitHub存储库的最终更改。

相关问题