Skip to content

Commit 1778211

Browse files
committed
#5 upgrade to flyway 5.0.7 with forward compatibility for flyway 5.1.x
1 parent 153e577 commit 1778211

File tree

4 files changed

+187
-43
lines changed

4 files changed

+187
-43
lines changed

build.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
32
import java.util.regex.Matcher
43

54
plugins {
@@ -11,10 +10,12 @@ ext {
1110
ossrhUsername = project.findProperty('ossrh.username')
1211
ossrhPassword = project.findProperty('ossrh.password')
1312

14-
flywayCoreVersions = ['3.0', '3.1', '3.2.1', '4.0.3', '4.1.2']
15-
flywayTestExtensionsVersions = ['3.0.1', '3.1', '3.2.1.1', '4.0.1', '4.1.0']
13+
flywayCoreVersions = ['3.0', '3.1', '3.2.1', '4.0.3', '4.1.2', '4.2.0', '5.0.7']
14+
flywayTestExtensionsVersions = ['3.0.1', '3.1', '3.2.1.1', '4.0.1', '4.1.0', '4.2.0.2', '5.0.0']
1615
embeddedPostgresVersions = ['9.3.23', '9.4.18', '9.5.13', '9.6.9', '10.4.0']
1716

17+
flywayCoreVersion = flywayCoreVersions.last()
18+
flywayTestVersion = flywayTestExtensionsVersions.last()
1819
postgresVersion = embeddedPostgresVersions.last()
1920
}
2021

@@ -143,7 +144,8 @@ project(':embedded-database-spring-test') {
143144
compile project(':embedded-database-spring-test-autoconfigure')
144145
compile 'org.springframework:spring-context:4.3.10.RELEASE'
145146
compile 'org.springframework:spring-test:4.3.10.RELEASE'
146-
compile 'org.flywaydb.flyway-test-extensions:flyway-spring-test:4.2.0.2'
147+
compile "org.flywaydb:flyway-core:$flywayCoreVersion"
148+
compile "org.flywaydb.flyway-test-extensions:flyway-spring-test:$flywayTestVersion"
147149
compile 'com.google.guava:guava:23.0'
148150
compile 'org.tukaani:xz:1.8'
149151

@@ -191,7 +193,7 @@ project(':embedded-database-spring-test') {
191193
}
192194

193195
configurations {
194-
for (version in flywayCoreVersions) {
196+
flywayCoreVersions.init().each { version ->
195197
"testRuntimeWithFlywayCore$version" {
196198
extendsFrom testRuntime
197199
resolutionStrategy {
@@ -204,7 +206,7 @@ project(':embedded-database-spring-test') {
204206
}
205207
}
206208

207-
for (version in flywayTestExtensionsVersions) {
209+
flywayTestExtensionsVersions.init().each { version ->
208210
"testRuntimeWithFlywayTestExtensions$version" {
209211
extendsFrom testRuntime
210212
resolutionStrategy {
@@ -231,7 +233,7 @@ project(':embedded-database-spring-test') {
231233
}
232234
}
233235

234-
for (version in flywayCoreVersions) {
236+
flywayCoreVersions.init().each { version ->
235237
task "testWithFlywayCore$version"(type: Test) {
236238
dependsOn jar
237239

@@ -246,7 +248,7 @@ project(':embedded-database-spring-test') {
246248
check.dependsOn("testWithFlywayCore$version")
247249
}
248250

249-
for (version in flywayTestExtensionsVersions) {
251+
flywayTestExtensionsVersions.init().each { version ->
250252
task "testWithFlywayTestExtensions$version"(type: Test) {
251253
dependsOn jar
252254

@@ -257,7 +259,6 @@ project(':embedded-database-spring-test') {
257259
includeCategories 'io.zonky.test.category.FlywayIntegrationTests'
258260

259261
if (VersionNumber.withPatchNumber().parse(version) >= VersionNumber.withPatchNumber().parse("4.2.0.1")) {
260-
println "MultiFlywayIntegrationTests category has been applied!!! - $version"
261262
includeCategories 'io.zonky.test.category.MultiFlywayIntegrationTests'
262263
}
263264
}

embedded-database-spring-test/src/main/java/io/zonky/test/db/flyway/FlywayClassUtils.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.apache.commons.io.IOUtils;
44
import org.flywaydb.core.Flyway;
5+
import org.flywaydb.core.api.FlywayException;
56
import org.flywaydb.test.annotation.FlywayTest;
67
import org.slf4j.LoggerFactory;
78
import org.springframework.core.io.ClassPathResource;
@@ -15,6 +16,7 @@ public class FlywayClassUtils {
1516
"org.flywaydb.test.annotation.FlywayTests", FlywayClassUtils.class.getClassLoader());
1617

1718
private static final int flywayVersion;
19+
private static final boolean isFlywayPro;
1820

1921
static {
2022
String version;
@@ -34,6 +36,19 @@ public class FlywayClassUtils {
3436
version = "0";
3537
}
3638
flywayVersion = Integer.valueOf(version);
39+
40+
if (flywayVersion >= 50) {
41+
boolean isCommercial;
42+
try {
43+
new Flyway().getUndoSqlMigrationPrefix();
44+
isCommercial = true;
45+
} catch (FlywayException e) {
46+
isCommercial = false;
47+
}
48+
isFlywayPro = isCommercial;
49+
} else {
50+
isFlywayPro = false;
51+
}
3752
}
3853

3954
private FlywayClassUtils() {}
@@ -53,4 +68,8 @@ public static boolean isRepeatableFlywayTestAnnotationPresent() {
5368
public static int getFlywayVersion() {
5469
return flywayVersion;
5570
}
71+
72+
public static boolean isFlywayPro() {
73+
return isFlywayPro;
74+
}
5675
}

0 commit comments

Comments
 (0)