Skip to content

Commit

Permalink
Merge pull request #21 from flyway/archetype
Browse files Browse the repository at this point in the history
Add a flyway-community-db-support-archetype to help development
  • Loading branch information
Barry-RG authored May 17, 2024
2 parents 1d3c93f + a9ec266 commit 955b158
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 1 deletion.
29 changes: 29 additions & 0 deletions flyway-community-db-support-archetype/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-community-db-support-archetype</artifactId>
<version>10.12.0</version>
<packaging>maven-archetype</packaging>

<name>Archetype - flyway-community-db-support-archetype</name>
<description>An archetype for creating a new Flyway Community Database Support module</description>
<url>https://flywaydb.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>3.2.1</version>
</extension>
</extensions>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
name="${artifactId}">

<requiredProperties>
<requiredProperty key="parentVersion">
<defaultValue>10.8.0</defaultValue>
</requiredProperty>
<requiredProperty key="artifactId">
<defaultValue>flyway-database-example</defaultValue>
<validationRegex>flyway-database-\w+</validationRegex>
</requiredProperty>
</requiredProperties>

<fileSets>
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-community-db-support</artifactId>
<version>${parentVersion}</version>
</parent>

<artifactId>${artifactId}</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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;
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 implements CommunityDatabaseType {

@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;
}

@Override
public String getPluginVersion(Configuration config) {
return ExampleDatabaseExtension.readVersion();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.flywaydb.community.database.example.ExampleDatabaseType
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${pom.version}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
artifactId=flyway-database-example
parentVersion=10.12.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
verify
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-parent</artifactId>
<version>10.9.0</version>
<version>10.12.0</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -38,6 +38,7 @@
<module>flyway-database-clickhouse</module>
<module>flyway-database-oceanbase</module>
<module>flyway-database-databricks</module>
<module>flyway-community-db-support-archetype</module>
</modules>

<properties>
Expand Down

0 comments on commit 955b158

Please sign in to comment.