John Doe
John Doe

Reputation: 147

sqlFILE to XML with liquibase

I try to generate XML files based on my sql files. I use that plugin. Can I use changeset in .each ? And why I got error for no singnature of method ? Documentation of that plugin is a little poor...

@Grapes(
    @Grab(group='org.liquibase', module='liquibase-groovy-dsl', version='1.2.2')
)

import groovy.io.FileType
import liquibase.changelog.*

def databaseChangeLog() {

def list = []
def dir = new File(".")
dir.eachFileRecurse (FileType.FILES) { file ->
list << file
    list.each {                    
        changeSet(id: 'sql-file') {
        sqlFile(path: $list, stripComments: 'true', splitStatements: 'true', encoding: 'utf8')
}
    }
            }
} 

error

Upvotes: 0

Views: 141

Answers (1)

sensei
sensei

Reputation: 621

I believe you have at least 2 problems here.

First, you shouldn't iterate on your list object before it's done being populated. But indeed, that object is not very useful and I guess you could do your thing in eachFileRecurse directly.

Second, I think you've mixed things up between a function definition (def databaseChangeLog() {}) and making a call to the databaseChangeLog delegate from the plug-in.

So your code should probably look like this:

@Grapes(
    @Grab(group='org.liquibase', module='liquibase-groovy-dsl', version='1.2.2')
)

import groovy.io.FileType
import liquibase.changelog.*

def dir = new File(".")

databaseChangeLog {
  dir.eachFileRecurse(FileType.FILES) { file ->
    changeSet(id: 'sql-file') {
      sqlFile(path: file.absolutePath, stripComments: 'true', splitStatements: 'true', encoding: 'utf8')
    }
  }
}

Upvotes: 1

Related Questions