Archived
feat: dynamic version from Maven resource filtering
- Add VersionProvider class that reads version from version.properties - Enable Maven resource filtering for version.properties - Version is now automatically synced with pom.xml Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a72dfd2e4c
commit
6b28dca798
8 files changed
+86
-3
No files matched your search
+8
-1
@@ -5,13 +5,19 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [0.1.5] - 2026-01-22
|
||||
## [0.1.6] - 2026-01-22
|
||||
|
||||
### Added
|
||||
- Intel Mac (x86_64) support
|
||||
|
||||
### Fixed
|
||||
- Homebrew tap now auto-updates on release
|
||||
- Version string now matches release tag
|
||||
|
||||
## [0.1.5] - 2026-01-22
|
||||
|
||||
### Fixed
|
||||
- Version string was hardcoded (broken release)
|
||||
|
||||
## [0.1.4] - 2026-01-22
|
||||
|
||||
@@ -56,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
- Jobs that fail to start now properly transition to FAILED state
|
||||
- Startup errors are written to stderr.log for visibility
|
||||
|
||||
[0.1.6]: https://github.com/samson-media/barn/releases/tag/v0.1.6
|
||||
[0.1.5]: https://github.com/samson-media/barn/releases/tag/v0.1.5
|
||||
[0.1.4]: https://github.com/samson-media/barn/releases/tag/v0.1.4
|
||||
[0.1.3]: https://github.com/samson-media/barn/releases/tag/v0.1.3
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.samsonmedia</groupId>
|
||||
<artifactId>barn</artifactId>
|
||||
<version>0.1.5</version>
|
||||
<version>0.1.6</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Barn</name>
|
||||
@@ -121,6 +121,22 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>version.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<excludes>
|
||||
<exclude>version.properties</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<!-- Compiler -->
|
||||
<plugin>
|
||||
|
||||
@@ -13,7 +13,7 @@ import picocli.CommandLine.Spec;
|
||||
@Command(
|
||||
name = "barn",
|
||||
mixinStandardHelpOptions = true,
|
||||
version = "barn 0.1.2",
|
||||
versionProvider = VersionProvider.class,
|
||||
description = "Cross-platform job daemon for media processing",
|
||||
subcommands = {
|
||||
RunCommand.class,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.samsonmedia.barn.cli;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import picocli.CommandLine.IVersionProvider;
|
||||
|
||||
/**
|
||||
* Provides version information from the version.properties resource file.
|
||||
*
|
||||
* <p>The version is injected at build time via Maven resource filtering.
|
||||
*/
|
||||
public final class VersionProvider implements IVersionProvider {
|
||||
|
||||
@Override
|
||||
public String[] getVersion() {
|
||||
String version = "unknown";
|
||||
try (InputStream is = getClass().getResourceAsStream("/version.properties")) {
|
||||
if (is != null) {
|
||||
Properties props = new Properties();
|
||||
props.load(is);
|
||||
version = props.getProperty("version", "unknown");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Fall back to unknown
|
||||
}
|
||||
return new String[]{"barn " + version};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
[
|
||||
{
|
||||
"name": "com.samsonmedia.barn.cli.VersionProvider",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "ch.qos.logback.core.status.NopStatusListener",
|
||||
"allDeclaredConstructors": true,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"resources": {
|
||||
"includes": [
|
||||
{"pattern": "logback.xml"},
|
||||
{"pattern": "version.properties"},
|
||||
{"pattern": "META-INF/.*"}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
version=${project.version}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.samsonmedia.barn.cli;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class VersionProviderTest {
|
||||
|
||||
@Test
|
||||
void getVersion_shouldReturnVersionFromProperties() {
|
||||
// Arrange
|
||||
var provider = new VersionProvider();
|
||||
|
||||
// Act
|
||||
String[] version = provider.getVersion();
|
||||
|
||||
// Assert
|
||||
assertThat(version).hasSize(1);
|
||||
assertThat(version[0]).startsWith("barn ");
|
||||
assertThat(version[0]).doesNotContain("unknown");
|
||||
assertThat(version[0]).doesNotContain("${");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user