Skip to content

Commit

Permalink
fix: input property fingerprint invalid
Browse files Browse the repository at this point in the history
While I can confirm this fixes the issue, I cannot add a test since there is no infrastructure to execute the tasks.

ref: liquibase#120
  • Loading branch information
Nils Brugger committed Feb 20, 2024
1 parent 7ee8349 commit 5c5d0f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/main/groovy/org/liquibase/gradle/LiquibaseTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<LiquibaseCommand> getLiquibaseCommand()

/** a {@code Provider} that can provide a value for the liquibase version. */
private Provider<String> liquibaseVersionProvider
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions src/test/groovy/org/liquibase/gradle/LiquibasePluginTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand All @@ -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)
}

/**
Expand All @@ -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.
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 5c5d0f1

Please sign in to comment.