liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
200 stars 60 forks source link

V3.0.1 Invalid argument '--url': missing required argument #160

Open ccmjga opened 1 month ago

ccmjga commented 1 month ago

@marques-work @stevesaliman I'm sorry to bother you again.i am really didn't get the point of this question. https://github.com/liquibase/liquibase-gradle-plugin/issues/154

I'm using liquibase-gradle-plugin 3.0.1 + gradle 8.10 + gradle.build.kts + liquibase-core:4.29.2 to build my project.

My config file is as follows:

plugins {
    ....
    id("org.liquibase.gradle") version "3.0.1"
}
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    ....
    liquibaseRuntime("org.liquibase:liquibase-core:4.29.2")
    liquibaseRuntime("org.postgresql:postgresql")
    liquibaseRuntime("info.picocli:picocli:4.7.6")
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.liquibase:liquibase-core:4.29.2")
    }
}

liquibase {
    runList = "main"
    activities.register("main") {
        val url = "jdbc:postgresql://${providers.gradleProperty("database.hostPort").get()}/${providers.gradleProperty("database.name").get()}"
        this.arguments = mapOf(
            "changelogFile" to "src/main/resources/changelog-main.sql",
            "url" to url,
            "username" to providers.gradleProperty("database.user").get(),
            "password" to providers.gradleProperty("database.password").get(),
            "driver" to "org.postgresql.Driver",
            "defaultSchemaName" to "mjga"
        )
    }
}

When I ran generateChangelog --stacktrace I also ran into Invalid argument '--url': missing required argument

Next I changed the config file to this then when running generateChangelog --stacktrace again, the problem magically disappeared.

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
    gradlePluginPortal()
  }

  dependencies {
        classpath("org.liquibase:liquibase-core:4.29.2")
    }
}

Even if I restore the configuration to

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.liquibase:liquibase-core:4.29.2")
    }
}

The question still hasn't come up anymore. What happened? How does this work?

If someone else downloads my project, do they need to change the config file around like I did to get it to work?

ccmjga commented 1 month ago

Of course I could go back to version 2.2, but 2.2 doesn't seem to support the use of defaultSchemaName in liquibase {} so using version 3.0+ is my only option. https://github.com/liquibase/liquibase-gradle-plugin/issues/130

stevesaliman commented 1 month ago

Try running with --debug, then look for the line that starts with liquibase-plugin: Running 'liquibase. That will tell you what arguments the plugin is passing to Liquibase.

My hunch is that the url variable in your config file doesn't have a value for some reason. In Groovy build files, you could add a println statement to the build file to help troubleshoot the issue, you could probably do the same in a Kotlin file.

vladipetrenko commented 1 month ago

I have similar troubles with my project, strange behavior on activity and arguments. I'm using liquibase-gradle-plugin 3.0.1 + gradle 7.61 + gradle.build.kts + liquibase-core:4.29.2 to build my project. I debugged plugin from IntelliJ. I found strange behavior in activity and arguments. If I start "diff" activity, i get "dropAll" as name of activity and all four arguments from "dropAll" but not from "diff" activity. I don't really go deep into debuging, but I think here is something wrong with arguments and activity handling.

ccmjga commented 1 month ago

I have similar troubles with my project, strange behavior on activity and arguments. I'm using liquibase-gradle-plugin 3.0.1 + gradle 7.61 + gradle.build.kts + liquibase-core:4.29.2 to build my project. I debugged plugin from IntelliJ. I found strange behavior in activity and arguments. If I start "diff" activity, i get "dropAll" as name of activity and all four arguments from "dropAll" but not from "diff" activity. I don't really go deep into debuging, but I think here is somthing wrong with arguments and activity handling.

My problems are intermittent. Now I'm clueless. For now I've given up on using this plugin for now, pending a newer version.

stevesaliman commented 1 month ago

I can't reproduce the "diff" behavior. Whenever I run diff, I get the right arguments passed to Liquibase.

My hunch is that the intermittent nature of the plugin's behavior is somehow related to the gradle daemon. Perhaps the daemon is holding on to something in the cache that it shouldn't?

Does stopping the daemon help at all?

vladipetrenko commented 1 month ago

I try to kill all my gradle demons like discribed in this post: https://stackoverflow.com/questions/69468990/momentarily-kill-or-restart-gradle-daemon-from-inside-intellij-idea-gradle-s

