# Overview

`app-signer-gradle-plugin` is the Gradle plugin `com.microej.gradle.app-signer`. It signs the MicroEJ
Application binary (`.fo`) produced by the MicroEJ application plugin, wrapping the `app-signer`
signing engine. It adds a `signFeature` task that signs the Application binary into a `.fo.signed` file.

When the MicroEJ application plugin is applied, `signFeature` is wired to `buildFeature`: it takes the
produced Application binary as its input by default, which makes it depend on `buildFeature` implicitly. By
default, it also finalizes `buildFeature`, so the Application binary is signed right after it is built; set
`appSigner.signOnBuild=false` to disable that and sign only on demand.

# Usage

Apply the plugin next to the MicroEJ application plugin in your `build.gradle.kts`:

```kotlin
plugins {
    id("com.microej.gradle.application")
    id("com.microej.gradle.app-signer") version "x.y.z"
}
```

Release candidates are published as `x.y.z-SNAPSHOT` versions: apply them with `version "x.y.z-SNAPSHOT"` to always get
the latest one.

Configure the signing parameters in `gradle.properties` (see the table below), then run:

```
./gradlew signFeature
```

The signed Application binary is written to `build/application/feature/application.fo.signed` by default.

# Standalone signing

The plugin can also be applied on its own, without the MicroEJ application plugin, to sign an Application binary
that was already built elsewhere. This is useful when signing is decoupled from building: for example a dedicated
signing pipeline that holds the signing key, signing a `.fo` produced by another team, or re-signing an existing
`.fo` without rebuilding it.

Apply only the signer plugin and point `appSigner.featureFile` at the Application binary to sign:

```kotlin
plugins {
    id("com.microej.gradle.app-signer") version "x.y.z"
}
```

```
./gradlew signFeature -PappSigner.featureFile=path/to/application.fo
```

In this mode `appSigner.featureFile` is required, since there is no `buildFeature` output to fall back on. All
other signing properties behave as documented in the table below.

# Configuration

Every parameter is set through a Gradle property prefixed with `appSigner.`. Put non-sensitive values in the
project `gradle.properties` and secrets (passwords) in `~/.gradle/gradle.properties`:

```properties
appSigner.keyStorePath=tools/keys/keystore.p12
appSigner.alias=my-signing-key
appSigner.keyStorePassword=changeit
appSigner.applicationId=com.acme.app
appSigner.applicationVersion=1.0.0
```

| Property                          | Description                                                                                                                                       | Default                                              |
|-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `appSigner.keyStorePath`          | Path to the key store file (relative to the project).                                                                                             | _(required)_                                         |
| `appSigner.keyStoreType`          | Key store type (for example `PKCS12` or `JKS`).                                                                                                   | `PKCS12`                                             |
| `appSigner.keyStorePassword`      | Password protecting the key store.                                                                                                                | _(required)_                                         |
| `appSigner.alias`                 | Alias of the signing key and its certificate chain.                                                                                               | _(required)_                                         |
| `appSigner.keyPassword`           | Password protecting the signing key. Reuses the key store password when unset.                                                                    | _(key store password)_                               |
| `appSigner.applicationId`         | Identifier of the application to install.                                                                                                         | `microej.applicationName`, else `project.name`       |
| `appSigner.applicationVersion`    | Version of the application to install.                                                                                                            | `microej.applicationVersion`, else `project.version` |
| `appSigner.signedFeatureLocation` | Output path of the signed Application binary (relative to the build directory).                                                                   | `application/feature/application.fo.signed`          |
| `appSigner.featureFile`           | Application binary `.fo` to sign. Overrides the `buildFeature` output when set.                                                                   | _(produced by `buildFeature`)_                       |
| `appSigner.signOnBuild`           | When `true`, `buildFeature` automatically runs `signFeature`. Set to `false` to build without signing; `signFeature` can still be run explicitly. | `true`                                               |

Parameters marked _(required)_ have no default: `signFeature` fails, listing every missing property, when any of them is not set.

`applicationId` / `applicationVersion` are optional. They default to the MicroEJ application identity (`microej.applicationName` / `microej.applicationVersion`) when set, otherwise to `project.name` / `project.version` — mirroring what `buildFeature` stamps into the binary. The `appSigner.*` property (or the task API) overrides them. They are signed but not verified at installation, so `signFeature` never requires them.

# Requirements

This plugin requires **JDK 11** or higher. The signing engine relies on JDK-internal `sun.security.*` APIs, but the
plugin runs the signature in a forked JVM that already passes the required `--add-exports`, so **no JVM
configuration is needed in the consuming project**.

# Dependencies

_All dependencies are retrieved transitively by Gradle_.

# Source

N/A.

# Restrictions

None.

---

_Copyright 2026 MicroEJ Corp. All rights reserved._\
_Use of this source code is governed by a BSD-style license that can be found with this software._\
_Build: 7E4D1F7C_
