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..fb81cf9 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.