DEV Community

Cover image for Stop Waiting for Gradle: Turn Your Old Laptop into an Android/Kotlin Build Sanctuary
Joseph Sanjaya
Joseph Sanjaya

Posted on • Originally published at Medium

Stop Waiting for Gradle: Turn Your Old Laptop into an Android/Kotlin Build Sanctuary

If you are a geek like me, you live in a multi-device environment. I have my Gaming PC for freelancing and late-night sessions. I have my Mac for professional work and those heavy iOS/CMP compilations. And I have my Corporate Laptop for the 9-to-5 grind.

Switching between them used to be a nightmare.

I would push code from the Mac, walk over to the PC, pull the changes, and then… wait. I’d wait for Maven Central to redownload libraries I already had on the other machine. I’d wait for Gradle to rebuild tasks that hadn’t changed.

I was paying a “Context Switch Tax” of 15 to 20 minutes every single time I changed desks.

But I also had a secret weapon: an old, dusty laptop sitting in a drawer. Instead of letting it rot, I turned it into a Build Sanctuary.

Using CasaOS, I transformed that junk hardware into a local powerhouse.

The best part? It didn’t just solve my build times. Because it’s running CasaOS, this old laptop is now my Private Cloud. It handles my local file storage (bye-bye, cloud storage fees), hosts my backend services for testing, and acts as a central environment for everything I develop.

Here is how you can do it and why you should stop ignoring your old hardware.

The “Sanctuary” Concept

Your bandwidth is finite, and your time is expensive. Downloading the same 500MB of libraries three times a day isn’t just inefficient; it’s a distraction.

Imagine a world where you update a library on your Mac, and when you open your PC, it’s already “there.”

  • No downloading.
  • No waiting.
  • Instant sync.

You create a Single Source of Truth for your entire home network.

The Foundation (CasaOS): We are going to use CasaOS. It’s a clean, visual interface for Linux. It turns a scary terminal into a friendly dashboard that looks like a smartphone screen.

  1. Take your old laptop.
  2. Install a lightweight Linux distro (like Ubuntu Server).
  3. Run the CasaOS installer.

Casa OS Dashboard

Now, let’s make it useful for Android.

Step 1: The Gradle Build Cache Node

Gradle is paranoid. It likes to rebuild things just to be safe. If you switch computers, Gradle assumes it’s a fresh start and recompiles code that you haven’t touched.

A Remote Build Cache Node acts as the brain of your operation. It remembers what you built on your Mac.

When you switch to your PC, Gradle asks the Node, “Do you have the output for this task?” The Node says “Yes,” and hands it over instantly via your local network. You skip the compilation step entirely.

The Setup: In your CasaOS dashboard, we are going to add a custom Docker app.

  1. Create the Custom App *You don’t need to touch a single line of code or write a YAML file. In the CasaOS dashboard, just click the *+ button and select “Install a Custom App”.

captionless image

Here is the Cheat Sheet:

  • Docker Image: gradle/build-cache-node
  • Tag: latest
  • Port (Host): 5071
  • Volumes (Host): /DATA/AppData/gradle-cache (This connects actual storage to store the Gradle cache files.)
  • Container Command: start

Hit Install. Wait a few seconds until the icon turns green. You are now live.

2. Connect Your Project
Open your Android project’s settings.gradle.kts file. We need to tell the project to talk to your old laptop.

Now, your Mac compiles the code, uploads the result to the laptop, and your PC downloads the result. It feels like magic. You can check if the project already using the remote cache by using --scan . On the report it will shown:

captionless image

Step 2: Sonatype Nexus

I live in Indonesia. We are famous for our delicious food, beautiful islands, and unfortunately our terrible internet speeds.

Yesterday, the worst happened. My ISP went dark. I had a hard deadline for a freelance client in three hours. Usually, this is the part where I panic, tether my phone, and watch a 10MB download take twenty minutes while sweating bullets.

Because I had Nexus running, I kept working. My Android Studio didn’t even notice the internet was gone. It reached out to my local server, grabbed the dependencies it needed instantly, and the build finished successfully. I met the deadline without a single blocker.