But it does not help. Below I describe my testing litle bit more:

My config file is as follows:

liquibase {
    jvmArgs = "-Duser.dir=${project.projectDir}"

    val encryptedDBPassword = properties["datasource.password"] as String

    activities.register("diff") {
        this.arguments = mapOf(
            "changelogFile" to "src/main/resources/db/migration/changelogs/${version}_diff_changelog.xml",
            "url" to properties["datasource.url"],
            "username" to properties["datasource.user"],
            "password" to decrypt(encryptedDBPassword),
            "defaultSchemaName" to properties["default.schemas"],
            "referenceUrl" to "hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy",
            "driver" to "org.postgresql.Driver",
            "referenceDriver" to "liquibase.ext.hibernate.database.connection.HibernateDriver"
        )
    }
    activities.register("generate-data-changelog") {
        this.arguments = mapOf(
            "liquibaseOutputFile" to "src/main/resources/db/migration/changelogs/_changelog_data.xml",
            "url" to properties["datasource.url"],
            "username" to properties["datasource.user"],
            "password" to decrypt(encryptedDBPassword),
            "defaultSchemaName" to properties["default.schemas"],
            "diffTypes" to "data"
        )
    }
    activities.register("generate-changelog") {
        this.arguments = mapOf(
            "liquibaseOutputFile" to "src/main/resources/db/migration/changelogs/_changelog.xml",
            "url" to properties["datasource.url"],
            "username" to properties["datasource.user"],
            "password" to decrypt(encryptedDBPassword),
            "defaultSchemaName" to properties["default.schemas"],
        )
    }
    activities.register("dropAll") {
        this.arguments = mapOf(
            "url" to properties["datasource.url"],
            "username" to properties["datasource.user"],
            "password" to decrypt(encryptedDBPassword),
            "defaultSchemaName" to properties["default.schemas"],
        )
    }
}

I start gradle task "diff" from IntelliJ in "Debug Mode".

Image

I set two breakpoints one in ArgumentBuilder.groovy and the other one on LiquibaseTask.groovy and debug the plugin. I get strange debug information, the activity is completly wrong. I started with "diff" but i get "dropAll" and i get data completly from "dropAll"

Image

Why is wrong liquibase activity running? I don't know is this a problem of IntelliJ or Gradle or of plugin them self.


The next try from me, was to use only one activity, my config like so:

liquibase {
    jvmArgs = "-Duser.dir=${project.projectDir}"

    val encryptedDBPassword = properties["datasource.password"] as String

    activities.register("diff") {
        this.arguments = mapOf(
            "changelogFile" to "src/main/resources/db/migration/changelogs/${version}_diff_changelog.xml",
            "url" to properties["datasource.url"],
            "username" to properties["datasource.user"],
            "password" to decrypt(encryptedDBPassword),
            "defaultSchemaName" to properties["default.schemas"],
            "referenceUrl" to "hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy",
            "driver" to "org.postgresql.Driver",
            "referenceDriver" to "liquibase.ext.hibernate.database.connection.HibernateDriver"
        )
    }
}

The right activity runs. The plugin works and create liquibase command to execute diff, but it is without "--changelog-file" parameter configuration I get following debug outprint: 2024-10-22T15:29:54.415+0200 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Running 'liquibase --driver=org.postgresql.Driver diff --default-schema-name=SHEMA_NAME --password=PASSWORD --reference-driver=liquibase.ext.hibernate.database.connection.HibernateDriver --reference-url=hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy --url=JDBC_URL --username=USERNAME'

But where is the changelogFile configuration, it was configured for the running activity. What is wrong, i do not know?

stevesaliman commented 1 month ago

I think I see where some of the confusion may be coming from. There is a difference between a Liquibase "command" and a plugin Activity.

A command is a liquibase command, such as dropAll, update, or diffChangelog.

Activities are introduced by the plugin. An activity is a more high level, broad category, and can be used to run the same command in different ways. For example, deploying an application might involve updating the application's schema, but it might also involve inserting metadata about the application in a registry in a different database. The plugin achieves this by allowing users to define 2 activities, each referring to different databases and changelogs. Activities can also be thought of as a collection of parameters that need to be grouped together. Perhaps "configuration" or "paramCollection" would have been a better choice...

