Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: derive version from gradle.properties at build time
Replace 4 hardcoded '0.1.0-SNAPSHOT' references with BuildVersion
that reads from version.properties generated at build time.

- gradle.properties: single source of truth (now 0.3.0-SNAPSHOT)
- aceclaw-core/build.gradle.kts: generates version.properties resource
- BuildVersion.java: reads version from classpath resource
- AceClawMain, RequestRouter: use BuildVersion.version()
- Release workflow already bumps gradle.properties via git-cliff

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
  • Loading branch information
xinhuagu and claude committed Mar 19, 2026
commit 1401e45a8a5ef313226ada6419633588a876cdcc
4 changes: 2 additions & 2 deletions aceclaw-cli/src/main/java/dev/aceclaw/cli/AceClawMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
@Command(
name = "aceclaw",
mixinStandardHelpOptions = true,
version = "aceclaw 0.1.0-SNAPSHOT",
version = "aceclaw (version loaded at runtime)",
description = "AI coding agent — Device as Agent",
subcommands = { AceClawMain.DaemonCommand.class, AceClawMain.ModelsCommand.class }
)
public final class AceClawMain implements Runnable {

static final String VERSION = "0.1.0-SNAPSHOT";
static final String VERSION = dev.aceclaw.core.BuildVersion.version();
private static final Path CODEX_AUTH_FILE = Path.of(
System.getProperty("user.home"), ".codex", "auth.json");

Expand Down
16 changes: 16 additions & 0 deletions aceclaw-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// aceclaw-core: Agent loop, task planner, tool system, LLM client abstractions, agent teams

// Generate version.properties from gradle.properties at build time
tasks.register("generateVersionProperties") {
val outputDir = layout.buildDirectory.dir("generated/resources/version")
outputs.dir(outputDir)
doLast {
val dir = outputDir.get().asFile
dir.mkdirs()
dir.resolve("version.properties").writeText(
"# Generated by build\nversion=${project.version}\ngroup=${project.group}\n"
)
}
}

sourceSets["main"].resources.srcDir(layout.buildDirectory.dir("generated/resources/version"))
tasks.named("processResources") { dependsOn("generateVersionProperties") }

dependencies {
api(project(":aceclaw-sdk"))
implementation(project(":aceclaw-infra"))
Expand Down
50 changes: 50 additions & 0 deletions aceclaw-core/src/main/java/dev/aceclaw/core/BuildVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package dev.aceclaw.core;

import java.io.InputStream;
import java.util.Properties;

/**
* Reads the build version from {@code version.properties} generated at build time.
* Single source of truth: {@code gradle.properties} → build → classpath resource.
*/
public final class BuildVersion {

private static final String FALLBACK = "dev";
private static volatile String cachedVersion;

private BuildVersion() {}

/**
* Returns the project version (e.g. "0.3.0-SNAPSHOT" or "0.3.0").
* Falls back to "dev" if the resource is missing (IDE run without build).
*/
public static String version() {
String v = cachedVersion;
if (v != null) return v;
synchronized (BuildVersion.class) {
if (cachedVersion != null) return cachedVersion;
cachedVersion = loadVersion();
return cachedVersion;
}
}

/**
* Returns a display string like "AceClaw v0.3.0-SNAPSHOT".
*/
public static String displayVersion() {
return "AceClaw v" + version();
}

private static String loadVersion() {
try (InputStream is = BuildVersion.class.getClassLoader()
.getResourceAsStream("version.properties")) {
if (is == null) return FALLBACK;
Properties props = new Properties();
props.load(is);
String v = props.getProperty("version", FALLBACK);
return v.isBlank() ? FALLBACK : v;
} catch (Exception e) {
return FALLBACK;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private Object handleHealthStatus(JsonNode params) {

result.put("activeSessions", sessionManager.sessionCount());
result.put("timestamp", Instant.now().toString());
result.put("version", "0.1.0-SNAPSHOT");
result.put("version", dev.aceclaw.core.BuildVersion.version());
var m = modelName;
if (m != null) {
result.put("model", m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void testHealthStatus() throws Exception {
var result = response.get("result");
assertThat(result.get("status").asText()).isEqualTo("healthy");
assertThat(result.has("timestamp")).isTrue();
assertThat(result.get("version").asText()).isEqualTo("0.1.0-SNAPSHOT");
assertThat(result.get("version").asText()).isNotBlank();
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=dev.aceclaw
version=0.1.0
version=0.3.0-SNAPSHOT
Loading