Better share version information between modules
Move important version properties to buildSrc directory to access between modules as needed. Also add a simple task to generate a simple BuildConfig class to access version name. This is better than adding dependency on a third-party library/plugin. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
53f36154aa
commit
d1bc8c23cf
4 changed files with 48 additions and 14 deletions
|
|
@ -31,25 +31,25 @@ kotlin {
|
|||
|
||||
configure<ApplicationExtension> {
|
||||
compileSdk {
|
||||
version = release(36) {
|
||||
minorApiLevel = 1
|
||||
version = release(NEWPIPE_VERSION_SDK_COMPILE_MAJOR) {
|
||||
minorApiLevel = NEWPIPE_VERSION_SDK_COMPILE_MINOR
|
||||
}
|
||||
}
|
||||
namespace = "org.schabi.newpipe"
|
||||
namespace = NEWPIPE_APPLICATION_ID_OLD
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "org.schabi.newpipe"
|
||||
applicationId = NEWPIPE_APPLICATION_ID_OLD
|
||||
resValue("string", "app_name", "NewPipe")
|
||||
minSdk {
|
||||
version = release(23)
|
||||
version = release(NEWPIPE_VERSION_SDK_MIN)
|
||||
}
|
||||
targetSdk {
|
||||
version = release(35)
|
||||
version = release(NEWPIPE_VERSION_SDK_TARGET)
|
||||
}
|
||||
|
||||
versionCode = System.getProperty("versionCodeOverride")?.toInt() ?: 1011
|
||||
versionCode = System.getProperty("versionCodeOverride")?.toInt() ?: NEWPIPE_VERSION_CODE
|
||||
|
||||
versionName = "0.28.6"
|
||||
versionName = NEWPIPE_VERSION_NAME
|
||||
System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it }
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
|||
15
buildSrc/src/main/kotlin/ProjectConfig.kt
Normal file
15
buildSrc/src/main/kotlin/ProjectConfig.kt
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
const val NEWPIPE_VERSION_SDK_COMPILE_MAJOR = 36
|
||||
const val NEWPIPE_VERSION_SDK_COMPILE_MINOR = 1
|
||||
const val NEWPIPE_VERSION_SDK_MIN = 23
|
||||
const val NEWPIPE_VERSION_SDK_TARGET = 35
|
||||
|
||||
const val NEWPIPE_VERSION_CODE = 1011
|
||||
const val NEWPIPE_VERSION_NAME = "0.28.6"
|
||||
|
||||
const val NEWPIPE_APPLICATION_ID_OLD = "org.schabi.newpipe"
|
||||
const val NEWPIPE_APPLICATION_ID_NEW = "net.newpipe.app"
|
||||
|
|
@ -25,8 +25,8 @@ compose.desktop {
|
|||
|
||||
nativeDistributions {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "net.newpipe.app"
|
||||
packageVersion = "1.0.0"
|
||||
packageName = NEWPIPE_APPLICATION_ID_NEW
|
||||
packageVersion = NEWPIPE_VERSION_NAME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,24 @@ plugins {
|
|||
alias(libs.plugins.jetbrains.kotlinx.serialization)
|
||||
}
|
||||
|
||||
// Better than adding a third-party dependency for something as simple as this
|
||||
// https://stackoverflow.com/a/74771876/8446131
|
||||
val buildConfigGenerator by tasks.registering(Sync::class) {
|
||||
val buildConfigPackage = NEWPIPE_APPLICATION_ID_NEW
|
||||
val rawClass = """
|
||||
package $buildConfigPackage
|
||||
|
||||
object BuildConfig {
|
||||
const val VERSION_NAME = "$NEWPIPE_VERSION_NAME"
|
||||
}
|
||||
""".trimIndent()
|
||||
from(resources.text.fromString(rawClass)) {
|
||||
rename { "BuildConfig.kt" }
|
||||
into(buildConfigPackage.replace(".", "/"))
|
||||
}
|
||||
into(layout.buildDirectory.dir("generated/kotlin/"))
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
|
||||
|
|
@ -27,14 +45,14 @@ kotlin {
|
|||
}
|
||||
|
||||
android {
|
||||
namespace = "net.newpipe.app"
|
||||
namespace = NEWPIPE_APPLICATION_ID_NEW
|
||||
compileSdk {
|
||||
version = release(36) {
|
||||
minorApiLevel = 1
|
||||
version = release(NEWPIPE_VERSION_SDK_COMPILE_MAJOR) {
|
||||
minorApiLevel = NEWPIPE_VERSION_SDK_COMPILE_MINOR
|
||||
}
|
||||
}
|
||||
minSdk {
|
||||
version = release(23)
|
||||
version = release(NEWPIPE_VERSION_SDK_MIN)
|
||||
}
|
||||
androidResources {
|
||||
enable = true
|
||||
|
|
@ -71,6 +89,7 @@ kotlin {
|
|||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
kotlin.srcDir(buildConfigGenerator.map { it.destinationDir })
|
||||
dependencies {
|
||||
implementation(libs.jetbrains.compose.runtime)
|
||||
implementation(libs.jetbrains.compose.foundation)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue