-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathliquibase.gradle
37 lines (31 loc) · 1.43 KB
/
liquibase.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
configurations {
liquibase
}
dependencies {
liquibase 'org.liquibase.ext:liquibase-hibernate5:3.6'
compile 'org.liquibase:liquibase-core:3.5.3'
}
apply plugin: 'org.liquibase.gradle'
//loading properties file.
Properties liquibaseProps = new Properties()
liquibaseProps.load(new FileInputStream(file("src/main/resources/liquibase-task.properties")))
Properties applicationProps = new Properties()
applicationProps.load(new FileInputStream(file("src/main/resources/application.properties")))
task liquibaseDiffChangeLog(type: JavaExec) {
group = "liquibase"
classpath sourceSets.main.runtimeClasspath
classpath configurations.liquibase
main = "liquibase.integration.commandline.Main"
args "--changeLogFile="+liquibaseProps.getProperty('liquibase.changelog.path')+ "db.changelog-"+ buildTimestamp()+"-schema.xml"
args "--referenceUrl=hibernate:spring:" + liquibaseProps.getProperty('liquibase.domain.package') + "?dialect=" + applicationProps.getProperty('spring.jpa.database-platform')
args "--username=" + applicationProps.getProperty('spring.datasource.username')
args "--password=" + applicationProps.getProperty('spring.datasource.password')
args "--url=" + applicationProps.getProperty('spring.datasource.url')
args "--driver=" + applicationProps.getProperty('spring.datasource.driverClassName')
args "diffChangeLog"
}
def buildTimestamp() {
def date = new Date()
def formattedDate = date.format('yyyyMMdd_HHmmss')
return formattedDate
}