My M2 MacBook Air is fantastic for most types of work. Sadly though, it is not powerful enough to compile a modern Kotlin app without locking up and taking forever.
To solve this, I wanted to find a way to have Gradle tasks executed remotely on my (much more powerful, but less delightful) Windows desktop machine.
Enter Mirakle, “a Gradle plugin that allows you to move build process from a local machine to a remote one”. It’s exactly what I needed, and I’m surprised it only has around 500 stars on GitHub. My basic setup is something like this:
- I have WSL set to automatically start when my Windows computer logs in.
- My user in WSL is set up with the Android SDKs installed, and $ANDROID_HOME set properly. Installing the SDKs on Ubuntu was harder than I expected it to be. Using the Snap package made it easier.
- Both the WSL machine and my Macbook are connected via Tailscale, so I can always reach the WSL instance via a stable domain name (desktop-wsl in my case).
- I added the config below to
~/.gradlew/init.d/
on my Macbook to automatically use Mirakle for remote execution of all Gradle tasks.
And… That’s it. Now, whenever I run Gradle either via the terminal or Android Studio, most or all of the heavy lifting happens remotely on my beefy desktop machine. If my desktop computer can’t be reached for whatever reason, I can add -x mirakle
to any ./gradlew
command to run it locally instead.
And since this all runs over Tailscale, it doesn’t matter if I’m home or at a café: My workspace is synced over an encrypted connection wherever I am. Pretty sweet.
PS: The Android Studio UI for (re-)pairing my phone never worked properly on my home network. With Tailscale, I don’t have to worry about even being on the same WiFi: my phone has a stable IPv4 address that I can easily connect to using adb connect
on the command line.
Mirakle config
Saved to ~/.gradle/init.d/mirakle_init.gradle
initscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'io.github.adambl4:mirakle:1.6.0'
}
}
apply plugin: MirakleBreakMode
rootProject {
mirakle {
host "desktop-wsl"
excludeCommon = [".gradle", ".idea", "**/local.properties", "**/mirakle.properties", "**/mirakle_local.properties"]
// These are tasks that will break remote work and bring the remainder of the Gradle task back to be executed locally. Nifty for installing on a local device or avoiding large network transfers.
breakOnTasks += ["optimizeProdReleaseResources", "mergeProjectDexProdDebug"]
}
}