liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 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.