0

I'm trying to integrate Liquibase to my company's application.

Our system uses Gradle as the build tool. I'm pretty new to Gradle.

I followed the following tutorial.

https://dzone.com/articles/managing-your-database-with-liquibase-and-gradle

I added the following to my build.gradle file.

def changeLog = "dev/samplechangelog.h2.sql"

task ('dev') {
    doLast {
        println "executing dev"
        liquibase {
            activities {
                main {
                    changeLogFile changeLog
                    url 'jdbc:postgresql://some_url:5432/postgres?currentSchema=schema_name'
                    username 'postgres'
                    password 'some_password'
                }
                runList = main
            }
        }
    }
}

And added the dependencies as in the tutorial.

After I build the project, I can see the Gradle task 'dev' like below.

enter image description here

The tutorial says to run gradle task dev update to run the gradle task.

But I think I should be able to do the same thing by double clicking the 'dev' task in the the 'Gradle' tab as in the above picture.

I put the update as an argument like below.

enter image description here

After I double click the Gradle task 'dev' I get the following output.

enter image description here

Even though it says the Build is successful, it's not. The databasechangelog table is not updated.

I can configm that the liquibase.properties file has the correct properties because I run liquibase via the terminal it updates in the same DB.

Does anyone have any ideas why this happens?

Amila Fonseka
  • 392
  • 1
  • 5
  • 15
  • `After I double click the Gradle task 'dev' I get the following output.` Please use Run Configuration Green icon to run the tas you have created. When you double click the task in Gradle tool window IDE will re-create it without parameters. – Andrey Sep 18 '20 at 07:58
  • Or use **Run Anything** popup: https://www.jetbrains.com/help/idea/work-with-gradle-tasks.html#gradle_tool_bar – Andrey Sep 18 '20 at 07:59
  • Also check that you get the expected result when running it in the command line. – Andrey Sep 18 '20 at 08:00
  • Thanks a lot, @Andrey for your comments. Actually I made SOME progress on it. When I REMOVED the outer ```task``` I was able to run it by double clicking on the ```update``` task in the liquibase gradle tasks. But still I have to learn about how Gradle works though. – Amila Fonseka Sep 18 '20 at 08:48
  • Please consider closing this question if your question has been answered. It appears that liquibase does work for you within InteliJ. Good luck on the Gradle, but if you need more help on liquibase, the forum (https://forum.liquibase.org) or liquibase discord server (https://discord.gg/9yBwMtj) is pretty useful. – ronak Oct 15 '20 at 02:47

0 Answers0