Skip to content

Commit abbff9d

Browse files
Add getPluginVersion support
1 parent 1f7ae54 commit abbff9d

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
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+
}

flyway-community-db-support-archetype/src/main/resources/archetype-resources/src/main/java/org/flywaydb/community/database/example/ExampleDatabaseType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.flywaydb.community.database.example;
22

33
import java.sql.Connection;
4+
import org.flywaydb.community.database.ExampleDatabaseExtension;
45
import org.flywaydb.core.api.ResourceProvider;
56
import org.flywaydb.core.api.configuration.Configuration;
67
import org.flywaydb.core.internal.database.base.BaseDatabaseType;
@@ -50,4 +51,9 @@ public Parser createParser(final Configuration configuration, final ResourceProv
5051
final ParsingContext parsingContext) {
5152
return null;
5253
}
54+
55+
@Override
56+
public String getPluginVersion(Configuration config) {
57+
return ExampleDatabaseExtension.readVersion();
58+
}
5359
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${pom.version}

0 commit comments

Comments
 (0)