1 Commits
Author SHA1 Message Date
Daniel SamsonandClaude Opus 4.5 6b28dca798 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>
2026-01-22 09:14:08 +00:00
8 changed files with 86 additions and 3 deletions

No files matched your search

+8 -1
View File
@@ -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/), The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project adheres to [Semantic Versioning](https://semver.org/). and this project adheres to [Semantic Versioning](https://semver.org/).
## [0.1.5] - 2026-01-22 ## [0.1.6] - 2026-01-22
### Added ### Added
- Intel Mac (x86_64) support - Intel Mac (x86_64) support
### Fixed ### Fixed
- Homebrew tap now auto-updates on release - 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 ## [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 - Jobs that fail to start now properly transition to FAILED state
- Startup errors are written to stderr.log for visibility - 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.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.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 [0.1.3]: https://github.com/samson-media/barn/releases/tag/v0.1.3
+17 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.samsonmedia</groupId> <groupId>com.samsonmedia</groupId>
<artifactId>barn</artifactId> <artifactId>barn</artifactId>
<version>0.1.5</version> <version>0.1.6</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Barn</name> <name>Barn</name>
@@ -121,6 +121,22 @@
</dependencies> </dependencies>
<build> <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> <plugins>
<!-- Compiler --> <!-- Compiler -->
<plugin> <plugin>
@@ -13,7 +13,7 @@ import picocli.CommandLine.Spec;
@Command( @Command(
name = "barn", name = "barn",
mixinStandardHelpOptions = true, mixinStandardHelpOptions = true,
version = "barn 0.1.2", versionProvider = VersionProvider.class,
description = "Cross-platform job daemon for media processing", description = "Cross-platform job daemon for media processing",
subcommands = { subcommands = {
RunCommand.class, 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", "name": "ch.qos.logback.core.status.NopStatusListener",
"allDeclaredConstructors": true, "allDeclaredConstructors": true,
@@ -2,6 +2,7 @@
"resources": { "resources": {
"includes": [ "includes": [
{"pattern": "logback.xml"}, {"pattern": "logback.xml"},
{"pattern": "version.properties"},
{"pattern": "META-INF/.*"} {"pattern": "META-INF/.*"}
] ]
}, },
+1
View File
@@ -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("${");
}
}