Nexus acts as a Proxy.

  1. You ask for a library (e.g., Retrofit).
  2. Nexus checks if it has it locally.
  3. If not, it downloads it once from the internet and stores it.
  4. The next time any device asks for Retrofit or if your internet dies Nexus delivers it at LAN speeds.

The Setup: Click + and “Install a Custom App” again. Use these settings:

captionless image

The Cheat Sheet:

  • Docker Image: sonatype/nexus3
  • Tag: latest
  • Port: Host 8081 ↔ Container 8081
  • Volume: Host /DATA/AppData/nexus-data ↔ Container /nexus-data (Tip: You can point the Host path to an external hard drive if you have a massive library collection)

2. Configure the Proxy

  • Log in to the Nexus dashboard (default is usually port 8081). The default username is admin. The first-time password is stored in a file inside the container’s host path open it to get the initial password.
  • Create a “Proxy Repository” for maven-central and google-maven.

captionless image

  • Group them into a single repository called maven-public.

3. Connect Your Project: Now, tell your Android project to look at your sanctuary first. Open your root build.gradle.kts (or settings.gradle.kts in newer projects) and update the repositories block:

Now, your builds fly because they are pulling data via Ethernet, not waiting on a server across the ocean. You can check on the Download Info :

captionless image

Step 3: The “One-Shot” Hack

You probably have dozens of projects. Opening every single build.gradle.kts file to add your new server IP is tedious. It's boring work, and you will forget to do it for new projects.

We can use a Global Initialization Script. You write this configuration once on your machine. Every single project you open or create on that computer will automatically use your local Build Sanctuary. No manual editing required.

On your Mac or PC, navigate to the .gradle folder (usually ~/.gradle/) and create a folder named init.d.

nexus.gradle,this script forces Gradle to look at your local server before it looks at the internet.

The “Line Cutter” Logic (**repos.add(0, nexus)**): Gradle is polite; it usually checks repositories in the order they are listed. If your project lists google() first, Gradle will hit the internet first, defeating the purpose. This script aggressively removes your local repo and re-inserts it at index 0 (the top). It guarantees your local server is always the first stop.

casa-cache.gradle, this script connects the build cache, but safely.

How to activate it: Now, just add this one line to your ~/.gradle/gradle.properties file:

casa.cache.url=http://192.168.1.XXX:5071/cache/
casa.cache.push=true
Enter fullscreen mode Exit fullscreen mode

Restart Android Studio. That’s it. Every project you touch is now supercharged.

For the Terminal Purists

Maybe you are reading this and thinking, “I don’t want a fancy UI. I don’t want the overhead of CasaOS. I just want raw performance.”

You don’t need CasaOS. It’s just a nice wrapper. Under the hood, this is all just Docker.

The Setup: If you prefer the command line, just install Docker and Docker Compose on your server. Create a single docker-compose.yml file that defines both the Nexus service and the Build Cache service.

Run docker-compose up -d.

You get the exact same benefits the speed, the sync, the sanctuary without the graphical interface. It’s your sanctuary; build it how you like it.

Scaling to the Enterprise

You might be thinking, “This is cool for my home lab, but does it work at work?”

This exact architecture is how top-tier tech companies speed up development.

If this setup saves you 15 minutes a day, imagine what it does for a team of 50 developers. By setting up a central Gradle Enterprise server or a shared Nexus instance in the office:

  1. Onboarding is instant. New employees don’t spend Day 1 downloading the internet. They sync from the local server.
  2. Consistency is enforced. Everyone uses the exact same artifacts.
  3. Bandwidth is saved. You stop 50 people from downloading the same 1GB files simultaneously.

It creates a Single Source of Truth for the entire engineering department.

Monday Morning Action Step

Don’t let this be just another article you bookmark and forget.

  1. Find the hardware. Go dig out that old ThinkPad, the unused Dell, or even a Raspberry Pi 4.
  2. Wipe it. Install a fresh Linux OS.
  3. Deploy. Whether you use the friendly CasaOS interface or stick to pure Docker, just get it running.

Give your old tech a new job, and give yourself the gift of faster builds. Your sanity (and your internet bill) will thank you.

Top comments (0)