Gradle Plugin
The JetStart Gradle plugin (com.jetstart.hot-reload) is responsible for integrating JetStart's hot-reload capabilities into your Android application's build process.
Overview
The Gradle plugin automates several key tasks:
- BuildConfig Injection - It adds
JETSTART_SERVER_URLandJETSTART_SESSION_IDfields to your app'sBuildConfig. These fields are dynamically updated byjetstart devto point to the current development session. - Hot Reload Instrumentation - It configures the debug build variant to support DEX hot-swapping.
- Dependency Management - It ensures that the necessary hot-reload runtime libraries are correctly included in the debug build.
Installation
The plugin is automatically included when you create a new project with jetstart create. It is applied in your app-level build.gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
// ...
id 'com.jetstart.hot-reload' version '1.0.0'
}
How It Works
During a jetstart dev session, the CLI communicates with the Gradle plugin to inject the necessary connection details. This allows the mobile app to automatically discover and connect to the development server without manual configuration.
Injected Fields
In your MainActivity.kt, you can access these fields to connect to the hot-reload server:
if (BuildConfig.DEBUG) {
val serverUrl = BuildConfig.JETSTART_SERVER_URL
val sessionId = BuildConfig.JETSTART_SESSION_ID
HotReload.connect(this, serverUrl, sessionId)
}
Security
The Gradle plugin is designed to be active only in debug builds. When you run a release build (jetstart build --release), the plugin:
- Does not inject any development credentials.
- Ensures that the hot-reload runtime is not included in the final production binary.
- Strips any
BuildConfigfields related to JetStart.
Configuration
Most configuration is handled automatically by the JetStart CLI. However, you can see the plugin's impact in your project's build.gradle and gradle.properties.
Related Documentation
- Hot Reload System - Technical deep dive
- Hot Reload Runtime - The companion runtime library
- CLI Reference - How to use
jetstart dev