Skip to content
Snippets Groups Projects
Commit 0892c586 authored by Sebastian's avatar Sebastian
Browse files

Generate Kotlin code for BuildData instead of Java

parent d64b20cf
No related branches found
No related tags found
1 merge request!90Add plugin in buildSrc to provide some build metadata to app at runtime
Pipeline #9045 passed
......@@ -68,7 +68,7 @@ open class GenerateBuildDataSourceTask : AbstractBuildDataTask() {
path = path.resolve(parts[i])
}
Files.createDirectories(path)
val file = path.resolve("$className.java")
val file = path.resolve("$className.kt")
val content = createSource(
packageName, className, version,
commitTime, gitHash, gitBranch
......@@ -97,43 +97,13 @@ open class GenerateBuildDataSourceTask : AbstractBuildDataTask() {
gitBranch: String,
) = FileBuilder().apply {
line("// this file is generated, do not edit")
// // this file is generated, do not edit
// package org.briarproject.briar.desktop;
//
// public class BuildData {
line("// this file is generated, do not edit")
line("package $packageName;")
line()
line("public class $className {")
line()
// public static String getVersion() {
// return "0.1";
// }
line(" public static String getVersion() {")
line(" return \"$version\";")
line(" }")
line()
// public static long getGitTime() {
// return 1641645802088L;
// }
line(" public static long getGitTime() {")
line(" return " + gitTime + "L;")
line(" }")
line()
// public static long getGitHash() {
// return "749dda081c3e7862050255817bc239b9255b1582";
// }
line(" public static String getGitHash() {")
line(" return \"$gitHash\";")
line(" }")
line()
// public static String getGitBranch() {
// return "master";
// }
line(" public static String getGitBranch() {")
line(" return \"$gitBranch\";")
line(" }")
line("package $packageName")
line()
line("object $className {")
line(" val VERSION = \"$version\"")
line(" val GIT_TIME = ${gitTime}L")
line(" val GIT_HASH = \"$gitHash\"")
line(" val GIT_BRANCH = \"$gitBranch\"")
line("}")
}.toString()
}
......@@ -74,13 +74,13 @@ private class Main : CliktCommand(
LogUtils.setupLogging(level)
val buildTime = Instant.ofEpochMilli(BuildData.getGitTime()).atZone(ZoneId.systemDefault()).toLocalDateTime()
val buildTime = Instant.ofEpochMilli(BuildData.GIT_TIME).atZone(ZoneId.systemDefault()).toLocalDateTime()
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
LOG.info { "This is briar-desktop version ${BuildData.getVersion()}" }
LOG.info { "This is briar-desktop version ${BuildData.VERSION}" }
LOG.info { "Build info:" }
LOG.info { " Git hash ${BuildData.getGitHash()}" }
LOG.info { " Git hash ${BuildData.GIT_HASH}" }
LOG.info { " Commit time ${formatter.format(buildTime)}" }
LOG.info { " Branch ${BuildData.getGitBranch()}" }
LOG.info { " Branch ${BuildData.GIT_BRANCH}" }
val dataDir = getDataDir()
val app =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment