UbDiag Gradle Plugin for Android
For seamless interplay between apps and the Ubique build management tools.
Features
Build properties
The following build properties can be specified using the -P
arguments:
buildid - used for "ub_buildid" meta data, a unique string to identify the build, defaults to "localbuild"
buildnumber - used for "ub_buildnumber" meta data, an incremental build number (per branch), defaults to "0"
branch - Git branch used for "ub_branch", defaults to the currently checked out branch, or "develop" if no Git
buildDir - custom build directory path, optional
webicon - web icon file to be generated and labelled, optional
<meta-data>
properties
AndroidManifest.xml The following <meta-data>
properties are injected into the AndroidManifest.xml:
ub_buildid
: Unique build IDub_buildnumber
: Incremental build numberub_branch
: Checked out Git branch of the source codeub_flavor
: Gradle flavor of the build
Launcher icon label
The build tool can draw a label banner onto the launcher icon (as per the manifest). By default the flavor's name is used for the label. Any flavor having a name starting with 'prod' will not be labelled.
To explicitly enable or disable the labelling, set launcherIconLabelEnabled
in the defaultConfig
or a specific flavor.
myflavor {
launcherIconLabelEnabled = false
}
A custom label can be set with the launcherIconLabel
property within a flavor:
myflavor {
launcherIconLabel = "foobar"
}
If a webicon
file is provided via Gradle property, the 'web icon' (usually a PNG file in the app module directory) also gets a banner applied, or generated from the app's launcher icon if it does not exist.
Note: In case of an adaptive launcher icon the foreground drawable has to have the same name as the XML resource with the postfix _foreground
.
Supported icon formats: PNG, WebP, Vector (adaptive foreground only)
Usage
To apply the Gradle build plugin, you have to add it as a project dependency in the top-level build.gradle:
buildscript {
repositories {
mavenCentral()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.0' // Android build plugin
classpath 'ch.ubique.gradle:ubdiag-android:8.2.0' // UbDiag build plugin
}
}
Then apply the plugin in the app's module build.gradle:
apply plugin: 'com.android.application' // standard Android app build plugin first
apply plugin: 'ch.ubique.gradle.ubdiag' // apply UbDiag build plugin after
android {
...
}
Development & Testing
To test any changes locally, you can deploy a build to your local maven repository and include that from any application:
-
Define a custom version by setting the mavenPublishing
coordinates
version in thebuild.gradle
file. -
You might need to disable
signAllPublications()
-
Deploy the plugin artifact by running
./gradlew publishToMavenLocal
-
Reference the local maven repository in your application's build script:
repositories { mavenLocal() }
-
And apply the local plugin version:
dependencies { classpath "ch.ubique.gradle:ubdiag-android:$yourLocalVersion" }
Deployment
Each release on Github will be deployed to Maven Central.
Use the mavenPublishing coordinates version as defined in the build.gradle
file as the release tag, prefixed with a v
.
- Group:
ch.ubique.gradle
- Artifact:
ubdiag-android
- Version:
major.minor.revision
, withmajor.minor
being in sync with the Android Gradle Plugin (AGP).