From 5c5d0f188fce290d3d259d41bc10bd20b54492e8 Mon Sep 17 00:00:00 2001 From: Nils Brugger Date: Tue, 20 Feb 2024 16:29:27 +0100 Subject: [PATCH] fix: input property fingerprint invalid While I can confirm this fixes the issue, I cannot add a test since there is no infrastructure to execute the tasks. ref: #120 --- .../org/liquibase/gradle/LiquibaseTask.groovy | 9 +++++---- .../liquibase/gradle/LiquibasePluginTest.groovy | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/groovy/org/liquibase/gradle/LiquibaseTask.groovy b/src/main/groovy/org/liquibase/gradle/LiquibaseTask.groovy index 4dfbe2d..67ef81a 100644 --- a/src/main/groovy/org/liquibase/gradle/LiquibaseTask.groovy +++ b/src/main/groovy/org/liquibase/gradle/LiquibaseTask.groovy @@ -15,6 +15,7 @@ package org.liquibase.gradle import org.gradle.api.Task +import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.Input import org.gradle.api.tasks.JavaExec @@ -27,11 +28,11 @@ import static org.liquibase.gradle.Util.versionAtLeast * * @author Stven C. Saliman */ -class LiquibaseTask extends JavaExec { +abstract class LiquibaseTask extends JavaExec { /** The Liquibase command to run */ @Input - LiquibaseCommand liquibaseCommand + abstract Property getLiquibaseCommand() /** a {@code Provider} that can provide a value for the liquibase version. */ private Provider liquibaseVersionProvider @@ -73,10 +74,10 @@ class LiquibaseTask extends JavaExec { // Set values on the JavaExec task using the Argument Builder appropriate for the Liquibase // version we have. if ( versionAtLeast(liquibaseVersion, '4.4') ) { - setArgs(ArgumentBuilder.buildLiquibaseArgs(project, activity, liquibaseCommand, liquibaseVersion)) + setArgs(ArgumentBuilder.buildLiquibaseArgs(project, activity, liquibaseCommand.get(), liquibaseVersion)) } else { logger.warn("using legacy argument builder. Consider updating to Liquibase 4.4+") - setArgs(LegacyArgumentBuilder.buildLiquibaseArgs(project, activity, liquibaseCommand, liquibaseVersion)) + setArgs(LegacyArgumentBuilder.buildLiquibaseArgs(project, activity, liquibaseCommand.get(), liquibaseVersion)) } def classpath = project.configurations.getByName(LiquibasePlugin.LIQUIBASE_RUNTIME_CONFIGURATION) diff --git a/src/test/groovy/org/liquibase/gradle/LiquibasePluginTest.groovy b/src/test/groovy/org/liquibase/gradle/LiquibasePluginTest.groovy index d14432c..7702e83 100644 --- a/src/test/groovy/org/liquibase/gradle/LiquibasePluginTest.groovy +++ b/src/test/groovy/org/liquibase/gradle/LiquibasePluginTest.groovy @@ -35,13 +35,13 @@ class LiquibasePluginTest { assertNotNull("Project is missing tag task", task) assertTrue("tag task is the wrong type", task instanceof LiquibaseTask) assertTrue("tag task should be enabled", task.enabled) - assertEquals("tag task has the wrong command", "tag", task.liquibaseCommand.command) + assertEquals("tag task has the wrong command", "tag", task.liquibaseCommand.get().command) // and the update task does not. task = project.tasks.findByName('update') assertNotNull("Project is missing update task", task) assertTrue("update task is the wrong type", task instanceof LiquibaseTask) assertTrue("update task should be enabled", task.enabled) - assertEquals("update task has the wrong command", "update", task.liquibaseCommand.command) + assertEquals("update task has the wrong command", "update", task.liquibaseCommand.get().command) } /** @@ -59,13 +59,13 @@ class LiquibasePluginTest { assertNotNull("Project is missing tag task", task) assertTrue("tag task is the wrong type", task instanceof LiquibaseTask) assertTrue("tag task should be enabled", task.enabled) - assertEquals("tag task has the wrong command", "tag", task.liquibaseCommand.command) + assertEquals("tag task has the wrong command", "tag", task.liquibaseCommand.get().command) // and the update task does not. task = project.tasks.findByName('update') assertNotNull("Project is missing update task", task) assertTrue("update task is the wrong type", task instanceof LiquibaseTask) assertTrue("update task should be enabled", task.enabled) - assertEquals("update task has the wrong command", "update", task.liquibaseCommand.command) + assertEquals("update task has the wrong command", "update", task.liquibaseCommand.get().command) } /** @@ -86,13 +86,13 @@ class LiquibasePluginTest { assertNotNull("Project is missing tag task", task) assertTrue("tag task is the wrong type", task instanceof LiquibaseTask) assertTrue("tag task should be enabled", task.enabled) - assertEquals("tag task has the wrong command", "tag", task.liquibaseCommand.command) + assertEquals("tag task has the wrong command", "tag", task.liquibaseCommand.get().command) // and the update task does not. task = project.tasks.findByName('liquibaseUpdate') assertNotNull("Project is missing update task", task) assertTrue("update task is the wrong type", task instanceof LiquibaseTask) assertTrue("update task should be enabled", task.enabled) - assertEquals("update task has the wrong command", "update", task.liquibaseCommand.command) + assertEquals("update task has the wrong command", "update", task.liquibaseCommand.get().command) // Make sure the standard tasks didn't get created, since we created them with different // names. @@ -150,7 +150,8 @@ class LiquibasePluginTest { // The provider looking for Liquibase will throw an // AbstractProperty$PropertyQueryException that should be wrapping the // LiquibaseConfigurationException that the plugin throws. Does it? - assertTrue("Wrong Exception when Liquibase is not in the class path", + e.printStackTrace() + assertTrue("Wrong Exception ($e) when Liquibase is not in the class path", e.getCause() instanceof LiquibaseConfigurationException) } }