Skip to content

Commit b2e2ef8

Browse files
committed
chore: store pom version as resource property and use it for capability template
1 parent adf56d2 commit b2e2ef8

File tree

62 files changed

+93
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+93
-63
lines changed

pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@
164164
</dependencies>
165165

166166
<build>
167+
<resources>
168+
<resource>
169+
<directory>src/main/resources</directory>
170+
<filtering>false</filtering>
171+
</resource>
172+
<resource>
173+
<directory>src/main/resources</directory>
174+
<filtering>true</filtering>
175+
<includes>
176+
<include>version.properties</include>
177+
</includes>
178+
</resource>
179+
</resources>
167180
<plugins>
168181
<plugin>
169182
<groupId>org.apache.maven.plugins</groupId>

src/main/java/io/naftiko/Cli.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@Command(
2222
name = "naftiko",
2323
mixinStandardHelpOptions = true,
24-
version = "1.0.0-alpha1",
24+
version = "1.0.0-alpha2",
2525
description = "Naftiko CLI",
2626
subcommands = {CreateCommand.class, ValidateCommand.class}
2727
)

src/main/java/io/naftiko/cli/FileGenerator.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,22 @@
2424
import java.nio.file.Paths;
2525
import java.util.HashMap;
2626
import java.util.Map;
27+
import java.util.Properties;
2728

2829
public class FileGenerator {
30+
private static final String VERSION;
31+
32+
static {
33+
try (InputStream versionStream = FileGenerator.class.getClassLoader().getResourceAsStream("version.properties")) {
34+
Properties props = new Properties();
35+
props.load(versionStream);
36+
String v = props.getProperty("version");
37+
VERSION = v.endsWith("-SNAPSHOT") ? v.substring(0, v.length() - "-SNAPSHOT".length()) : v;
38+
} catch (IOException e) {
39+
throw new ExceptionInInitializerError("Could not load version.properties: " + e.getMessage());
40+
}
41+
}
42+
2943
public static void generateCapabilityFile(String capabilityName, FileFormat format, String baseUri, String port) throws IOException {
3044
String templatePath = "templates/capability." + format.pathName + ".mustache";
3145
String outputFileName = capabilityName + ".naftiko." + format.pathName;
@@ -41,6 +55,7 @@ public static void generateCapabilityFile(String capabilityName, FileFormat form
4155
// Render template and write file.
4256
Template mustache = Mustache.compiler().compile(new InputStreamReader(templateStream));
4357
Map<String, Object> scope = new HashMap<>();
58+
scope.put("version", VERSION);
4459
scope.put("capabilityName", capabilityName);
4560
scope.put("port", port);
4661
scope.put("baseUri", baseUri);

src/main/resources/META-INF/native-image/resource-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"resources": [
33
{ "pattern": "schemas/.*" },
44
{ "pattern": "templates/.*" },
5-
{ "pattern": "jsv-messages.*\\.properties" }
5+
{ "pattern": "jsv-messages.*\\.properties" },
6+
{ "pattern": "version\\.properties" }
67
]
78
}

src/main/resources/schemas/examples/cir.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=../naftiko-schema.json
22
---
3-
naftiko: "1.0.0-alpha1"
3+
naftiko: "1.0.0-alpha2"
44

55
info:
66
label: "CIR Time Export"

src/main/resources/schemas/examples/html-consumes-rest-adapter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=../naftiko-schema.json
22
---
3-
naftiko: "1.0.0-alpha1"
3+
naftiko: "1.0.0-alpha2"
44
info:
55
label: "HTML Catalog Reader"
66
description: "Extracts product rows from an HTML table"

src/main/resources/schemas/examples/markdown-consumes-rest-adapter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=../naftiko-schema.json
22
---
3-
naftiko: "1.0.0-alpha1"
3+
naftiko: "1.0.0-alpha2"
44
info:
55
label: "Markdown Feature Reader"
66
description: "Extracts feature rows from a markdown table"

src/main/resources/schemas/examples/multi-consumes-rest-adapter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=../naftiko-schema.json
22
---
3-
naftiko: "1.0.0-alpha1"
3+
naftiko: "1.0.0-alpha2"
44
info:
55
label: "Sample Capability"
66
description: "This is a sample capability specification to demonstrate the features of Naftiko"

src/main/resources/schemas/examples/multi-consumes-with-auth.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=../naftiko-schema.json
22
---
3-
naftiko: "1.0.0-alpha1"
3+
naftiko: "1.0.0-alpha2"
44
info:
55
label: passtru
66
description: Example pass tru capability

src/main/resources/schemas/examples/no-adapter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=../naftiko-schema.json
22
---
3-
naftiko: "1.0.0-alpha1"
3+
naftiko: "1.0.0-alpha2"
44
info:
55
label: "Sample Capability"
66
description: "This is a sample capability specification to demonstrate the features of Naftiko"

0 commit comments

Comments
 (0)