liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
200 stars 60 forks source link

Cannot invoke method get() on null object #119

Open lfgcampos opened 1 year ago

lfgcampos commented 1 year ago

I believe this is more of a usage question rather than a bug.

I have my project configured using Kotlin DSL. But for some internal reasons, I need to configure my own gradle task, which is pretty common.

An extract of my code look like this:

import org.liquibase.gradle.LiquibaseTask
import org.liquibase.gradle.liquibase.command.RollbackCountCommand

plugins {
    id("org.liquibase.gradle") version "2.2.0"
}

// ...

dependencies {
    // liquibase properties
    liquibaseRuntime("org.liquibase:liquibase-core:4.20.0")
    liquibaseRuntime("org.postgresql:postgresql:42.5.1")
    liquibaseRuntime("info.picocli:picocli:4.6.1")
}

// ...

tasks.register<LiquibaseTask>("rollbackChangeSet") {
    group = "liquibase-internal"
    liquibaseCommand = RollbackCountCommand()
    liquibase {
        activities.register("runRollback") {
            this.arguments = mapOf(
                    "changeLogFile" to dbMasterChangelog,
                    "url" to databaseUrl,
                    "username" to databaseUser,
                    "password" to databasePass,
                    "driver" to databaseDriver,
                    "logLevel" to "INFO",
                    "count" to 1
            )
        }
        runList = "runRollback"
    }
}

// ...

When I run it, I get the error mentioned:

Cannot invoke method get() on null object

It happens here suggesting that the liquibaseVersionProvider was not created properly, meaning the overrode configure wasn't called for the task.

I've tried to find ways to call it myself, hook it into some sort of gradle task lifecycle and other things without luck.

The same task used to work with previous version of liquibase and the plugin.

Can it be a bug? Am I doing something wrong here? Any help is appreciated.

stevesaliman commented 3 months ago

Version 3.0.0 of the plugin was released this morning, and it completely overhauls the way Liquibase tasks are created and configured. Is this still an issue with the latest version?

lfgcampos commented 3 months ago

Version 3.0.0 of the plugin was released this morning, and it completely overhauls the way Liquibase tasks are created and configured. Is this still an issue with the latest version?

Thanks for the heads up! Let me play with the new version during the week and get back to you on this =)