From 1d8c37066ee73ee93819a59c0cb635bf1622aad8 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 10 Oct 2024 09:04:01 +0200 Subject: [PATCH] update flyway to v9.1.3 --- build.gradle | 19 ++++++++++++++----- .../javamodules/ExtraModuleInfoTransform.java | 5 +++++ .../transform/javamodules/ModuleInfo.java | 12 ++++++++++-- .../sparrow/io/db/DbPersistence.java | 2 +- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index ec29bb50..c5dbc649 100644 --- a/build.gradle +++ b/build.gradle @@ -76,7 +76,7 @@ dependencies { implementation('org.jdbi:jdbi3-sqlobject:3.20.0') { exclude group: 'org.slf4j' } - implementation('org.flywaydb:flyway-core:7.10.7-SNAPSHOT') + implementation('org.flywaydb:flyway-core:9.1.3') implementation('org.fxmisc.richtext:richtextfx:0.10.4') implementation('no.tornado:tornadofx-controls:1.0.4') implementation('com.google.zxing:javase:3.4.0') { @@ -189,7 +189,8 @@ application { "--add-opens=java.base/java.net=com.sparrowwallet.sparrow", "--add-opens=java.base/java.io=com.google.gson", "--add-opens=java.smartcardio/sun.security.smartcardio=com.sparrowwallet.sparrow", - "--add-reads=kotlin.stdlib=kotlinx.coroutines.core"] + "--add-reads=kotlin.stdlib=kotlinx.coroutines.core", + "--add-reads=org.flywaydb.core=java.desktop"] if(os.macOsX) { applicationDefaultJvmArgs += ["-Dprism.lcdtext=false", "-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow-large.png", @@ -210,8 +211,6 @@ jlink { requires 'jdk.crypto.cryptoki' requires 'java.management' requires 'io.leangen.geantyref' - uses 'org.flywaydb.core.extensibility.FlywayExtension' - uses 'org.flywaydb.core.internal.database.DatabaseType' uses 'org.eclipse.jetty.http.HttpFieldPreEncoder' } @@ -249,7 +248,8 @@ jlink { "--add-reads=com.sparrowwallet.merged.module=co.nstant.in.cbor", "--add-reads=com.sparrowwallet.merged.module=org.bouncycastle.pg", "--add-reads=com.sparrowwallet.merged.module=org.bouncycastle.provider", - "--add-reads=kotlin.stdlib=kotlinx.coroutines.core"] + "--add-reads=kotlin.stdlib=kotlinx.coroutines.core", + "--add-reads=org.flywaydb.core=java.desktop"] if(os.windows) { jvmArgs += ["-Djavax.accessibility.assistive_technologies", "-Djavax.accessibility.screen_magnifier_present=false"] @@ -488,6 +488,15 @@ extraJavaModuleInfo { requires('io.reactivex.rxjava2') requires('javafx.graphics') } + module('flyway-core-9.1.3.jar', 'org.flywaydb.core', '9.1.3') { + exports('org.flywaydb.core') + exports('org.flywaydb.core.api') + exports('org.flywaydb.core.api.exception') + exports('org.flywaydb.core.api.configuration') + uses('org.flywaydb.core.extensibility.Plugin') + provides('org.flywaydb.core.extensibility.Plugin', 'org.flywaydb.core.internal.database.h2.H2DatabaseType', 'org.flywaydb.core.internal.schemahistory.BaseAppliedMigration', 'org.flywaydb.core.internal.resource.CoreResourceTypeProvider') + requires('java.sql') + } module('wellbehavedfx-0.3.3.jar', 'org.fxmisc.wellbehaved', '0.3.3') { requires('javafx.base') requires('javafx.graphics') diff --git a/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ExtraModuleInfoTransform.java b/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ExtraModuleInfoTransform.java index c892bdb7..0a93bec8 100644 --- a/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ExtraModuleInfoTransform.java +++ b/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ExtraModuleInfoTransform.java @@ -13,6 +13,7 @@ import org.objectweb.asm.Opcodes; import java.io.*; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.jar.*; import java.util.regex.Pattern; @@ -169,6 +170,10 @@ abstract public class ExtraModuleInfoTransform implements TransformAction> providesEntry : moduleInfo.getProvides().entrySet()) { + moduleVisitor.visitProvide(providesEntry.getKey().replace('.', '/'), + providesEntry.getValue().stream().map(name -> name.replace('.', '/')).toArray(String[]::new)); + } moduleVisitor.visitEnd(); classWriter.visitEnd(); return classWriter.toByteArray(); diff --git a/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ModuleInfo.java b/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ModuleInfo.java index ecb999b3..167a5e8c 100644 --- a/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ModuleInfo.java +++ b/buildSrc/src/main/java/org/gradle/sample/transform/javamodules/ModuleInfo.java @@ -1,8 +1,7 @@ package org.gradle.sample.transform.javamodules; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * Data class to hold the information that should be added as module-info.class to an existing Jar file. @@ -14,6 +13,7 @@ public class ModuleInfo implements Serializable { private List requires = new ArrayList<>(); private List requiresTransitive = new ArrayList<>(); private List uses = new ArrayList<>(); + private Map> provides = new LinkedHashMap<>(); ModuleInfo(String moduleName, String moduleVersion) { this.moduleName = moduleName; @@ -36,6 +36,10 @@ public class ModuleInfo implements Serializable { this.uses.add(uses); } + public void provides(String service, String... providers) { + this.provides.put(service, Arrays.asList(providers)); + } + public String getModuleName() { return moduleName; } @@ -59,4 +63,8 @@ public class ModuleInfo implements Serializable { protected List getUses() { return uses; } + + public Map> getProvides() { + return provides; + } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java b/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java index 8b214ee8..8eeab03b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java @@ -624,7 +624,7 @@ public class DbPersistence implements Persistence { } private Flyway getFlyway(Storage storage, String schema, String password, File resourcesDir) throws StorageException { - return Flyway.configure().dataSource(getDataSource(storage, password)).locations("filesystem:" + resourcesDir.getAbsolutePath()).schemas(schema).failOnMissingLocations(true).load(); + return Flyway.configure().cleanDisabled(false).dataSource(getDataSource(storage, password)).locations("filesystem:" + resourcesDir.getAbsolutePath()).schemas(schema).failOnMissingLocations(true).load(); } //Flyway does not support JPMS yet, so the migration files are extracted to a temp dir in order to avoid classloader encapsulation issues