From f6f5a9285669f76cbdd92ebaeb6b1f434e6f859d Mon Sep 17 00:00:00 2001 From: LTFan Date: Sun, 18 Feb 2024 14:39:29 +0800 Subject: [PATCH] build: add buildSrc --- build.gradle.kts | 151 +++++++----------- buildSrc/build.gradle.kts | 22 +++ buildSrc/settings.gradle.kts | 39 +++++ buildSrc/src/main/kotlin/Output.kt | 26 +++ buildSrc/src/main/kotlin/Properties.kt | 96 +++++++++++ buildSrc/src/main/kotlin/RootProject.kt | 25 +++ buildSrc/src/main/kotlin/SystemEnvironment.kt | 27 ++++ compose-app/build.gradle.kts | 36 ++--- keycloak-spi/build.gradle.kts | 13 +- server/build.gradle.kts | 13 +- 10 files changed, 305 insertions(+), 143 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/settings.gradle.kts create mode 100644 buildSrc/src/main/kotlin/Output.kt create mode 100644 buildSrc/src/main/kotlin/Properties.kt create mode 100644 buildSrc/src/main/kotlin/RootProject.kt create mode 100644 buildSrc/src/main/kotlin/SystemEnvironment.kt diff --git a/build.gradle.kts b/build.gradle.kts index f76416b..dd6f292 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,13 +16,10 @@ * with Fhraise. If not, see . */ -import org.gradle.internal.os.OperatingSystem +import xyz.xfqlittlefan.fhraise.buildsrc.* import java.io.ByteArrayOutputStream -import java.util.* plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader alias(libs.plugins.kotlinMultiplatform) apply false alias(libs.plugins.kotlinJvm) apply false alias(libs.plugins.kotlinSerialization) apply false @@ -41,37 +38,7 @@ allprojects { apply(plugin = "kotlinx-atomicfu") } -val versionPropertiesFile = file("version.properties") -val versionProperties = Properties().apply { - with(versionPropertiesFile) { - if (exists()) { - load(inputStream()) - } - } -} - -var devVer: String by versionProperties -var commitSha: String by versionProperties -var reversion: String by versionProperties -var version: String by versionProperties - -val buildNumberPropertiesFile = file("build-number.properties") -val buildNumberProperties = Properties().apply { - with(buildNumberPropertiesFile) { - if (exists()) { - load(inputStream()) - } - } -} - -var buildNumber: String by buildNumberProperties - -val String.outputDirectory - get() = rootProject.layout.buildDirectory.dir("outputs/binaries/$version.$buildNumber/$this") - -val isLinux = OperatingSystem.current().isLinux -val isWindows = OperatingSystem.current().isWindows -val arch: String = System.getProperty("os.arch") +RootProject.project = rootProject tasks.register("updateDevVer") { group = "versioning" @@ -84,9 +51,8 @@ tasks.register("updateDevVer") { standardOutput = stream isIgnoreExitValue = true } - devVer = if (result.exitValue == 0) stream.toString().trim().substringAfter("dev") else "0.0" - versionProperties.store(versionPropertiesFile.outputStream(), null) - logger.lifecycle("devVer: $devVer") + projectDevVer = if (result.exitValue == 0) stream.toString().trim().substringAfter("dev") else "0.0" + logger.lifecycle("devVer: $projectDevVer") } } @@ -100,9 +66,8 @@ tasks.register("updateCommitSha") { commandLine = listOf("git", "rev-parse", "--short", "HEAD") standardOutput = stream } - commitSha = stream.toString().trim() - versionProperties.store(versionPropertiesFile.outputStream(), null) - logger.lifecycle("commitSha: $commitSha") + projectCommitSha = stream.toString().trim() + logger.lifecycle("commitSha: $projectCommitSha") } } @@ -113,13 +78,12 @@ tasks.register("updateReversion") { doLast { val stream = ByteArrayOutputStream() val result = exec { - commandLine = listOf("git", "rev-list", "--count", "dev$devVer..main") + commandLine = listOf("git", "rev-list", "--count", "dev$projectDevVer..main") standardOutput = stream isIgnoreExitValue = true } - reversion = if (result.exitValue == 0) stream.toString().trim() else "0" - versionProperties.store(versionPropertiesFile.outputStream(), null) - logger.lifecycle("reversion: $reversion") + projectReversion = if (result.exitValue == 0) stream.toString().trim().toInt() else 0 + logger.lifecycle("reversion: $projectReversion") } } @@ -130,9 +94,8 @@ tasks.register("updateVersion") { dependsOn("updateDevVer", "updateCommitSha", "updateReversion") doLast { - version = "$devVer.$reversion+$commitSha" - versionProperties.store(versionPropertiesFile.outputStream(), null) - logger.lifecycle("version: $version") + version = "$projectDevVer.$projectReversion+$projectCommitSha" + logger.lifecycle("version: $projectVersion") } } @@ -141,13 +104,8 @@ tasks.register("increaseBuildNumber") { description = "Increase the build number" doLast { - buildNumber = try { - (buildNumber.toInt() + 1).toString() - } catch (e: Throwable) { - "1" - } - buildNumberProperties.store(buildNumberPropertiesFile.outputStream(), null) - logger.lifecycle("buildNumber: $buildNumber") + projectBuildNumber += 1 + logger.lifecycle("buildNumber: $projectBuildNumber") } } @@ -166,7 +124,7 @@ tasks.register("releaseAndroidApp") { doLast { val apkDir = file(project(":compose-app").layout.buildDirectory.dir("outputs/apk/release")) - val outputDir = file("android".outputDirectory) + val outputDir = file(outputDirectoryOf("android")) apkDir.copyRecursively(outputDir, overwrite = true) logger.lifecycle("output directory: ${outputDir.absolutePath}") } @@ -176,7 +134,7 @@ tasks.register("releaseLinuxApp") { group = "project build" description = "Build the Linux release executable" - if (!isLinux) { + if (!SystemEnvironment.isLinux) { enabled = false } @@ -187,7 +145,7 @@ tasks.register("releaseTarLinuxApp") { group = "project build" description = "Build the Linux release tar" - if (!isLinux) { + if (!SystemEnvironment.isLinux) { enabled = false } @@ -195,19 +153,19 @@ tasks.register("releaseTarLinuxApp") { archiveBaseName = "fhraise" archiveAppendix = "linux" - archiveVersion = "$version.$buildNumber" - archiveClassifier = arch + archiveVersion = "$projectVersion.$projectBuildNumber" + archiveClassifier = SystemEnvironment.arch archiveExtension = "tar" compression = Compression.GZIP - destinationDirectory = file("linux-tar".outputDirectory) - from(file("desktop/main-release/app/Fhraise".outputDirectory)) + destinationDirectory = file(outputDirectoryOf("linux-tar")) + from(file(outputDirectoryOf("desktop/main-release/app/Fhraise"))) } tasks.register("releaseWindowsApp") { group = "project build" description = "Build the Windows release executable" - if (!isWindows) { + if (!SystemEnvironment.isWindows) { enabled = false } @@ -218,7 +176,7 @@ tasks.register("releaseZipWindowsApp") { group = "project build" description = "Build the Windows release zip" - if (!isWindows) { + if (!SystemEnvironment.isWindows) { enabled = false } @@ -226,20 +184,20 @@ tasks.register("releaseZipWindowsApp") { archiveBaseName = "fhraise" archiveAppendix = "windows" - archiveVersion = "$version.$buildNumber" - archiveClassifier = arch + archiveVersion = "$projectVersion.$projectBuildNumber" + archiveClassifier = SystemEnvironment.arch archiveExtension = "zip" - destinationDirectory = file("windows-zip".outputDirectory) - from(file("desktop/main-release/app/Fhraise".outputDirectory)) + destinationDirectory = file(outputDirectoryOf("windows-zip")) + from(file(outputDirectoryOf("desktop/main-release/app/Fhraise"))) } tasks.register("releaseDesktopApp") { group = "project build" description = "Build the desktop release" - if (isLinux) { + if (SystemEnvironment.isLinux) { dependsOn("releaseLinuxApp") - } else if (isWindows) { + } else if (SystemEnvironment.isWindows) { dependsOn("releaseWindowsApp") } } @@ -248,9 +206,9 @@ tasks.register("releaseArchiveDesktopApp") { group = "project build" description = "Build the desktop release archive" - if (isLinux) { + if (SystemEnvironment.isLinux) { dependsOn("releaseTarLinuxApp") - } else if (isWindows) { + } else if (SystemEnvironment.isWindows) { dependsOn("releaseZipWindowsApp") } } @@ -262,7 +220,7 @@ tasks.register("releaseWebApp") { dependsOn("compose-app:wasmJsBrowserProductionWebpack") doLast { - logger.lifecycle("output directory: ${file("web".outputDirectory).absolutePath}") + logger.lifecycle("output directory: ${file(outputDirectoryOf("web")).absolutePath}") } } @@ -274,11 +232,11 @@ tasks.register("releaseTarWebApp") { archiveBaseName = "fhraise" archiveAppendix = "web" - archiveVersion = "$version.$buildNumber" + archiveVersion = "$projectVersion.$projectBuildNumber" archiveExtension = "tar" compression = Compression.GZIP - destinationDirectory = file("web-tar".outputDirectory) - from(file("web".outputDirectory)) + destinationDirectory = file(outputDirectoryOf("web-tar")) + from(file(outputDirectoryOf("web"))) } tasks.register("releaseServer") { @@ -289,8 +247,8 @@ tasks.register("releaseServer") { doLast { val jar = file(project(":server").layout.buildDirectory.file("libs/server-all.jar")) - val outputDir = file("server".outputDirectory) - jar.copyTo(outputDir.resolve("fhraise-server-$version.$buildNumber.jar"), overwrite = true) + val outputDir = file(outputDirectoryOf("server")) + jar.copyTo(outputDir.resolve("fhraise-server-$projectVersion.$projectBuildNumber.jar"), overwrite = true) logger.lifecycle("output directory: ${outputDir.absolutePath}") } } @@ -302,7 +260,7 @@ tasks.register("ciVersioning") { dependsOn("updateVersion") doLast { - val outputVersion = "v${version.substringBefore('+')}" + val outputVersion = "v${projectVersion.substringBefore('+')}" file(System.getenv("GITHUB_OUTPUT")).writeText("version=$outputVersion") logger.lifecycle("Wrote version to GitHub output: $outputVersion") } @@ -316,20 +274,24 @@ tasks.register("ciReleaseLinuxApp") { doLast { val assetsDir = file(layout.buildDirectory.dir("assets")) - file("android".outputDirectory).listFiles()?.filter { it.name.endsWith(".apk") }?.forEach { file -> + file(outputDirectoryOf("android")).listFiles()?.filter { it.name.endsWith(".apk") }?.forEach { file -> file.name.substringAfter("compose-app-").substringBefore("-release").let { - file.copyTo(assetsDir.resolve("fhraise-android-$version.$buildNumber-$it.apk"), overwrite = true) + file.copyTo( + assetsDir.resolve("fhraise-android-$projectVersion.$projectBuildNumber-$it.apk"), overwrite = true + ) } } - file("desktop/main-release/deb".outputDirectory).listFiles()?.first()?.copyTo( - assetsDir.resolve("fhraise-linux-$version.$buildNumber-$arch.deb"), overwrite = true + file(outputDirectoryOf("desktop/main-release/deb")).listFiles()?.first()?.copyTo( + assetsDir.resolve("fhraise-linux-$projectVersion.$projectBuildNumber-${SystemEnvironment.arch}.deb"), + overwrite = true ) - file("desktop/main-release/rpm".outputDirectory).listFiles()?.first()?.copyTo( - assetsDir.resolve("fhraise-linux-$version.$buildNumber-$arch.rpm"), overwrite = true + file(outputDirectoryOf("desktop/main-release/rpm")).listFiles()?.first()?.copyTo( + assetsDir.resolve("fhraise-linux-$projectVersion.$projectBuildNumber-${SystemEnvironment.arch}.rpm"), + overwrite = true ) - file("linux-tar".outputDirectory).copyRecursively(assetsDir, overwrite = true) - file("web-tar".outputDirectory).copyRecursively(assetsDir, overwrite = true) - file("server".outputDirectory).copyRecursively(assetsDir, overwrite = true) + file(outputDirectoryOf("linux-tar")).copyRecursively(assetsDir, overwrite = true) + file(outputDirectoryOf("web-tar")).copyRecursively(assetsDir, overwrite = true) + file(outputDirectoryOf("server")).copyRecursively(assetsDir, overwrite = true) } } @@ -341,9 +303,10 @@ tasks.register("ciReleaseWindowsApp") { doLast { val assetsDir = file(layout.buildDirectory.dir("assets")) - file("windows-zip".outputDirectory).copyRecursively(assetsDir, overwrite = true) - file("desktop/main-release/msi".outputDirectory).listFiles()?.first()?.copyTo( - assetsDir.resolve("fhraise-windows-$version.$buildNumber-$arch.msi"), overwrite = true + file(outputDirectoryOf("windows-zip")).copyRecursively(assetsDir, overwrite = true) + file(outputDirectoryOf("desktop/main-release/msi")).listFiles()?.first()?.copyTo( + assetsDir.resolve("fhraise-windows-$projectVersion.$projectBuildNumber-${SystemEnvironment.arch}.msi"), + overwrite = true ) } } @@ -352,9 +315,9 @@ tasks.register("ciReleaseApp") { group = "ci" description = "Build the release app" - if (isLinux) { + if (SystemEnvironment.isLinux) { dependsOn("ciReleaseLinuxApp") - } else if (isWindows) { + } else if (SystemEnvironment.isWindows) { dependsOn("ciReleaseWindowsApp") } } @@ -410,7 +373,7 @@ tasks.register("installReleaseAndroidApp") { dependsOn("releaseAndroidApp") doLast { - val apk = file("android".outputDirectory).listFiles()!!.first { it.name.endsWith(".apk") }!! + val apk = file(outputDirectoryOf("android")).listFiles()!!.first { it.name.endsWith(".apk") }!! val cmd = mutableListOf("adb") if (hasProperty("device")) { cmd.add("-s") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..a1b56ab --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,22 @@ +/* + * This file is part of Fhraise. + * Copyright (c) 2024 HSAS Foodies. All Rights Reserved. + * + * Fhraise is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Fhraise is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with Fhraise. If not, see . + */ + +plugins { + alias(libs.plugins.kotlinJvm) + `kotlin-dsl` +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..4f794a6 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,39 @@ +/* + * This file is part of Fhraise. + * Copyright (c) 2024 HSAS Foodies. All Rights Reserved. + * + * Fhraise is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Fhraise is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with Fhraise. If not, see . + */ + +rootProject.name = "buildSrc" + +pluginManagement { + repositories { + google() + gradlePluginPortal() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } + } +} diff --git a/buildSrc/src/main/kotlin/Output.kt b/buildSrc/src/main/kotlin/Output.kt new file mode 100644 index 0000000..703ca27 --- /dev/null +++ b/buildSrc/src/main/kotlin/Output.kt @@ -0,0 +1,26 @@ +/* + * This file is part of Fhraise. + * Copyright (c) 2024 HSAS Foodies. All Rights Reserved. + * + * Fhraise is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Fhraise is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with Fhraise. If not, see . + */ + +package xyz.xfqlittlefan.fhraise.buildsrc + +import org.gradle.api.Project +import org.gradle.api.file.Directory +import org.gradle.api.provider.Provider + +fun Project.outputDirectoryOf(target: String): Provider = + rootProject.layout.buildDirectory.dir("outputs/binaries/$projectVersion.$projectBuildNumber/$target") diff --git a/buildSrc/src/main/kotlin/Properties.kt b/buildSrc/src/main/kotlin/Properties.kt new file mode 100644 index 0000000..7825090 --- /dev/null +++ b/buildSrc/src/main/kotlin/Properties.kt @@ -0,0 +1,96 @@ +/* + * This file is part of Fhraise. + * Copyright (c) 2024 HSAS Foodies. All Rights Reserved. + * + * Fhraise is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Fhraise is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with Fhraise. If not, see . + */ + +package xyz.xfqlittlefan.fhraise.buildsrc + +import org.gradle.kotlin.dsl.provideDelegate +import java.io.File +import java.util.* +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KProperty + +open class BuildProperties(private val file: File) : Properties(), ReadWriteProperty { + init { + with(file) { + if (exists()) { + load(inputStream()) + } + } + } + + private fun save() = with(file) { store(outputStream(), null) } + + override fun getValue(thisRef: Any?, property: KProperty<*>): String? = getProperty(property.name, null) + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) { + setProperty(property.name, value) + save() + } + + operator fun invoke(defaultValue: String) = invoke(defaultValue, { it }, { it }) + + operator fun invoke(defaultValue: Int) = invoke(defaultValue, String::toInt, Int::toString) + + inline operator fun invoke( + defaultValue: V, crossinline transform: (String) -> V, crossinline reverse: (V) -> String + ) = object : ReadWriteProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>) = + this@BuildProperties.getValue(thisRef, property)?.let(transform) ?: defaultValue + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: V) = + this@BuildProperties.setValue(thisRef, property, reverse(value)) + } +} + +val versionProperties by lazy { BuildProperties(RootProject.project.file("version.properties")) } +val buildNumberProperties by lazy { BuildProperties(RootProject.project.file("build-number.properties")) } + +private var devVer by versionProperties("0.1") +var projectDevVer + get() = devVer + set(value) { + devVer = value + } + +private var commitSha by versionProperties("0000000") +var projectCommitSha + get() = commitSha + set(value) { + commitSha = value + } + +private var reversion by versionProperties(0) +var projectReversion + get() = reversion + set(value) { + reversion = value + } + +private var version by versionProperties("0.1.0") +var projectVersion + get() = version + set(value) { + version = value + } + +private var buildNumber by buildNumberProperties(1) +var projectBuildNumber + get() = buildNumber + set(value) { + buildNumber = value + } diff --git a/buildSrc/src/main/kotlin/RootProject.kt b/buildSrc/src/main/kotlin/RootProject.kt new file mode 100644 index 0000000..12f65dd --- /dev/null +++ b/buildSrc/src/main/kotlin/RootProject.kt @@ -0,0 +1,25 @@ +/* + * This file is part of Fhraise. + * Copyright (c) 2024 HSAS Foodies. All Rights Reserved. + * + * Fhraise is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Fhraise is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with Fhraise. If not, see . + */ + +package xyz.xfqlittlefan.fhraise.buildsrc + +import org.gradle.api.Project + +object RootProject { + lateinit var project: Project +} diff --git a/buildSrc/src/main/kotlin/SystemEnvironment.kt b/buildSrc/src/main/kotlin/SystemEnvironment.kt new file mode 100644 index 0000000..93806a8 --- /dev/null +++ b/buildSrc/src/main/kotlin/SystemEnvironment.kt @@ -0,0 +1,27 @@ +/* + * This file is part of Fhraise. + * Copyright (c) 2024 HSAS Foodies. All Rights Reserved. + * + * Fhraise is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Fhraise is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with Fhraise. If not, see . + */ + +package xyz.xfqlittlefan.fhraise.buildsrc + +import org.gradle.internal.os.OperatingSystem + +object SystemEnvironment { + val isLinux = OperatingSystem.current().isLinux + val isWindows = OperatingSystem.current().isWindows + val arch: String = System.getProperty("os.arch") +} diff --git a/compose-app/build.gradle.kts b/compose-app/build.gradle.kts index bb8d04b..3739daf 100644 --- a/compose-app/build.gradle.kts +++ b/compose-app/build.gradle.kts @@ -19,6 +19,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDistributionDsl import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl +import xyz.xfqlittlefan.fhraise.buildsrc.outputDirectoryOf +import xyz.xfqlittlefan.fhraise.buildsrc.projectBuildNumber +import xyz.xfqlittlefan.fhraise.buildsrc.projectVersion import java.time.Year import java.util.* @@ -33,27 +36,6 @@ val androidCompileSdk: String by project val androidMinSdk: String by project val androidTargetSdk: String by project -val versionProperties = Properties().apply { - with(rootProject.file("version.properties")) { - if (exists()) { - load(inputStream()) - } - } -} -val version: String = versionProperties.getProperty("version", "0.1.0") - -val buildNumberProperties = Properties().apply { - with(rootProject.file("build-number.properties")) { - if (exists()) { - load(inputStream()) - } - } -} -val buildNumber: String = buildNumberProperties.getProperty("buildNumber", "1") - -val String.outputDirectory - get() = rootProject.layout.buildDirectory.dir("outputs/binaries/$version.$buildNumber/$this") - kotlin { @OptIn(ExperimentalWasmDsl::class) wasmJs { moduleName = "fhraise" @@ -62,7 +44,7 @@ kotlin { outputFileName = "fhraise.js" } @OptIn(ExperimentalDistributionDsl::class) distribution { - outputDirectory = "web".outputDirectory + outputDirectory = outputDirectoryOf("web") } } binaries.executable() @@ -159,8 +141,8 @@ android { applicationId = "xyz.xfqlittlefan.fhraise" minSdk = androidMinSdk.toInt() targetSdk = androidTargetSdk.toInt() - versionCode = buildNumber.toInt() - versionName = version + versionCode = projectBuildNumber + versionName = projectVersion } packaging { resources { @@ -222,7 +204,7 @@ compose.desktop { targetFormats(TargetFormat.Deb, TargetFormat.Rpm, TargetFormat.AppImage, TargetFormat.Msi) modules("java.instrument", "java.management", "jdk.unsupported") packageName = "Fhraise" - packageVersion = version + packageVersion = projectVersion description = "Fhraise" copyright = "© 2024${ Year.now().value.let { @@ -231,7 +213,7 @@ compose.desktop { } HSAS Foodies. All Rights Reserved." vendor = "HSAS Foodies" licenseFile = rootProject.file("LICENSE") - outputBaseDir = "desktop".outputDirectory + outputBaseDir = outputDirectoryOf("desktop") linux { debMaintainer = "xfqwdsj@qq.com" @@ -240,7 +222,7 @@ compose.desktop { } windows { - packageVersion = version.split("+").first() + packageVersion = projectVersion.split("+").first() dirChooser = true menuGroup = "HSAS Foodies" upgradeUuid = "e72b5bab-6eb1-41a6-b9c4-d755d92103ae" diff --git a/keycloak-spi/build.gradle.kts b/keycloak-spi/build.gradle.kts index 4dd297d..280c5b4 100644 --- a/keycloak-spi/build.gradle.kts +++ b/keycloak-spi/build.gradle.kts @@ -16,24 +16,15 @@ * with Fhraise. If not, see . */ -import java.util.* +import xyz.xfqlittlefan.fhraise.buildsrc.projectVersion plugins { alias(libs.plugins.kotlinJvm) `java-library` } -val versionProperties = Properties().apply { - with(rootProject.file("version.properties")) { - if (exists()) { - load(inputStream()) - } - } -} -val version: String = versionProperties.getProperty("version", "0.1.0") - group = "xyz.xfqlittlefan.fhraise" -project.version = version +project.version = projectVersion dependencies { implementation(libs.keycloak.core) diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 5af2368..980963c 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -16,7 +16,7 @@ * with Fhraise. If not, see . */ -import java.util.* +import xyz.xfqlittlefan.fhraise.buildsrc.projectVersion plugins { alias(libs.plugins.kotlinJvm) @@ -25,17 +25,8 @@ plugins { application } -val versionProperties = Properties().apply { - with(rootProject.file("version.properties")) { - if (exists()) { - load(inputStream()) - } - } -} -val version: String = versionProperties.getProperty("version", "0.1.0") - group = "xyz.xfqlittlefan.fhraise" -project.version = version +project.version = projectVersion application { mainClass.set("xyz.xfqlittlefan.fhraise.ApplicationKt")