File tree Expand file tree Collapse file tree 4 files changed +27
-1
lines changed
src/main/kotlin/com/bazel_diff/cli Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,6 @@ run -c opt --show_loading_progress=false --show_progress=false --ui_event_filter
22run:verbose -c dbg --show_loading_progress=true --show_progress=true --ui_event_filters=info,error,debug
33# https://github.com/mockito/mockito/issues/1879
44test --sandbox_tmpfs_path=/tmp
5+
6+ # To allow stamping git tag for version.
7+ build --workspace_status_command=$(pwd)/workspace_status.sh
Original file line number Diff line number Diff line change @@ -8,6 +8,17 @@ config_setting(
88 },
99)
1010
11+ genrule (
12+ name = "version_file" ,
13+ srcs = [],
14+ outs = ["version" ],
15+ cmd_bash = """
16+ version_tag=$$(grep ^STABLE_GIT_TAG bazel-out/stable-status.txt | cut -d' ' -f2); \
17+ printf '%s' $$version_tag > $@;
18+ """ ,
19+ stamp = 1 ,
20+ )
21+
1122java_binary (
1223 name = "bazel-diff" ,
1324 jvm_flags = select ({
@@ -22,6 +33,7 @@ java_binary(
2233kt_jvm_library (
2334 name = "cli-lib" ,
2435 srcs = glob (["src/main/kotlin/**/*.kt" ]),
36+ resources = [":version_file" ],
2537 deps = [
2638 "@bazel_diff_maven//:com_google_code_gson_gson" ,
2739 "@bazel_diff_maven//:com_google_guava_guava" ,
Original file line number Diff line number Diff line change 11package com.bazel_diff.cli
22
33import picocli.CommandLine.IVersionProvider
4+ import java.io.BufferedReader
5+ import java.io.InputStreamReader
46
57class VersionProvider : IVersionProvider {
68 override fun getVersion (): Array <String > {
7- return arrayOf(" 7.0.0" )
9+ val classLoader = this ::class .java.classLoader
10+ val inputStream = classLoader.getResourceAsStream(" cli/version" )
11+ ? : throw IllegalArgumentException (" unknown version as version file not found in resources" )
12+
13+ val version = BufferedReader (InputStreamReader (inputStream)).use { it.readText().trim() }
14+ return arrayOf(version)
815 }
916}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Get the current Git tag or default to the commit hash
4+ echo " STABLE_GIT_TAG $( git describe --tags --abbrev=0 2> /dev/null || git rev-parse HEAD) "
You can’t perform that action at this time.
0 commit comments