Skip to content

Commit

Permalink
refactor(tgsql): use LibraryVersion (remove TanzawaVersion)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishidama committed Dec 20, 2023
1 parent fea47a8 commit 4faffc7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 165 deletions.
1 change: 1 addition & 0 deletions modules/tgsql/cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
dependencies {
// dependent projects
implementation project(':tgsql:core')
implementation project(':common:util')
runtimeOnly "com.tsurugidb.tsubakuro:tsubakuro-ipc:${tsubakuroVersion}"
runtimeOnly "com.tsurugidb.tsubakuro:tsubakuro-stream:${tsubakuroVersion}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.tsurugidb.console.cli.repl.jline.ReplJLineReader;
import com.tsurugidb.console.cli.repl.jline.ReplJLineTerminal;
import com.tsurugidb.console.core.ScriptRunner;
import com.tsurugidb.console.core.util.TanzawaVersion;
import com.tsurugidb.tools.common.util.LibraryVersion;
import com.tsurugidb.tsubakuro.client.ServiceClientCollector;
import com.tsurugidb.tsubakuro.util.TsubakuroVersion;

Expand All @@ -37,6 +37,8 @@
public final class Main {
private static final Logger LOG = LoggerFactory.getLogger(Main.class);

private static final String TGSQL_CORE_MODULE_NAME = "tanzawa-tgsql-core"; //$NON-NLS-1$

/**
* Execute script.
*
Expand Down Expand Up @@ -118,14 +120,15 @@ public static int execute(String... args) throws Exception {
}

private static void printVersion() {
String core = TanzawaVersion.MODULE_CORE;
String tgsqlVersion = getVersion("tgsqlVersion", () -> TanzawaVersion.getBuildVersion(core));
var tgsqlCoreVersion = getTgSqlCoreVersion();

String tgsqlVersion = getVersion("tgsqlVersion", () -> tgsqlCoreVersion.getBuildVersion().get());
System.out.println("-------------------------------------");
System.out.printf("Tsurugi SQL console %s%n", tgsqlVersion);
System.out.println("-------------------------------------");

System.out.println();
String tgsqlTimestamp = getVersion("tgsqlTimestamp", () -> TanzawaVersion.getBuildTimestamp(core));
String tgsqlTimestamp = getVersion("tgsqlTimestamp", () -> tgsqlCoreVersion.getBuildTimestamp().get().toString());
System.out.printf("Build time: %s%n", tgsqlTimestamp);

System.out.println();
Expand All @@ -138,6 +141,15 @@ private static void printVersion() {
System.out.printf("JVM: %s (%s)%n", jvmVersion, javaHome);
}

private static LibraryVersion getTgSqlCoreVersion() {
try {
return LibraryVersion.loadByName(TGSQL_CORE_MODULE_NAME, Main.class.getClassLoader());
} catch (Exception e) {
LOG.debug("getTgSqlCoreVersion error", e);
return null;
}
}

@FunctionalInterface
private interface StringSupplier {
String get() throws IOException;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 4faffc7

Please sign in to comment.