Skip to content

Commit

Permalink
Add app version to setup window
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesmuchene committed Jul 9, 2024
1 parent d891339 commit 5728915
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,15 @@ detekt {
config.from(file(path = "detekt.yaml"))
buildUponDefaultConfig = true
}

val versionTheRelease by tasks.registering {
description = "Write version file to resources"
doLast {
file("src/main/resources/version")
.writeText(text = "v$version")
}
}

val jar by tasks.existing(Jar::class) {
dependsOn(versionTheRelease)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogWindow
import com.charlesmuchene.prefeditor.extensions.rememberIconPainter
import com.charlesmuchene.prefeditor.resources.Version
import com.charlesmuchene.prefeditor.ui.APP_SPACING
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.intui.standalone.theme.IntUiTheme
Expand Down Expand Up @@ -59,6 +60,8 @@ fun SetupWindow(modifier: Modifier = Modifier) {
Spacer(modifier = Modifier.height(12.dp))
Text(text = title, style = Typography.h0TextStyle())
Spacer(modifier = Modifier.height(12.dp))
Text(text = Version.version, style = Typography.labelTextStyle())
Spacer(modifier = Modifier.height(12.dp))
val url = "https://www.charlesmuchene.com"
ExternalLink(
text = "Copyright © 2024 Charles Muchene",
Expand Down
27 changes: 27 additions & 0 deletions src/main/kotlin/com/charlesmuchene/prefeditor/resources/Version.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2024 Charles Muchene
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.charlesmuchene.prefeditor.resources

object Version {
private const val VERSION_FILENAME = "version"
private const val DEFAULT_VERSION = "---"

val version: String by lazy {
javaClass.classLoader.getResource(VERSION_FILENAME)?.readText() ?: DEFAULT_VERSION
}

}
1 change: 1 addition & 0 deletions src/main/resources/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.1

0 comments on commit 5728915

Please sign in to comment.