The liquibase block also has an optional "runList", which determines which activities are run for each task. If no runList is defined, the Liquibase Plugin will run all the activities. NOTE: the order of execution when there is no runList is not guaranteed.

I usually put the following in my build.gradle files:

if ( !project.hasProperty("runList") ) {
    project.ext.runList = "main"
}

Then I define a "main" activity with all the parameters I need for running Liquibase commands. The plugin only supplies parameters to the liquibase command that are actually supported by the command. So in this case, the referenceUrl would be sent with "diff", but not "dropAll", no need to have 2 activities.

That setup makes "main" the default activity. If I wanted to have more than one activity, I could specify which one to use at runtime by including -PrunList=myActivity

vladipetrenko commented 1 month ago

After you explanation comment, I changed my configuration to:

liquibase {
    jvmArgs = "-Duser.dir=${project.projectDir}"

    val encryptedDBPassword = properties["datasource.password"] as String

    activities.register("main") {
        this.arguments = mapOf(
            "changelogFile" to "src/main/resources/db/migration/changelogs/${version}_diff_changelog.xml",
            "url" to properties["datasource.url"],
            "username" to properties["datasource.user"],
            "password" to decrypt(encryptedDBPassword),
            "defaultSchemaName" to properties["default.schemas"],
            "referenceUrl" to "hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy",
            "driver" to "org.postgresql.Driver",
            "referenceDriver" to "liquibase.ext.hibernate.database.connection.HibernateDriver"
        )
    }
}

NORMAL RUN

If I start gradle job normal Run -> diff, i get error:

2024-10-23T11:27:36.390+0200 [ERROR] [system.err] ####################################################
2024-10-23T11:27:36.390+0200 [ERROR] [system.err] Starte Liquibase am 11:27:36 mit Java 17.0.10 (Version 4.29.2 #3683, kompiliert am 2024-08-29 16:45+0000)
2024-10-23T11:27:36.390+0200 [ERROR] [system.err] Liquibase Version: 4.29.2
2024-10-23T11:27:36.390+0200 [ERROR] [system.err] WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
2024-10-23T11:27:36.413+0200 [ERROR] [system.err] Error parsing command line: Invalid argument '--reference-url': missing required argument
2024-10-23T11:27:36.413+0200 [ERROR] [system.err] 
2024-10-23T11:27:36.413+0200 [ERROR] [system.err] For detailed help, try 'liquibase --help' or 'liquibase <command-name> --help'
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':andi-spring-server:diff'.
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Process 'command 'C:\Program Files\Java\jdk-17.0.10+7\bin\java.exe'' finished with non-zero exit value 1
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2024-10-23T11:27:36.476+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --stacktrace option to get the stack trace.
2024-10-23T11:27:36.477+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights.
2024-10-23T11:27:36.477+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2024-10-23T11:27:36.477+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
2024-10-23T11:27:36.477+0200 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
2024-10-23T11:27:36.477+0200 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 2s

This is strange error: Error parsing command line: Invalid argument '--reference-url': missing required argument I configured the referenceUrl: "referenceUrl" to "hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&amp;hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy"

DEBUG RUN

Start gradle job debug Run -> diff. I get completely differen result!

Diff runs: 2024-10-23T11:34:24.854+0200 [ERROR] [system.err] Liquibase command 'diff' was executed successfully. But the defined changelogFile not used: "changelogFile" to "src/main/resources/db/migration/changelogs/${version}_diff_changelog.xml", Here the debug output: [DEBUG] [org.gradle.api.Project] liquibase-plugin: Running 'liquibase --driver=org.postgresql.Driver diff --default-schema-name=SHEMA_NAME --password=PASSWORD --reference-driver=liquibase.ext.hibernate.database.connection.HibernateDriver --reference-url=hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&amp;hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy --url=JDBC_URL --username=USERNAME'

And i can't debug the plugin from IntelliJ, because Skipped breakpoint at org. liquibase. gradle. LiquibaseTask:61 because it happened outside current JVM (I don't know how to fix this)

Some idea to next try?

stevesaliman commented 1 month ago

The LiquibaseTask class extends JavaExec, so you have to debug it a little differently. gradlew diff --debug-jvm should do the trick. The debug-jvm argument tells gradle to start the task in debug mode.

