Skip to content

Commit 955b158

Browse files
authored
Merge pull request #21 from flyway/archetype
Add a flyway-community-db-support-archetype to help development
2 parents 1d3c93f + a9ec266 commit 955b158

File tree

10 files changed

+202
-1
lines changed

10 files changed

+202
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>org.flywaydb</groupId>
7+
<artifactId>flyway-community-db-support-archetype</artifactId>
8+
<version>10.12.0</version>
9+
<packaging>maven-archetype</packaging>
10+
11+
<name>Archetype - flyway-community-db-support-archetype</name>
12+
<description>An archetype for creating a new Flyway Community Database Support module</description>
13+
<url>https://flywaydb.org</url>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.release>17</maven.compiler.release>
18+
</properties>
19+
20+
<build>
21+
<extensions>
22+
<extension>
23+
<groupId>org.apache.maven.archetype</groupId>
24+
<artifactId>archetype-packaging</artifactId>
25+
<version>3.2.1</version>
26+
</extension>
27+
</extensions>
28+
</build>
29+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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"
3+
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"
4+
name="${artifactId}">
5+
6+
<requiredProperties>
7+
<requiredProperty key="parentVersion">
8+
<defaultValue>10.8.0</defaultValue>
9+
</requiredProperty>
10+
<requiredProperty key="artifactId">
11+
<defaultValue>flyway-database-example</defaultValue>
12+
<validationRegex>flyway-database-\w+</validationRegex>
13+
</requiredProperty>
14+
</requiredProperties>
15+
16+
<fileSets>
17+
<fileSet filtered="true" packaged="true">
18+
<directory>src/main/java</directory>
19+
<includes>
20+
<include>**/*.java</include>
21+
</includes>
22+
</fileSet>
23+
</fileSets>
24+
</archetype-descriptor>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.flywaydb</groupId>
9+
<artifactId>flyway-community-db-support</artifactId>
10+
<version>${parentVersion}</version>
11+
</parent>
12+
13+
<artifactId>${artifactId}</artifactId>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.release>17</maven.compiler.release>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>${project.groupId}</groupId>
23+
<artifactId>flyway-core</artifactId>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<resources>
29+
<resource>
30+
<directory>src/main/resources</directory>
31+
<filtering>true</filtering>
32+
</resource>
33+
</resources>
34+
<plugins>
35+
<plugin>
36+
<artifactId>maven-resources-plugin</artifactId>
37+
</plugin>
38+
<plugin>
39+
<artifactId>maven-jar-plugin</artifactId>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) Red Gate Software Ltd 2010-2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.flywaydb.community.database;
17+
18+
import org.flywaydb.core.api.FlywayException;
19+
import org.flywaydb.core.extensibility.PluginMetadata;
20+
import org.flywaydb.core.internal.util.FileUtils;
21+
22+
import java.io.IOException;
23+
import java.nio.charset.StandardCharsets;
24+
25+
public class ExampleDatabaseExtension implements PluginMetadata {
26+
public String getDescription() {
27+
return "Community-contributed Example database support extension " + readVersion() + " by Redgate";
28+
}
29+
30+
public static String readVersion() {
31+
try {
32+
return FileUtils.copyToString(
33+
ExampleDatabaseExtension.class.getClassLoader().getResourceAsStream("org/flywaydb/community/database/example/version.txt"),
34+
StandardCharsets.UTF_8);
35+
} catch (IOException e) {
36+
throw new FlywayException("Unable to read extension version: " + e.getMessage(), e);
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.flywaydb.community.database.example;
2+
3+
import java.sql.Connection;
4+
import org.flywaydb.community.database.ExampleDatabaseExtension;
5+
import org.flywaydb.core.api.ResourceProvider;
6+
import org.flywaydb.core.api.configuration.Configuration;
7+
import org.flywaydb.core.internal.database.base.BaseDatabaseType;
8+
import org.flywaydb.core.internal.database.base.CommunityDatabaseType;
9+
import org.flywaydb.core.internal.database.base.Database;
10+
import org.flywaydb.core.internal.jdbc.JdbcConnectionFactory;
11+
import org.flywaydb.core.internal.jdbc.StatementInterceptor;
12+
import org.flywaydb.core.internal.parser.Parser;
13+
import org.flywaydb.core.internal.parser.ParsingContext;
14+
15+
public class ExampleDatabaseType extends BaseDatabaseType implements CommunityDatabaseType {
16+
17+
@Override
18+
public String getName() {
19+
return null;
20+
}
21+
22+
@Override
23+
public int getNullType() {
24+
return 0;
25+
}
26+
27+
@Override
28+
public boolean handlesJDBCUrl(final String url) {
29+
return false;
30+
}
31+
32+
@Override
33+
public String getDriverClass(final String url, final ClassLoader classLoader) {
34+
return null;
35+
}
36+
37+
@Override
38+
public boolean handlesDatabaseProductNameAndVersion(final String databaseProductName,
39+
final String databaseProductVersion,
40+
final Connection connection) {
41+
return false;
42+
}
43+
44+
@Override
45+
public Database createDatabase(final Configuration configuration, final JdbcConnectionFactory jdbcConnectionFactory,
46+
final StatementInterceptor statementInterceptor) {
47+
return null;
48+
}
49+
50+
@Override
51+
public Parser createParser(final Configuration configuration, final ResourceProvider resourceProvider,
52+
final ParsingContext parsingContext) {
53+
return null;
54+
}
55+
56+
@Override
57+
public String getPluginVersion(Configuration config) {
58+
return ExampleDatabaseExtension.readVersion();
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.flywaydb.community.database.example.ExampleDatabaseType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${pom.version}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
artifactId=flyway-database-example
2+
parentVersion=10.12.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
verify

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>org.flywaydb</groupId>
2323
<artifactId>flyway-parent</artifactId>
24-
<version>10.9.0</version>
24+
<version>10.12.0</version>
2525
<relativePath/>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
@@ -38,6 +38,7 @@
3838
<module>flyway-database-clickhouse</module>
3939
<module>flyway-database-oceanbase</module>
4040
<module>flyway-database-databricks</module>
41+
<module>flyway-community-db-support-archetype</module>
4142
</modules>
4243

4344
<properties>

0 commit comments

Comments
 (0)