diff --git a/.travis.yml b/.travis.yml index d3eb5fdf..5392b598 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: groovy jdk: -- oraclejdk8 +- openjdk8 before_install: - cat /etc/hosts - sudo hostname "$(hostname | cut -c1-63)" diff --git a/README.md b/README.md index 6c6277e1..fcd9ba66 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Branches -**master** Version of the plugin compatible with Grails 3 and Hibernate 5. +**master** Version of the plugin compatible with Grails 3 / 4 and Hibernate 5. **2.x**. Version of the plugin compatible with Grails 3 and Hibernate 4. @@ -29,9 +29,9 @@ One popular approach is to have a root changelog named changlog.groovy (or chang ## Documentation * Grails 2: http://grails-plugins.github.io/grails-database-migration/docs/manual/index.html * Grails 3 (Hibernate 4): http://grails-plugins.github.io/grails-database-migration/2.0.x/index.html -* Grails 3 (Hibernate 5): http://grails-plugins.github.io/grails-database-migration/3.0.x/index.html +* Grails 3/4 (Hibernate 5): http://grails-plugins.github.io/grails-database-migration/3.0.x/index.html ## Package distribution -Software is distrbuted in [Bintray](https://bintray.com/grails/plugins/database-migration) +Software is distributed on [Bintray](https://bintray.com/grails/plugins/database-migration) diff --git a/build.gradle b/build.gradle index eae2b525..0229a353 100644 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,7 @@ configurations { dependencies { compile "org.liquibase:liquibase-core:$liquibaseVersion" - compile('org.liquibase.ext:liquibase-hibernate5:3.7') { + compile("org.liquibase.ext:liquibase-hibernate5:$liquibaseVersion") { exclude group: 'org.hibernate', module: 'hibernate-core' exclude group: 'org.hibernate', module: 'hibernate-entitymanager' exclude group: 'org.hibernate', module: 'hibernate-envers' diff --git a/gradle.properties b/gradle.properties index f807233d..128aa6b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ grailsVersion=3.2.1 gradleWrapperVersion=3.1 -liquibaseVersion=3.6.1 +liquibaseVersion=3.10.1 websiteUrl=http://grails-plugins.github.io/grails-database-migration issueTrackerUrl=https://github.com/grails-plugins/grails-database-migration/issues diff --git a/src/test/groovy/org/grails/plugins/databasemigration/command/DatabaseMigrationCommandSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/command/DatabaseMigrationCommandSpec.groovy index a5c3e60a..bd5599b4 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/command/DatabaseMigrationCommandSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/command/DatabaseMigrationCommandSpec.groovy @@ -51,4 +51,9 @@ abstract class DatabaseMigrationCommandSpec extends Specification { changeLogLocation = File.createTempDir() } + + protected static extractOutput(OutputCapture outputCapture){ + // outputCapture may contain debug outputs + outputCapture.toString().getAt(outputCapture.toString().indexOf("databaseChangeLog")..-1)?.replaceAll(/\s/,"") + } } diff --git a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmDiffCommandSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmDiffCommandSpec.groovy index c5ba5108..d0a9fac1 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmDiffCommandSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmDiffCommandSpec.groovy @@ -53,13 +53,14 @@ CREATE TABLE author (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, command.handle(getExecutionContext('other')) then: - outputCapture.toString() =~ ''' + String expected = extractOutput(outputCapture) + expected =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "AUTHOR"\\) \\{ column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) + constraints\\(nullable:"false", primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) \\} column\\(name: "NAME", type: "VARCHAR\\(255\\)"\\) \\{ @@ -76,7 +77,7 @@ databaseChangeLog = \\{ \\} \\} \\} -'''.trim() +'''.replaceAll(/\s/,"") } def "writes Change Log to update the database to a file given as arguments"() { @@ -87,13 +88,13 @@ databaseChangeLog = \\{ command.handle(getExecutionContext('other', outputChangeLog.name)) then: - outputChangeLog.text =~ ''' + outputChangeLog.text?.replaceAll(/\s/,"") =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "AUTHOR"\\) \\{ column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) + constraints\\(nullable:"false", primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) \\} column\\(name: "NAME", type: "VARCHAR\\(255\\)"\\) \\{ @@ -110,7 +111,7 @@ databaseChangeLog = \\{ \\} \\} \\} -'''.trim() +'''.replaceAll(/\s/,"") } def "an error occurs if the otherEnv parameter is not specified"() { diff --git a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateChangelogCommandSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateChangelogCommandSpec.groovy index 4bdeb2de..5843da73 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateChangelogCommandSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateChangelogCommandSpec.groovy @@ -33,13 +33,13 @@ CREATE TABLE author (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, command.handle(getExecutionContext()) then: - outputCapture.toString() =~ ''' + extractOutput(outputCapture) =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".*?", id: ".*?"\\) \\{ createTable\\(tableName: "AUTHOR"\\) \\{ column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) \\} column\\(name: "NAME", type: "VARCHAR\\(255\\)"\\) \\{ @@ -51,7 +51,7 @@ databaseChangeLog = \\{ changeSet\\(author: ".*?", id: ".*?"\\) \\{ createTable\\(tableName: "BOOK"\\) \\{ column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "PK_BOOK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "PK_BOOK"\\) \\} column\\(name: "TITLE", type: "VARCHAR\\(255\\)"\\) \\{ @@ -64,7 +64,7 @@ databaseChangeLog = \\{ \\} \\} \\} -'''.trim() +'''.replaceAll(/\s/, "") } def "generates an initial changelog from the database to a file given as arguments"() { @@ -75,13 +75,13 @@ databaseChangeLog = \\{ command.handle(getExecutionContext(outputChangeLog.name)) then: - outputChangeLog.text =~ ''' + outputChangeLog.text?.replaceAll(/\s/, "") =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".*?", id: ".*?"\\) \\{ createTable\\(tableName: "AUTHOR"\\) \\{ column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\) \\} column\\(name: "NAME", type: "VARCHAR\\(255\\)"\\) \\{ @@ -93,7 +93,7 @@ databaseChangeLog = \\{ changeSet\\(author: ".*?", id: ".*?"\\) \\{ createTable\\(tableName: "BOOK"\\) \\{ column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "PK_BOOK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "PK_BOOK"\\) \\} column\\(name: "TITLE", type: "VARCHAR\\(255\\)"\\) \\{ @@ -106,6 +106,6 @@ databaseChangeLog = \\{ \\} \\} \\} -'''.trim() +'''.replaceAll(/\s/, "") } } diff --git a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy index 20a65da2..a4a4e8f1 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy @@ -27,13 +27,13 @@ class DbmGenerateGormChangelogCommandSpec extends ApplicationContextDatabaseMigr command.handle(getExecutionContext()) then: - outputCapture.toString() =~ ''' + extractOutput(outputCapture) =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "author"\\) \\{ column\\(autoIncrement: "true", name: "id", type: "BIGINT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "authorPK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "authorPK"\\) \\} column\\(name: "version", type: "BIGINT"\\) \\{ @@ -49,7 +49,7 @@ databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "book"\\) \\{ column\\(autoIncrement: "true", name: "id", type: "BIGINT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "bookPK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "bookPK"\\) \\} column\\(name: "version", type: "BIGINT"\\) \\{ @@ -70,7 +70,7 @@ databaseChangeLog = \\{ addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\) \\} \\} -'''.trim() +'''.replaceAll(/\s/,"") } def "writes Change Log to copy the current state of the database to a file given as arguments"() { @@ -81,14 +81,14 @@ databaseChangeLog = \\{ command.handle(getExecutionContext(filename)) then: - def output = new File(changeLogLocation, filename).text + def output = new File(changeLogLocation, filename).text?.replaceAll(/\s/, "") output =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "author"\\) \\{ column\\(autoIncrement: "true", name: "id", type: "BIGINT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "authorPK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "authorPK"\\) \\} column\\(name: "version", type: "BIGINT"\\) \\{ @@ -104,7 +104,7 @@ databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "book"\\) \\{ column\\(autoIncrement: "true", name: "id", type: "BIGINT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "bookPK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "bookPK"\\) \\} column\\(name: "version", type: "BIGINT"\\) \\{ @@ -125,7 +125,7 @@ databaseChangeLog = \\{ addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\) \\} \\} -'''.trim() +'''.replaceAll(/\s/, "") } def "an error occurs if changeLogFile already exists"() { diff --git a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy index e4d0aefb..3b90a4a3 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy @@ -31,14 +31,14 @@ class DbmGormDiffCommandSpec extends ApplicationContextDatabaseMigrationCommandS command.handle(getExecutionContext()) then: - def output = outputCapture.toString() - output =~ ''' + def output = extractOutput(outputCapture).replaceAll(/\s/,"") + output ==~ ''' databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "book"\\) \\{ column\\(autoIncrement: "true", name: "id", type: "BIGINT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "bookPK"\\) + constraints\\(nullable: "false", primaryKey: "true", primaryKeyName: "bookPK"\\) \\} column\\(name: "version", type: "BIGINT"\\) \\{ @@ -59,7 +59,7 @@ databaseChangeLog = \\{ addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\) \\} \\} -'''.trim() +'''.replaceAll(/\s/,"") } def "diffs GORM classes against a database and generates a changelog to a file given as arguments"() { @@ -70,14 +70,14 @@ databaseChangeLog = \\{ command.handle(getExecutionContext(filename)) then: - def output = new File(changeLogLocation, filename).text + def output = new File(changeLogLocation, filename).text?.replaceAll(/\s/,"") output =~ ''' databaseChangeLog = \\{ changeSet\\(author: ".+?", id: ".+?"\\) \\{ createTable\\(tableName: "book"\\) \\{ column\\(autoIncrement: "true", name: "id", type: "BIGINT"\\) \\{ - constraints\\(primaryKey: "true", primaryKeyName: "bookPK"\\) + constraints\\(nullable:"false", primaryKey: "true", primaryKeyName: "bookPK"\\) \\} column\\(name: "version", type: "BIGINT"\\) \\{ @@ -98,7 +98,7 @@ databaseChangeLog = \\{ addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\) \\} \\} -'''.trim() +'''.replaceAll(/\s/,"") } def "an error occurs if changeLogFile already exists"() { diff --git a/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy index 6a4653cb..51b0ccda 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy @@ -4,13 +4,13 @@ import grails.core.GrailsApplication import liquibase.exception.ValidationFailedException import org.grails.plugins.databasemigration.command.* - class GroovyChangeLogSpec extends ApplicationContextDatabaseMigrationCommandSpec { static List calledBlocks def setup() { calledBlocks = [] + Locale.setDefault(new Locale("en", "US")) } def "updates a database with Groovy Change"() { @@ -66,11 +66,9 @@ databaseChangeLog = { calledBlocks == ['validate', 'change'] } - - def "stops processing by calling the error method"() { given: - def command = createCommand(DbmUpdateCommand) + DbmUpdateCommand command = (DbmUpdateCommand)createCommand(DbmUpdateCommand) command.changeLogFile << """ databaseChangeLog = { changeSet(author: "John Smith", id: "1") { diff --git a/src/test/resources/logback.groovy b/src/test/resources/logback.groovy index 079d5702..cb071074 100644 --- a/src/test/resources/logback.groovy +++ b/src/test/resources/logback.groovy @@ -11,6 +11,8 @@ root(ERROR, ['STDOUT']) logger("org.grails", DEBUG, ['STDOUT'], false) logger("liquibase", DEBUG, ['STDOUT'], false) +logger("org.grails.datastore.gorm.GormEnhancer", INFO, ['STDOUT'], false) +logger("org.grails.plugin.datasource.TomcatJDBCPoolMBeanExporter", WARN, ['STDOUT'], false)