From f3d5553f83ee7ad3096552c310c1d86702a2413e Mon Sep 17 00:00:00 2001 From: Barry Attwater Date: Thu, 8 Feb 2024 16:35:31 +0000 Subject: [PATCH 1/5] Add a flyway-community-db-support-archetype --- flyway-community-db-support-archetype/pom.xml | 29 ++++++++++ .../META-INF/maven/archetype-metadata.xml | 24 +++++++++ .../resources/archetype-resources/pom.xml | 43 +++++++++++++++ .../database/example/ExampleDatabaseType.java | 53 +++++++++++++++++++ .../org.flywaydb.core.extensibility.Plugin | 1 + .../archetype.properties | 2 + .../projects/flyway-database-example/goal.txt | 1 + pom.xml | 1 + 8 files changed, 154 insertions(+) create mode 100644 flyway-community-db-support-archetype/pom.xml create mode 100644 flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 flyway-community-db-support-archetype/src/main/resources/archetype-resources/pom.xml create mode 100644 flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java create mode 100644 flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin create mode 100644 flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties create mode 100644 flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/goal.txt diff --git a/flyway-community-db-support-archetype/pom.xml b/flyway-community-db-support-archetype/pom.xml new file mode 100644 index 0000000..e3271f0 --- /dev/null +++ b/flyway-community-db-support-archetype/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.flywaydb + flyway-community-db-support-archetype + 10.7.2 + maven-archetype + + Archetype - flyway-community-db-support-archetype + An archetype for creating a new Flyway Community Database Support module + https://flywaydb.org + + + UTF-8 + 17 + + + + + + org.apache.maven.archetype + archetype-packaging + 3.2.1 + + + + diff --git a/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000..e0f35d0 --- /dev/null +++ b/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,24 @@ + + + + + + 10.7.2 + + + flyway-database-example + flyway-database-\w+ + + + + + + src/main/java + + **/*.java + + + + diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/pom.xml b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000..5b5c17d --- /dev/null +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + + org.flywaydb + flyway-community-db-support + ${parentVersion} + + + ${artifactId} + + + UTF-8 + 17 + + + + + ${project.groupId} + flyway-core + + + + + + + src/main/resources + true + + + + + maven-resources-plugin + + + maven-jar-plugin + + + + diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java new file mode 100644 index 0000000..8ca26c2 --- /dev/null +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java @@ -0,0 +1,53 @@ +package org.flywaydb.community.database.example; + +import java.sql.Connection; +import org.flywaydb.core.api.ResourceProvider; +import org.flywaydb.core.api.configuration.Configuration; +import org.flywaydb.core.internal.database.base.BaseDatabaseType; +import org.flywaydb.core.internal.database.base.Database; +import org.flywaydb.core.internal.jdbc.JdbcConnectionFactory; +import org.flywaydb.core.internal.jdbc.StatementInterceptor; +import org.flywaydb.core.internal.parser.Parser; +import org.flywaydb.core.internal.parser.ParsingContext; + +public class ExampleDatabaseType extends BaseDatabaseType { + + @Override + public String getName() { + return null; + } + + @Override + public int getNullType() { + return 0; + } + + @Override + public boolean handlesJDBCUrl(final String url) { + return false; + } + + @Override + public String getDriverClass(final String url, final ClassLoader classLoader) { + return null; + } + + @Override + public boolean handlesDatabaseProductNameAndVersion(final String databaseProductName, + final String databaseProductVersion, + final Connection connection) { + return false; + } + + @Override + public Database createDatabase(final Configuration configuration, final JdbcConnectionFactory jdbcConnectionFactory, + final StatementInterceptor statementInterceptor) { + return null; + } + + @Override + public Parser createParser(final Configuration configuration, final ResourceProvider resourceProvider, + final ParsingContext parsingContext) { + return null; + } +} \ No newline at end of file diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin new file mode 100644 index 0000000..b0431cc --- /dev/null +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin @@ -0,0 +1 @@ +org.flywaydb.community.database.example.ExampleDatabaseType \ No newline at end of file diff --git a/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties new file mode 100644 index 0000000..c2303f8 --- /dev/null +++ b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties @@ -0,0 +1,2 @@ +artifactId=flyway-database-example +parentVersion=10.7.2 \ No newline at end of file diff --git a/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/goal.txt b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/goal.txt new file mode 100644 index 0000000..4a1a71d --- /dev/null +++ b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file diff --git a/pom.xml b/pom.xml index f33234f..dc1c643 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ flyway-database-clickhouse flyway-database-oceanbase flyway-database-databricks + flyway-community-db-support-archetype From 9496be4c28c5b33cf3f2cad895aa556f1e4d0b85 Mon Sep 17 00:00:00 2001 From: JasonLuo-Redgate <130552403+JasonLuo-Redgate@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:09:00 +0000 Subject: [PATCH 2/5] Add getPluginVersion support --- .../database/ExampleDatabaseExtension.java | 39 +++++++++++++++++++ .../database/example/ExampleDatabaseType.java | 6 +++ .../community/database/example/version.txt | 1 + 3 files changed, 46 insertions(+) create mode 100644 flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/ExampleDatabaseExtension.java create mode 100644 flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/org/flywaydb/community/database/example/version.txt diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/ExampleDatabaseExtension.java b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/ExampleDatabaseExtension.java new file mode 100644 index 0000000..9221a0d --- /dev/null +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/ExampleDatabaseExtension.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2024 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.flywaydb.community.database; + +import org.flywaydb.core.api.FlywayException; +import org.flywaydb.core.extensibility.PluginMetadata; +import org.flywaydb.core.internal.util.FileUtils; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +public class ExampleDatabaseExtension implements PluginMetadata { + public String getDescription() { + return "Community-contributed Example database support extension " + readVersion() + " by Redgate"; + } + + public static String readVersion() { + try { + return FileUtils.copyToString( + ExampleDatabaseExtension.class.getClassLoader().getResourceAsStream("org/flywaydb/community/database/example/version.txt"), + StandardCharsets.UTF_8); + } catch (IOException e) { + throw new FlywayException("Unable to read extension version: " + e.getMessage(), e); + } + } +} diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java index 8ca26c2..eef6090 100644 --- a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java @@ -1,6 +1,7 @@ package org.flywaydb.community.database.example; import java.sql.Connection; +import org.flywaydb.community.database.ExampleDatabaseExtension; import org.flywaydb.core.api.ResourceProvider; import org.flywaydb.core.api.configuration.Configuration; import org.flywaydb.core.internal.database.base.BaseDatabaseType; @@ -50,4 +51,9 @@ public Parser createParser(final Configuration configuration, final ResourceProv final ParsingContext parsingContext) { return null; } + + @Override + public String getPluginVersion(Configuration config) { + return ExampleDatabaseExtension.readVersion(); + } } \ No newline at end of file diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/org/flywaydb/community/database/example/version.txt b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/org/flywaydb/community/database/example/version.txt new file mode 100644 index 0000000..1785151 --- /dev/null +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/resources/org/flywaydb/community/database/example/version.txt @@ -0,0 +1 @@ +${pom.version} \ No newline at end of file From 608b4422a2b6e3b2bf114985af1b650a00c73acd Mon Sep 17 00:00:00 2001 From: JasonLuo-Redgate <130552403+JasonLuo-Redgate@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:42:45 +0000 Subject: [PATCH 3/5] implements CommunityDatabaseType --- .../community/database/example/ExampleDatabaseType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java index eef6090..bfb25e2 100644 --- a/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java +++ b/flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java @@ -5,13 +5,14 @@ import org.flywaydb.core.api.ResourceProvider; import org.flywaydb.core.api.configuration.Configuration; import org.flywaydb.core.internal.database.base.BaseDatabaseType; +import org.flywaydb.core.internal.database.base.CommunityDatabaseType; import org.flywaydb.core.internal.database.base.Database; import org.flywaydb.core.internal.jdbc.JdbcConnectionFactory; import org.flywaydb.core.internal.jdbc.StatementInterceptor; import org.flywaydb.core.internal.parser.Parser; import org.flywaydb.core.internal.parser.ParsingContext; -public class ExampleDatabaseType extends BaseDatabaseType { +public class ExampleDatabaseType extends BaseDatabaseType implements CommunityDatabaseType { @Override public String getName() { From 0cb6f8a667c158e79bf275bc41991d05ef61fe46 Mon Sep 17 00:00:00 2001 From: JasonLuo-Redgate <130552403+JasonLuo-Redgate@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:18:40 +0000 Subject: [PATCH 4/5] bump version --- flyway-community-db-support-archetype/pom.xml | 2 +- .../src/main/resources/META-INF/maven/archetype-metadata.xml | 2 +- .../projects/flyway-database-example/archetype.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flyway-community-db-support-archetype/pom.xml b/flyway-community-db-support-archetype/pom.xml index e3271f0..892b605 100644 --- a/flyway-community-db-support-archetype/pom.xml +++ b/flyway-community-db-support-archetype/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.flywaydb flyway-community-db-support-archetype - 10.7.2 + 10.8.0 maven-archetype Archetype - flyway-community-db-support-archetype diff --git a/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index e0f35d0..2eb534e 100644 --- a/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/flyway-community-db-support-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -5,7 +5,7 @@ - 10.7.2 + 10.8.0 flyway-database-example diff --git a/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties index c2303f8..7546397 100644 --- a/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties +++ b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties @@ -1,2 +1,2 @@ artifactId=flyway-database-example -parentVersion=10.7.2 \ No newline at end of file +parentVersion=10.8.0 \ No newline at end of file From a9ec266cd953594bf73be40ec3de00f69d828c1b Mon Sep 17 00:00:00 2001 From: Barry Attwater Date: Tue, 14 May 2024 17:06:10 +0100 Subject: [PATCH 5/5] Increase version to 10.12.0 --- flyway-community-db-support-archetype/pom.xml | 2 +- .../projects/flyway-database-example/archetype.properties | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flyway-community-db-support-archetype/pom.xml b/flyway-community-db-support-archetype/pom.xml index 892b605..8f7865a 100644 --- a/flyway-community-db-support-archetype/pom.xml +++ b/flyway-community-db-support-archetype/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.flywaydb flyway-community-db-support-archetype - 10.8.0 + 10.12.0 maven-archetype Archetype - flyway-community-db-support-archetype diff --git a/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties index 7546397..45ecfa9 100644 --- a/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties +++ b/flyway-community-db-support-archetype/src/test/resources/projects/flyway-database-example/archetype.properties @@ -1,2 +1,2 @@ artifactId=flyway-database-example -parentVersion=10.8.0 \ No newline at end of file +parentVersion=10.12.0 \ No newline at end of file diff --git a/pom.xml b/pom.xml index dc1c643..3ae7ee3 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.flywaydb flyway-parent - 10.9.0 + 10.12.0 4.0.0