Im little stuck with XML. Path in sqlfile in XML must be taken from folders where are SQLfiles loaded by using dir and dir1 I have problem to build XML like that :
<databaseChangeLog
<changeSet author="John" id="JRIA" failOnError="true" runAlways="false">
<sqlFile path="path.sql" relativeToChangelogFile="true" encoding="utf8" />
<rollback>
<sqlFile path="rollback/path.sql" relativeToChangelogFile="true" encoding="utf8" />
</rollback>
</changeSet>
My example :
import groovy.io.FileType
import groovy.xml.*
def dir = new File("C:\\Users\\John\\git\\changelogs\\version1\\db")
def dir1 = new File("C:\\Users\\John\\git\\changelogs\\version1\\rollback")
def sw = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(sw)
xml.changeSet(author:"John", ID:"JIRA", failOnError: "True", runAlways: "false"){
sqlFile(path:"From DIR", relativeToChangelogFile="true")
rollback(){
sqlFile(path:"From DIR1", relativeToChangelogFile="true")}
}
How to use dir and dir1 in good way to generate that XML ? And how get specific extension files (sql)
it was quite simple, just use
.each