liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

Unable to load main class org.liquibase.gradle.OutputEnablingLiquibaseRunner #74

Closed niktekusho closed 4 years ago

niktekusho commented 4 years ago

Hi! This problem seems to be quite common as I read about other issues. Example: https://github.com/liquibase/liquibase-gradle-plugin/issues/52

Running any liquibase task with the specified 'mainClassName' property will result in the Could not find or load main class org.liquibase.gradle.OutputEnablingLiquibaseRunner. Just by commenting out the main class override, the plugin works fine.

The plugin is on the latest version (2.0.3), and Gradle is at 6.4.1.

This is the 'build.gradle' file (will link a sample repository you can try):

plugins {
    id 'org.liquibase.gradle' version '2.0.3'
}

repositories {
    mavenCentral()
}

dependencies {
    liquibaseRuntime 'org.liquibase:liquibase-core:3.8.1'
    // As of: https://github.com/liquibase/liquibase-gradle-plugin/issues/52
    liquibaseRuntime 'org.liquibase:liquibase-gradle-plugin:2.0.3'

    liquibaseRuntime 'org.postgresql:postgresql:42.2.10'
    liquibaseRuntime 'org.yaml:snakeyaml:1.12'
}

liquibase {
    activities {
        main {
            changeLogFile 'db.changelog-master.json'
            url 'jdbc:postgresql://localhost:5432/postgres'
            username 'postgres'
            password 'password'
        }
    }
    mainClassName = 'org.liquibase.gradle.OutputEnablingLiquibaseRunner'
}

Reproduction repo link: https://github.com/niktekusho/liquibase-gradle-plugin-issue-74

stevesaliman commented 4 years ago

The issue was that there was no Groovy library in the liquibseRuntime, so the plugin couldn't load the Groovy class specified.

I've added a transitive dependency to the plugin, so version 2.0.4 of the plugin should fix the issue.

niktekusho commented 4 years ago

I confirm 2.0.4 solves the issue, thanks! 👍