From 05c34ef46c3d6093ca001ca759a384467f3d37e8 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Mon, 18 Nov 2024 10:16:30 +0100 Subject: [PATCH] Add reflection metadata for Flyway 10.20.1 --- .../flyway-core/10.20.1/index.json | 4 + .../flyway-core/10.20.1/reflect-config.json | 247 ++++++++++++++++++ .../flyway-core/10.20.1/resource-config.json | 14 + metadata/org.flywaydb/flyway-core/index.json | 8 + tests/src/index.json | 6 + .../flyway-core/10.20.1/.gitignore | 4 + .../flyway-core/10.20.1/README.md | 12 + .../flyway-core/10.20.1/access-filter.json | 10 + .../flyway-core/10.20.1/build.gradle | 38 +++ .../flyway-core/10.20.1/generate-metadata.sh | 4 + .../flyway-core/10.20.1/gradle.properties | 2 + .../flyway-core/10.20.1/settings.gradle | 13 + .../java/flyway/FixedResourceProvider.java | 47 ++++ .../src/test/java/flyway/FlywayTests.java | 48 ++++ .../native-image/test/resource-config.json | 13 + .../db/migration/V1__create_table.sql | 5 + .../db/migration/V2__alter_table.sql | 2 + .../flyway-core/10.20.1/user-code-filter.json | 10 + 18 files changed, 487 insertions(+) create mode 100644 metadata/org.flywaydb/flyway-core/10.20.1/index.json create mode 100644 metadata/org.flywaydb/flyway-core/10.20.1/reflect-config.json create mode 100644 metadata/org.flywaydb/flyway-core/10.20.1/resource-config.json create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/.gitignore create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/README.md create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/access-filter.json create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/build.gradle create mode 100755 tests/src/org.flywaydb/flyway-core/10.20.1/generate-metadata.sh create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/gradle.properties create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/settings.gradle create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FixedResourceProvider.java create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FlywayTests.java create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/META-INF/native-image/test/resource-config.json create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V1__create_table.sql create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V2__alter_table.sql create mode 100644 tests/src/org.flywaydb/flyway-core/10.20.1/user-code-filter.json diff --git a/metadata/org.flywaydb/flyway-core/10.20.1/index.json b/metadata/org.flywaydb/flyway-core/10.20.1/index.json new file mode 100644 index 000000000..11ac50cc5 --- /dev/null +++ b/metadata/org.flywaydb/flyway-core/10.20.1/index.json @@ -0,0 +1,4 @@ +[ + "reflect-config.json", + "resource-config.json" +] diff --git a/metadata/org.flywaydb/flyway-core/10.20.1/reflect-config.json b/metadata/org.flywaydb/flyway-core/10.20.1/reflect-config.json new file mode 100644 index 000000000..d94c7dcf5 --- /dev/null +++ b/metadata/org.flywaydb/flyway-core/10.20.1/reflect-config.json @@ -0,0 +1,247 @@ +[ + { + "name": "org.flywaydb.core.api.migration.baseline.BaselineMigrationConfigurationExtension", + "condition": { + "typeReachable": "org.flywaydb.core.api.configuration.ClassicConfiguration" + }, + "allDeclaredFields": true + }, + { + "name": "org.flywaydb.core.api.migration.baseline.BaselineMigrationConfigurationExtension", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + }, + { + "name": "getBaselineMigrationPrefix", + "parameterTypes": [ + ] + }, + { + "name": "setBaselineMigrationPrefix", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + }, + { + "name": "org.flywaydb.core.extensibility.ConfigurationExtension", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + } + }, + { + "name": "org.flywaydb.core.extensibility.Plugin", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + } + }, + { + "name": "org.flywaydb.core.internal.command.clean.CleanModeConfigurationExtension", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + }, + { + "name": "getClean", + "parameterTypes": [ + ] + }, + { + "name": "setClean", + "parameterTypes": [ + "org.flywaydb.core.internal.command.clean.CleanModel" + ] + } + ] + }, + { + "name": "org.flywaydb.core.internal.command.clean.CleanModel", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true + }, + { + "name": "org.flywaydb.core.internal.command.clean.SchemaModel", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true + }, + { + "name": "org.flywaydb.core.internal.configuration.extensions.DeployScriptFilenameConfigurationExtension", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + }, + { + "name": "getScriptFilename", + "parameterTypes": [ + ] + }, + { + "name": "setScriptFilename", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + }, + { + "name": "org.flywaydb.core.internal.configuration.extensions.PrepareScriptFilenameConfigurationExtension", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + }, + { + "name": "getScriptFilename", + "parameterTypes": [ + ] + }, + { + "name": "setScriptFilename", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + }, + { + "name": "org.flywaydb.core.internal.logging.apachecommons.ApacheCommonsLogCreator", + "condition": { + "typeReachable": "org.flywaydb.core.internal.util.ClassUtils" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.flywaydb.core.internal.logging.log4j2.Log4j2LogCreator", + "condition": { + "typeReachable": "org.flywaydb.core.internal.util.ClassUtils" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.flywaydb.core.internal.logging.slf4j.Slf4jLogCreator", + "condition": { + "typeReachable": "org.flywaydb.core.internal.util.ClassUtils" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.flywaydb.core.internal.proprietaryStubs.LicensingConfigurationExtensionStub", + "condition": { + "typeReachable": "org.flywaydb.core.api.configuration.ClassicConfiguration" + }, + "allDeclaredFields": true + }, + { + "name": "org.flywaydb.core.internal.proprietaryStubs.PATTokenConfigurationExtensionStub", + "condition": { + "typeReachable": "org.flywaydb.core.api.configuration.ClassicConfiguration" + }, + "allDeclaredFields": true + }, + { + "name": "org.flywaydb.core.internal.publishing.PublishingConfigurationExtension", + "condition": { + "typeReachable": "org.flywaydb.core.api.configuration.ClassicConfiguration" + }, + "allDeclaredFields": true + }, + { + "name": "org.flywaydb.core.internal.publishing.PublishingConfigurationExtension", + "queryAllDeclaredMethods": true, + "condition": { + "typeReachable": "org.flywaydb.core.extensibility.ConfigurationExtension" + }, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + }, + { + "name": "isCheckDriftOnMigrate", + "parameterTypes": [ + ] + }, + { + "name": "isPublishResult", + "parameterTypes": [ + ] + }, + { + "name": "setCheckDriftOnMigrate", + "parameterTypes": [ + "boolean" + ] + }, + { + "name": "setPublishResult", + "parameterTypes": [ + "boolean" + ] + } + ] + } +] diff --git a/metadata/org.flywaydb/flyway-core/10.20.1/resource-config.json b/metadata/org.flywaydb/flyway-core/10.20.1/resource-config.json new file mode 100644 index 000000000..b28217eba --- /dev/null +++ b/metadata/org.flywaydb/flyway-core/10.20.1/resource-config.json @@ -0,0 +1,14 @@ +{ + "resources": { + "includes": [ + { + "pattern": "\\Qorg/flywaydb/core/internal/version.txt\\E", + "condition": { + "typeReachable": "org.flywaydb.core.internal.license.VersionPrinter" + } + } + ] + }, + "bundles": [ + ] +} diff --git a/metadata/org.flywaydb/flyway-core/index.json b/metadata/org.flywaydb/flyway-core/index.json index 565ef02c0..76507fbfc 100644 --- a/metadata/org.flywaydb/flyway-core/index.json +++ b/metadata/org.flywaydb/flyway-core/index.json @@ -1,8 +1,16 @@ [ { "latest": true, + "metadata-version": "10.20.1", + "module": "org.flywaydb:flyway-core", + "tested-versions": [ + "10.20.1" + ] + }, + { "metadata-version": "10.20.0", "module": "org.flywaydb:flyway-core", + "default-for": "10\\.20\\.0", "tested-versions": [ "10.20.0" ] diff --git a/tests/src/index.json b/tests/src/index.json index 06e22f200..ae0c49477 100644 --- a/tests/src/index.json +++ b/tests/src/index.json @@ -430,6 +430,12 @@ "name": "org.flywaydb:flyway-core", "versions": [ "10.20.0" ] } ] +}, { + "test-project-path": "org.flywaydb/flyway-core/10.20.1", + "libraries": [ { + "name": "org.flywaydb:flyway-core", + "versions": [ "10.20.1" ] + } ] }, { "test-project-path" : "org.flywaydb/flyway-core/9.0.1", "libraries" : [ { diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/.gitignore b/tests/src/org.flywaydb/flyway-core/10.20.1/.gitignore new file mode 100644 index 000000000..c98c7875b --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/.gitignore @@ -0,0 +1,4 @@ +gradlew.bat +gradlew +gradle/ +build/ diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/README.md b/tests/src/org.flywaydb/flyway-core/10.20.1/README.md new file mode 100644 index 000000000..04bcbc001 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/README.md @@ -0,0 +1,12 @@ +The metadata has been generated by executing the following script: + +```bash +./generate-metadata.sh +``` + +The generated metadata can be found in the `build/native/agent-output/test` directory. + +Afterwards, the generated metadata has been cleaned: +- Remove path to test resources +- Remove `META-INF/services` entries +- Remove H2 references diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/access-filter.json b/tests/src/org.flywaydb/flyway-core/10.20.1/access-filter.json new file mode 100644 index 000000000..90a5450fc --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/access-filter.json @@ -0,0 +1,10 @@ +{ + "rules": [ + { + "excludeClasses": ".**" + }, + { + "includeClasses": "org.flywaydb.core.**" + } + ] +} diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/build.gradle b/tests/src/org.flywaydb/flyway-core/10.20.1/build.gradle new file mode 100644 index 000000000..e7b258512 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/build.gradle @@ -0,0 +1,38 @@ +/* + * Copyright and related rights waived via CC0 + * + * You should have received a copy of the CC0 legalcode along with this + * work. If not, see . + */ +plugins { + id "org.graalvm.internal.tck" +} + +String libraryVersion = tck.testedLibraryVersion.get() + +dependencies { + testImplementation "org.flywaydb:flyway-core:$libraryVersion" + testImplementation 'com.h2database:h2:2.2.224' + testImplementation 'org.assertj:assertj-core:3.22.0' + testImplementation 'org.awaitility:awaitility:4.2.0' + testRuntimeOnly 'org.slf4j:slf4j-simple:2.0.16' + testRuntimeOnly 'org.apache.logging.log4j:log4j-api:2.24.1' + testRuntimeOnly 'commons-logging:commons-logging:1.3.4' +} + +graalvmNative { + binaries { + test { + buildArgs.add('--no-fallback') + } + } + agent { + defaultMode = "conditional" + modes { + conditional { + userCodeFilterPath = "user-code-filter.json" + } + } + accessFilterFiles.from("access-filter.json") + } +} diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/generate-metadata.sh b/tests/src/org.flywaydb/flyway-core/10.20.1/generate-metadata.sh new file mode 100755 index 000000000..3be262b11 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/generate-metadata.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +./gradlew clean +./gradlew test --tests "flyway.FlywayTests" -Pagent diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/gradle.properties b/tests/src/org.flywaydb/flyway-core/10.20.1/gradle.properties new file mode 100644 index 000000000..e1d944bbc --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/gradle.properties @@ -0,0 +1,2 @@ +library.version=10.20.1 +metadata.dir=org.flywaydb/flyway-core/10.20.1/ diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/settings.gradle b/tests/src/org.flywaydb/flyway-core/10.20.1/settings.gradle new file mode 100644 index 000000000..b78d384f5 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + def tckPath = Objects.requireNonNullElse( + System.getenv("GVM_TCK_TCKDIR"), + "../../../../tck-build-logic" + ) + includeBuild(tckPath) +} + +plugins { + id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" +} + +rootProject.name = 'flyway-core-tests' diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FixedResourceProvider.java b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FixedResourceProvider.java new file mode 100644 index 000000000..623451485 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FixedResourceProvider.java @@ -0,0 +1,47 @@ +/* + * Copyright and related rights waived via CC0 + * + * You should have received a copy of the CC0 legalcode along with this + * work. If not, see . + */ +package flyway; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +import org.flywaydb.core.api.ResourceProvider; +import org.flywaydb.core.api.resource.LoadableResource; +import org.flywaydb.core.internal.resource.classpath.ClassPathResource; + +/** + * This is needed as GraalVM doesn't support enumerating resources. It uses a hardcoded list of migrations. + */ +class FixedResourceProvider implements ResourceProvider { + private static final Set MIGRATIONS; + + static { + Set migrations = new HashSet<>(); + migrations.add("db/migration/V1__create_table.sql"); + migrations.add("db/migration/V2__alter_table.sql"); + MIGRATIONS = Collections.unmodifiableSet(migrations); + } + + @Override + public LoadableResource getResource(String name) { + if (!MIGRATIONS.contains(name)) { + return null; + } + return new ClassPathResource(null, name, getClass().getClassLoader(), StandardCharsets.UTF_8); + } + + @Override + public Collection getResources(String prefix, String[] suffixes) { + return MIGRATIONS.stream() + .map(file -> new ClassPathResource(null, file, getClass().getClassLoader(), StandardCharsets.UTF_8)) + .collect(Collectors.toList()); + } +} diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FlywayTests.java b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FlywayTests.java new file mode 100644 index 000000000..500eb16d9 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/java/flyway/FlywayTests.java @@ -0,0 +1,48 @@ +/* + * Copyright and related rights waived via CC0 + * + * You should have received a copy of the CC0 legalcode along with this + * work. If not, see . + */ +package flyway; + +import java.nio.charset.StandardCharsets; + +import javax.sql.DataSource; + +import org.flywaydb.core.Flyway; +import org.flywaydb.core.api.configuration.Configuration; +import org.flywaydb.core.api.configuration.FluentConfiguration; +import org.flywaydb.core.api.output.MigrateResult; +import org.h2.jdbcx.JdbcDataSource; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FlywayTests { + + @Test + void migrate() { + DataSource dataSource = getDataSource(); + + Configuration configuration = new FluentConfiguration() + .dataSource(dataSource) + .encoding(StandardCharsets.UTF_8) + .resourceProvider(new FixedResourceProvider()) + .loggers("slf4j", "log4j2", "apache-commons"); + + Flyway flyway = new Flyway(configuration); + MigrateResult migration = flyway.migrate(); + + assertThat(migration.success).isTrue(); + assertThat(migration.migrationsExecuted).isEqualTo(2); + } + + private DataSource getDataSource() { + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setUrl("jdbc:h2:mem:test"); + dataSource.setUser("user"); + dataSource.setPassword("password"); + return dataSource; + } +} diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/META-INF/native-image/test/resource-config.json b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/META-INF/native-image/test/resource-config.json new file mode 100644 index 000000000..427b8ed40 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/META-INF/native-image/test/resource-config.json @@ -0,0 +1,13 @@ +{ + "bundles": [], + "resources": { + "includes": [ + { + "pattern": "\\Qdb/migration/V1__create_table.sql\\E" + }, + { + "pattern": "\\Qdb/migration/V2__alter_table.sql\\E" + } + ] + } +} diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V1__create_table.sql b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V1__create_table.sql new file mode 100644 index 000000000..5e35ac71d --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V1__create_table.sql @@ -0,0 +1,5 @@ +CREATE TABLE test +( + id INT PRIMARY KEY, + title VARCHAR NOT NULL +); diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V2__alter_table.sql b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V2__alter_table.sql new file mode 100644 index 000000000..ed568f6e7 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/src/test/resources/db/migration/V2__alter_table.sql @@ -0,0 +1,2 @@ +ALTER TABLE test + ADD COLUMN name INT NOT NULL DEFAULT 1; diff --git a/tests/src/org.flywaydb/flyway-core/10.20.1/user-code-filter.json b/tests/src/org.flywaydb/flyway-core/10.20.1/user-code-filter.json new file mode 100644 index 000000000..b75d5f693 --- /dev/null +++ b/tests/src/org.flywaydb/flyway-core/10.20.1/user-code-filter.json @@ -0,0 +1,10 @@ +{ + "rules": [ + { + "includeClasses": "org.flywaydb.core.**" + }, + { + "includeClasses": "flyway.FlywayTests" + } + ] +}