Files
capod/buildSrc/src/main/java/ProjectConfig.kt
T
darken 221f3ccbed Refactor: Convert build configuration to Gradle plugin pattern
- Migrate ProjectConfig from static object to proper Gradle plugin
- Add version type support (beta/rc) to version.properties
- Clean up legacy fastlane changelogs
- Update release script to support version types
- Remove automatic fastlane changelog generation from release script
- Add BuildConfig field injection for version info
2025-10-07 13:54:24 +02:00

56 lines
1.8 KiB
Kotlin

import org.gradle.api.Plugin
import org.gradle.api.Project
import java.io.File
import java.io.FileInputStream
import java.util.Properties
open class ProjectConfig {
val packageName = "eu.darken.capod"
val minSdk = 26
val compileSdk = 36
val targetSdk = 36
lateinit var version: Version
override fun toString(): String {
return "ProjectConfig($packageName, min=$minSdk, compile=$compileSdk, target=$targetSdk, version=$version)"
}
fun init(project: Project) {
val versionProperties = Properties().apply {
val propsPath = File(project.rootDir, "version.properties")
println("Version: From $propsPath:")
load(FileInputStream(propsPath))
println("$this")
}
version = Version(
major = versionProperties.getProperty("project.versioning.major").toInt(),
minor = versionProperties.getProperty("project.versioning.minor").toInt(),
patch = versionProperties.getProperty("project.versioning.patch").toInt(),
build = versionProperties.getProperty("project.versioning.build").toInt(),
type = versionProperties.getProperty("project.versioning.type"),
)
}
data class Version(
val major: Int,
val minor: Int,
val patch: Int,
val build: Int,
val type: String,
) {
val name: String
get() = "${major}.${minor}.${patch}-$type${build}"
val code: Long
get() = major * 10000000 + minor * 100000 + patch * 1000 + build * 10L
}
}
class ProjectConfigPlugin : Plugin<Project> {
override fun apply(project: Project) {
val extension = project.extensions.create("projectConfig", ProjectConfig::class.java)
extension.init(project)
project.afterEvaluate { println("ProjectConfigPlugin loaded: $extension") }
}
}