I'm not very familliar with Kotlin files, so I'm not sure why you get the behavior you do. I generally start with the Running 'liquibase line in the output. It tells me exactly how the plugin is trying to call Liquibase, and it tells me the exact value of each argument it is sending. That is a good place to discover which arguments are correct and which ones are missing or wrong.

I also downloaded the Liquibase standalone CLI, where I can run liquibase --help or liquibase <command> --help to see exactly which arguments are supported. The properties in your activity block must be the camelCase equivalent of the kebab-case shown in the help. I've lost arguments before because I've gotten the spelling wrong, or capitalized in the wrong place. (like changeLogFile instead of changelogFile)

I hope this helps.

vladipetrenko commented 1 month ago

I add println to my gradle.build.kts to outprint my map with key=value

println(activities.get("main").arguments)

Output:

[QUIET] [system.out] {
    changelogFile=hallo_diff_changelog.xml, 
    url=jdbc:JDBC_URL, 
    username=USERNAME, 
    password=PASSWORD, 
    defaultSchemaName=SCHEMA_NAME, 
    referenceUrl=hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&amp;hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy,
    driver=org.postgresql.Driver, 
    referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
    }

In debug(--debug) console output:

Gradle makes strange things? (class -> org.gradle.internal.execution.steps.SkipUpToDateStep)

2024-10-24T12:40:52.417+0200 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Resolve files of :andi-spring-server:liquibaseRuntime' completed
2024-10-24T12:40:52.417+0200 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Found version 4.29.2 of liquibase-core.
2024-10-24T12:40:52.418+0200 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Using the 4.4+ command line parser.
2024-10-24T12:40:52.419+0200 [INFO] [org.gradle.internal.execution.steps.ResolveCachingStateStep] Caching disabled for task ':andi-spring-server:diff' because:
  Build cache is disabled
2024-10-24T12:40:52.419+0200 [DEBUG] [org.gradle.internal.execution.steps.SkipUpToDateStep] Determining if task ':andi-spring-server:diff' is up-to-date
2024-10-24T12:40:52.419+0200 [INFO] [org.gradle.internal.execution.steps.SkipUpToDateStep] Task ':andi-spring-server:diff' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
2024-10-24T12:40:52.419+0200 [DEBUG] [org.gradle.internal.vfs.impl.AbstractVirtualFileSystem] Invalidating VFS paths: []
2024-10-24T12:40:52.420+0200 [DEBUG] [org.gradle.api.internal.tasks.execution.TaskExecution] Executing actions for task ':andi-spring-server:diff'.
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the changelogFile command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the defaultSchemaName command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the driver command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the password command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the referenceDriver command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the referenceUrl command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the url command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the username command argument because it is not supported by the diff command

This is wrong, all this arguments are supported by diff command...

At the end, I get java errors:


2024-10-24T13:23:32.393+0200 [ERROR] [system.err] Starte Liquibase am 13:23:32 mit Java 17.0.10 (Version 4.29.2 #3683, kompiliert am 2024-08-29 16:45+0000)
2024-10-24T13:23:32.393+0200 [ERROR] [system.err] Liquibase Version: 4.29.2
2024-10-24T13:23:32.393+0200 [ERROR] [system.err] WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
2024-10-24T13:23:32.418+0200 [ERROR] [system.err] Error parsing command line: Invalid argument '--reference-url': missing required argument
2024-10-24T13:23:32.418+0200 [ERROR] [system.err] 
2024-10-24T13:23:32.418+0200 [ERROR] [system.err] For detailed help, try 'liquibase --help' or 'liquibase <command-name> --help'
2024-10-24T13:23:32.479+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2024-10-24T13:23:32.479+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.

I'm not sure, but is this a gradle problem?

ccmjga commented 1 month ago

I add println to my gradle.build.kts to outprint my map with key=value

println(activities.get("main").arguments)

Output:

[QUIET] [system.out] {
  changelogFile=hallo_diff_changelog.xml, 
  url=jdbc:JDBC_URL, 
  username=USERNAME, 
  password=PASSWORD, 
  defaultSchemaName=SCHEMA_NAME, 
  referenceUrl=hibernate:spring:com.dls.vwa.robi.server.dataaccess?dialect=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect&amp;hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy,
  driver=org.postgresql.Driver, 
  referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
  }

In debug(--debug) console output:

Gradle makes strange things? (class -> org.gradle.internal.execution.steps.SkipUpToDateStep)

2024-10-24T12:40:52.417+0200 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Resolve files of :andi-spring-server:liquibaseRuntime' completed
2024-10-24T12:40:52.417+0200 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Found version 4.29.2 of liquibase-core.
2024-10-24T12:40:52.418+0200 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Using the 4.4+ command line parser.
2024-10-24T12:40:52.419+0200 [INFO] [org.gradle.internal.execution.steps.ResolveCachingStateStep] Caching disabled for task ':andi-spring-server:diff' because:
  Build cache is disabled
2024-10-24T12:40:52.419+0200 [DEBUG] [org.gradle.internal.execution.steps.SkipUpToDateStep] Determining if task ':andi-spring-server:diff' is up-to-date
2024-10-24T12:40:52.419+0200 [INFO] [org.gradle.internal.execution.steps.SkipUpToDateStep] Task ':andi-spring-server:diff' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
2024-10-24T12:40:52.419+0200 [DEBUG] [org.gradle.internal.vfs.impl.AbstractVirtualFileSystem] Invalidating VFS paths: []
2024-10-24T12:40:52.420+0200 [DEBUG] [org.gradle.api.internal.tasks.execution.TaskExecution] Executing actions for task ':andi-spring-server:diff'.
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the changelogFile command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the defaultSchemaName command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the driver command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the password command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the referenceDriver command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the referenceUrl command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the url command argument because it is not supported by the diff command
2024-10-24T12:40:52.421+0200 [DEBUG] [org.gradle.api.Project] skipping the username command argument because it is not supported by the diff command

This is wrong, all this arguments are supported by diff command...

At the end, I get java errors:


2024-10-24T13:23:32.393+0200 [ERROR] [system.err] Starte Liquibase am 13:23:32 mit Java 17.0.10 (Version 4.29.2 #3683, kompiliert am 2024-08-29 16:45+0000)
2024-10-24T13:23:32.393+0200 [ERROR] [system.err] Liquibase Version: 4.29.2
2024-10-24T13:23:32.393+0200 [ERROR] [system.err] WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
2024-10-24T13:23:32.418+0200 [ERROR] [system.err] Error parsing command line: Invalid argument '--reference-url': missing required argument
2024-10-24T13:23:32.418+0200 [ERROR] [system.err] 
2024-10-24T13:23:32.418+0200 [ERROR] [system.err] For detailed help, try 'liquibase --help' or 'liquibase <command-name> --help'
2024-10-24T13:23:32.479+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2024-10-24T13:23:32.479+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.

I'm not sure, but is this a gradle problem?

I also have this strange error happening intermittently in my project. But my rollback from v3 to v2 doesn't seem to create such a problem.

stevesaliman commented 4 weeks ago

When the plugin applies, it uses a Liquibase API to get the supported arguments for each command. When that API call returns empty lists, we get the behavior you see, where all the arguments are rejected as "unsupported".

I have no idea why this API call returns empty lists sometimes, only that it never does when I use the debugger. I did notice that the classpath seems to have an impact. For example, the plugin used to load the tasks at apply time, but get the supported arguments at execute time. What eventually realized is that apply time and execute time is two different classpaths, and while the same version of liquibase was used in both the buildscript and liquibaseRuntime dependencies was the same, to the JVM, they were two different instances of the jar file, and the second one was returning the empty list. The fix I made in 3.0.1 was to get the supported arguments at apply time instead so the same jar that gave me the task also gives me the argument list.

My hunch is that it is that something similar happens with the Gradle Daemon, but I dont' know enough about the daemon to know for sure. Does adding the --no-daemon flag make a difference?

owahlen commented 3 weeks ago

Having the same issue. In deed when using gradle with the --no-daemon option the task seems to work. Note, that the following workaround works for me without --no-daemon as it uses JAVA_OPTS instead of the arguments of the activity:

liquibase {
    jvmArgs = arrayOf(
        "-Dliquibase.command.url=$dbUrl",
        "-Dliquibase.command.username=$dbUser",
        "-Dliquibase.command.password=$dbPassword",
        "-Dliquibase.command.driver=org.postgresql.Driver",
        "-Dliquibase.command.changeLogFile=src/main/resources/db/changelog/db.changelog-master.yml")
    activities.register("main")
}
ahmedsayed commented 1 week ago

I had the same problem when trying to override the values from the command line, adding --no-daemon helped and worked for me