3.4 KiB
Kotlin / Gradle Mirror Setup with Nexus (Air‑Gapped Environment)
This document summarizes the steps performed to configure a Kotlin/Gradle package mirror using Sonatype Nexus Repository in an offline (air‑gapped) Ubuntu server environment. The server already has Docker installed and Nexus is accessible via:
The steps below cover the process from creating the repository to testing Gradle builds in the offline environment.
1. Create the Repository
-
Log in to the Nexus UI:
-
Navigate to:
Administration → Repositories → Create repository
-
Select:
maven2 (hosted)
-
Configure the repository:
| Setting | Value |
|---|---|
| Name | kotlin-mirror |
| Version policy | Release |
| Layout policy | Strict |
| Deployment policy | Allow redeploy |
- Click Save.
This repository will host Kotlin and Gradle artifacts for the offline environment.
2. Repository URL
After creation, the repository is accessible at:
https://mirror.mahgit.ir/repository/kotlin-mirror/
Example artifact URL:
3. Upload the Artifact
Because the server has no internet access, artifacts must be downloaded externally and uploaded manually.
Steps:
-
In Nexus UI navigate to:
Browse → kotlin-mirror → Upload
-
Fill the fields:
| Field | Value |
|---|---|
| Group | org.jetbrains.kotlin |
| Artifact | kotlin-stdlib |
| Version | 1.9.0 |
| Packaging | jar |
- Upload the following files:
- kotlin-stdlib-1.9.0.jar
- kotlin-stdlib-1.9.0.pom
- Click Upload.
The artifact will now be stored inside the repository.
4. Test Artifact Download
Open the artifact URL in a browser:
If the file downloads successfully, the repository is working correctly.
5. Configure Gradle to Use the Mirror
Modify your Gradle project configuration to use the Nexus mirror instead of Maven Central.
Example build.gradle configuration:
repositories {
maven {
url "https://mirror.mahgit.ir/repository/kotlin-mirror/"
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
}
Gradle will now resolve dependencies from the Nexus mirror.
6. Test Build in Offline Environment
Run the Gradle build on the offline server:
gradle build
Expected behavior:
Gradle resolves dependencies only from the Nexus mirror:
Gradle → Nexus Mirror → Local Artifact Storage
If the build completes successfully, the mirror setup is functioning correctly in the air‑gapped environment.
End of document.