App Metadata (NucleusApp)¶
Access application metadata injected by the Nucleus Gradle plugin at runtime.
Installation¶
NucleusApp is part of core-runtime:
Usage¶
import io.github.kdroidfilter.nucleus.core.runtime.NucleusApp
// Application identifier (matches packageName in the Nucleus DSL)
val appId: String = NucleusApp.appId
// Optional metadata (null if not configured in the DSL)
val version: String? = NucleusApp.version
val vendor: String? = NucleusApp.vendor
val description: String? = NucleusApp.description
// Check if the plugin injected metadata
if (NucleusApp.isConfigured) {
println("Running as packaged app: $appId v$version")
}
Properties¶
| Property | Type | Description |
|---|---|---|
appId |
String |
Application identifier. Falls back to main class name or "NucleusApp" if not injected. |
version |
String? |
Application version from packageVersion in the DSL. null if not configured. |
vendor |
String? |
Application vendor from vendor in the DSL. null if not configured. |
description |
String? |
Application description from description in the DSL. null if not configured. |
isConfigured |
Boolean |
true if the Nucleus plugin injected metadata (via system property or classpath resource). |
All properties are @JvmStatic and lazily initialized.
How It Works¶
The Nucleus Gradle plugin injects metadata through two mechanisms:
1. System properties (during run)¶
When running via ./gradlew run, the plugin adds JVM arguments:
2. Classpath resource (in packaged builds)¶
At build time, the plugin generates a nucleus/nucleus-app.properties file that is included in the application's classpath:
Resolution order¶
For each property, NucleusApp checks (first non-null wins):
- System property (
nucleus.app.id,nucleus.app.version, etc.) - Classpath resource (
nucleus/nucleus-app.properties) - Legacy fallback (for
appIdonly): main class fromsun.java.command, then"NucleusApp"
Use Cases¶
About dialog¶
@Composable
fun AboutDialog() {
Column {
Text("${NucleusApp.appId}")
NucleusApp.version?.let { Text("Version $it") }
NucleusApp.vendor?.let { Text("By $it") }
}
}
Conditional logic based on packaging¶
if (NucleusApp.isConfigured) {
// Running as packaged app — enable auto-update, telemetry, etc.
initAutoUpdater()
} else {
// Running in dev mode (./gradlew run)
enableDevTools()
}
Used by other Nucleus modules¶
NucleusApp.appId is consumed automatically by:
SingleInstanceManager— usesappIdas the default lock file identifier (viaAppIdProvider)taskbar-progress— usesappIdto resolve the Linux.desktopfile for D-Bus progressupdater-runtime— usesappIdto determine the update marker storage directory- GraalVM
graalvm-runtime— usesappIdto set the correctWM_CLASSon Linux native image