Nucleus
Lifecycle

App metadata at runtime

Read your app's id, version, vendor, display name, and Windows AUMID from Kotlin at runtime.

NucleusApp lets you read your application's metadata — id, version, vendor, display name, and Windows AUMID — from Kotlin at runtime. The values come from what you configure in the Nucleus Gradle plugin and are injected at build time, so you don't hardcode them or read them off disk yourself.

Add the dependency

NucleusApp lives in the core-runtime module, which the Nucleus Gradle plugin already pulls in. Add the coordinate explicitly only when you read metadata from a module that does not depend on it:

build.gradle.kts
dependencies {
    implementation("dev.nucleusframework:nucleus.core-runtime:2.0.7")
}

Read the metadata

NucleusApp is an object. Read its properties directly:

import androidx.compose.foundation.layout.Column
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import dev.nucleusframework.core.runtime.NucleusApp

@Composable
fun AboutDialog() {
    Column {
        Text(NucleusApp.appName ?: NucleusApp.appId)
        NucleusApp.version?.let { Text("Version $it") }
        NucleusApp.vendor?.let { Text("by $it") }
    }
}

Each property resolves once and is cached, so reading it repeatedly is cheap.

Use isConfigured to tell a packaged app apart from a ./gradlew run session:

if (NucleusApp.isConfigured) {
    // Running as a packaged app
    initAutoUpdater()
}

Gate auto-update, telemetry, or anything you don't want firing in development on NucleusApp.isConfigured. It is true only when the plugin injected metadata.

How it works

The Gradle plugin delivers metadata to NucleusApp through two channels. Each property resolves from them in order, and the first non-blank value wins:

  1. System properties during ./gradlew run-Dnucleus.app.id=..., -Dnucleus.app.version=..., and so on.
  2. A classpath resource in packaged builds — nucleus/nucleus-app.properties, baked into the application jar.

For appId only, a third step applies: when neither source provides a value, appId derives from the main class name through AppIdProvider, falling back to NucleusApp if that too is missing.

A single block in build.gradle.kts therefore flows into every runtime module without manual wiring. The same values back the single-instance lock identifier, the Windows AUMID used for toast notifications and badge counts, and the MSIX startup task id — all read through NucleusApp.

API reference

NucleusApp

An object exposing the injected metadata as read-only properties.

PropertyTypeValue
appIdStringApplication id. Matches the plugin's packageName. Falls back to the main class name.
appNameString?Display name, or null if not configured.
versionString?Application version, or null if not configured.
vendorString?Application vendor, or null if not configured.
descriptionString?Application description, or null if not configured.
aumidStringWindows Application User Model ID. Falls back to appId when not set.
startupTaskIdString?MSIX startup task id, injected when appx { addAutoLaunchExtension = true }. Used by Auto-launch. null otherwise.
isConfiguredBooleantrue when the plugin injected metadata through the nucleus.app.id system property or the classpath resource.

Notes

  • appId and aumid are non-null; every other value is nullable. Guard nullable reads or supply your own fallback.
  • isConfigured checks the nucleus.app.id system property and the classpath resource, not the other individual properties.

What's next

  • Auto-launch — start your app at login using startupTaskId.
  • Executable type — distinguish a DMG, Flatpak, or ./gradlew run at runtime.
  • Single instance — the single-instance lock keyed on your app id.