liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

includeAll doesn't work with relativeToChangelogFile="true" #29

Closed lludwa closed 5 years ago

lludwa commented 6 years ago

Including files works properly with following ways:

1) <includeAll path="src/main/resources/db/changelog/SQL/Evolutions/" relativeToChangelogFile="false"/>

2) <include file="SQL/Evolutions/2.sql" relativeToChangelogFile="true"/>

3) <include file="src/main/resources/db/changelog/SQL/Evolutions/1.sql" relativeToChangelogFile="false"/>

But doesn't work by: <includeAll path="SQL/Evolutions/" relativeToChangelogFile="true" />

Giving incoming message:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':update'.

    liquibase.exception.LiquibaseException: Unexpected error running Liquibase: Cannot find base path '/home/LiquibaseBugTestCase/src/main/resources/db/changelog/db.changelog.xml'

Steps to reproduce: 1) Configure test database (Database name: 'userdb', username 'userdb', password 'userdb') 2) Unzip file LiquibaseBugTestCase.zip 3) Invoke gradle update

stevesaliman commented 6 years ago

Thank you for the comprehensive test case. It is better than I usually get :-)

I think this is an issue with Liquibase itself. I downloaded the liquibase-core-3.5.3 and Mysql connector jars from Maven central, and I put them in the root directory of your project. I then ran the following:

java -jar liquibase-core-3.5.3.jar \
    --classpath=mysql-connector-java-5.1.34_1.jar \
    --logLevel=info \
    --changeLogFile=src/main/resources/db/changelog/db.changelog.xml \
    --url=jdbc:mysql://localhost:3306/userdb \
    --username=userdb \
    --password=userdb \
    update

When I did this, I got the same error as you did, but without Gradle in the mix - just straight Liquibase. I got the error for both relative and absolute paths to the change log file. I'd give that a try in your environment. If you see the same behavior in your environment, I'd recommend reporting the but in the Liquibase Jira. Previous reports of this bug are marked as fixed in previous versions, but it is clearly back now.

eximius313 commented 6 years ago

The problem is that, as long as https://github.com/liquibase/liquibase-gradle-plugin/issues/11 is unresolved, even if they fix it, we still we can not benefit from it :(

stevesaliman commented 6 years ago

There are a couple of Liquibase bugs in our way, aren't there :-)

Fortunately, if they fix the includeAll bug, but not the sqlFile bug, you can still use the latest Liquibase with the Gradle plugin by applying the workaround mentioned in #11

kgoralski commented 6 years ago

Seems that this helped me: https://stackoverflow.com/questions/27187979/gradle-liquibase-change-log-file-could-not-be-found

but now it is executing twice ;)

eximius313 commented 6 years ago

this is completly different problem

evaldobratti commented 6 years ago

Maybe I'm running on this same problem in my project, do we have any update on this issue?

stevesaliman commented 6 years ago

Liquibase has fixed the blocking bug that was mentioned in #11, so I'm working on a version of the DSL that supports Liquibase 3.6.

Version 2.0.0-SNAPSHOT of the plugin has been released to the Sonatype snapshot repository, so you could try it out and see if it fixes your issue.

stevesaliman commented 6 years ago

I've just uploaded the latest 2.0.0-SNAPSHOT releases of the Gradle plugin and the Groovy DSL, which should now fully support parsing Liquibase 3.6.1 changelogs.

I still have some testing to do to make sure the serializers work, I need to update the documentation, and I need to look into workarounds for the logging problem, but I hope to have a final release done soon. In the meantime, users who need to use versions of Liquibase later than 3.4.2 can use the SNAPSHOT releases to get up and running.

stevesaliman commented 5 years ago

Release 2.0.0 is now official! Liquibase 3.6.1 is now fully supported.

Version 2.0.0 is a breaking change. I tried to document the changes well, please feel free to submit pull requests if there are ways to make the documentation clearer.

I spent a lot of time working with the include and includeAll elements of the databaseChangeLog, and I think they work much better now. I did discover a bug with versions 1.2.2 through 1.2.4, so if you're upgrading from one of them, please make sure to read up on the required updates to the DATABASECHANGELOG table for changes that were already run.

Also note that Liquibase itself has some issues with logging and console output, as documented in CORE-3220. Until that gets fixed, you can enable console output by adding mainClassName 'org.liquibase.gradle.OutputEnablingLiquibaseRunner' to the liquibase block of build.gradle.