Skip to content
Draft
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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.PHONY: all
all: clean fmt test pitest build_release

VERSION := 4.2.0-inkless-SNAPSHOT
# Kafka distribution version. Source of truth is gradle.properties (project.version),
# so build_release/docker targets are correct on any checkout (main, a release
# branch, or a release tag) without manual overrides. Override with `make VERSION=...`
# if needed.
ifndef VERSION
VERSION := $(shell sed -n 's/^version=//p' gradle.properties)
endif

# Docker image settings (aligned with .github/workflows/inkless-release.yml)
REGISTRY := ghcr.io
Expand Down
40 changes: 40 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ ext {
repo = file("$rootDir/.git").isDirectory() ? Grgit.open(currentDir: project.getRootDir()) : null

commitId = determineCommitId()
inklessVersion = determineInklessVersion()

configureJavaCompiler = { name, options, projectPath ->
// -parameters generates arguments with parameter names in TestInfo#getDisplayName.
Expand Down Expand Up @@ -244,6 +245,27 @@ def determineCommitId() {
}
}

// Inkless: describe the nearest inkless-* tag (e.g. "inkless-4.2.1-0.45" at a tag,
// or "inkless-4.2.1-0.45-3-g9c3cf45" a few commits past it). This surfaces the
// git tag and the inkless increment in the baked-in version file. The increment
// lives only in tags (never in gradle.properties), so this is the only build-time
// source for it.
//
// Returned as a lazy Provider using providers.exec (the configuration-cache-safe
// API) rather than a config-time exec, and evaluated when createVersionFile runs.
// Uses the git CLI (worktree-aware) so it works in linked worktrees where Grgit's
// `repo` is null. Falls back to "unknown" on any error or missing tag.
def determineInklessVersion() {
if (project.hasProperty('inklessVersion')) {
return providers.provider { project.property('inklessVersion').toString() }
}
def described = providers.exec {
commandLine 'git', 'describe', '--tags', '--match', 'inkless-*', '--always', '--dirty'
workingDir project.rootDir
}.standardOutput.asText.map { it.trim() }
return described.map { it.isEmpty() ? "unknown" : it }.orElse("unknown")
}

/**
* For a given Project, compute a nice dash separated directory name
* to store the JUnit XML files in. E.g., Project ":connect:api" -> "connect-api"
Expand Down Expand Up @@ -1013,13 +1035,15 @@ project(':server') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -1475,13 +1499,15 @@ project(':group-coordinator:group-coordinator-api') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -1948,13 +1974,15 @@ project(':clients') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -2148,13 +2176,15 @@ project(':raft') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -2242,13 +2272,15 @@ project(':server-common') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -2301,13 +2333,15 @@ project(':storage:storage-api') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -2397,13 +2431,15 @@ project(':storage') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -2761,13 +2797,15 @@ project(':tools:tools-api') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile
outputs.cacheIf { true }

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down Expand Up @@ -3090,12 +3128,14 @@ project(':streams') {
def receiptFile = file("${layout.buildDirectory.get().asFile.path}/kafka/$buildStreamsVersionFileName")
inputs.property "commitId", commitId
inputs.property "version", version
inputs.property "inklessVersion", inklessVersion
outputs.file receiptFile

doLast {
def data = [
commitId: commitId,
version: version,
inklessVersion: inklessVersion.get(),
]

receiptFile.parentFile.mkdirs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class AppInfoParser {
private static final Logger log = LoggerFactory.getLogger(AppInfoParser.class);
private static final String VERSION;
private static final String COMMIT_ID;
// INKLESS: git-describe of the nearest inkless-* tag (tag + increment), baked in by build.gradle.
private static final String INKLESS_VERSION;

protected static final String DEFAULT_VALUE = "unknown";

Expand All @@ -48,6 +50,7 @@ public class AppInfoParser {
}
VERSION = props.getProperty("version", DEFAULT_VALUE).trim();
COMMIT_ID = props.getProperty("commitId", DEFAULT_VALUE).trim();
INKLESS_VERSION = props.getProperty("inklessVersion", DEFAULT_VALUE).trim();
}

public static String getVersion() {
Expand All @@ -58,6 +61,17 @@ public static String getCommitId() {
return COMMIT_ID;
}

// INKLESS: the inkless release increment / tag description (e.g. "inkless-4.2.1-0.45").
public static String getInklessVersion() {
return INKLESS_VERSION;
}
Comment thread
jeqo marked this conversation as resolved.

// INKLESS: " (Inkless:<version>)" suffix for --version output, or "" when the inkless
// version was not baked in (keeps upstream output/tests intact off a release build).
public static String getInklessVersionSuffix() {
return DEFAULT_VALUE.equals(INKLESS_VERSION) ? "" : " (Inkless:" + INKLESS_VERSION + ")";
}
Comment on lines +69 to +73

public static synchronized void registerAppInfo(String prefix, String id, Metrics metrics, long nowMs) {
try {
ObjectName name = new ObjectName(prefix + ":type=app-info,id=" + Sanitizer.jmxSanitize(id));
Expand Down Expand Up @@ -137,6 +151,10 @@ public AppInfo(long startTimeMs) {
this.startTimeMs = startTimeMs;
log.info("Kafka version: {}", AppInfoParser.getVersion());
log.info("Kafka commitId: {}", AppInfoParser.getCommitId());
// INKLESS: log the inkless tag/increment at startup when baked in (see build.gradle).
if (!DEFAULT_VALUE.equals(INKLESS_VERSION)) {
log.info("Inkless version: {}", INKLESS_VERSION);
}
log.info("Kafka startTimeMs: {}", startTimeMs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public void testUnregisterAppInfoUnregistersMetrics() throws JMException {
}
}

// INKLESS: without a baked kafka-version.properties on the test classpath the inkless
// version defaults to "unknown" and the --version suffix is suppressed.
@Test
public void testInklessVersionDefaultsToUnknownAndSuppressesSuffix() {
assertEquals(AppInfoParser.DEFAULT_VALUE, AppInfoParser.getInklessVersion());
assertEquals("", AppInfoParser.getInklessVersionSuffix());
}

private void registerAppInfo(Metrics metrics) throws JMException {
assertEquals(EXPECTED_COMMIT_VERSION, AppInfoParser.getCommitId());
assertEquals(EXPECTED_VERSION, AppInfoParser.getVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public static void printUsageAndExit(OptionParser parser, String message) {
}

public static void printVersionAndExit() {
System.out.println(AppInfoParser.getVersion());
// INKLESS: append the inkless tag/increment (e.g. "inkless-4.2.1-0.45") when baked in.
System.out.println(AppInfoParser.getVersion() + AppInfoParser.getInklessVersionSuffix());
Exit.exit(0);
Comment thread
jeqo marked this conversation as resolved.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public void run(
) {
String version = AppInfoParser.getVersion();
String commitId = AppInfoParser.getCommitId();
System.out.println(version + " (Commit:" + commitId + ")");
// INKLESS: also print the inkless tag/increment (e.g. "inkless-4.2.1-0.45") when baked in.
System.out.println(version + " (Commit:" + commitId + ")" + AppInfoParser.getInklessVersionSuffix());
Exit.exit(0);
Comment thread
jeqo marked this conversation as resolved.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public void testPrintHelp() {
@ClusterTest
public void testPrintVersion() {
String out = ToolsTestUtils.captureStandardOut(() -> GetOffsetShell.mainNoExit("--version"));
assertEquals(AppInfoParser.getVersion(), out);
assertEquals(AppInfoParser.getVersion() + AppInfoParser.getInklessVersionSuffix(), out);
}

private void assertExitCodeIsOne(String... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ public void testPrintVersion() {
try {
String out = ToolsTestUtils.captureStandardOut(() -> ConsumerGroupCommandOptions.fromArgs(new String[]{"--version"}));
assertEquals(0, exitProcedure.statusCode());
assertEquals(AppInfoParser.getVersion(), out);
assertEquals(AppInfoParser.getVersion() + AppInfoParser.getInklessVersionSuffix(), out);
} finally {
Exit.resetExitProcedure();
}
Expand Down
Loading