3.7 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.
2. 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.
3. Repository URL
After creation, the repository is accessible at:
https://mirror.mahgit.ir/repository/kotlin-mirror/
Example artifact URL:
4. 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.
5. Test Artifact Download
Open the artifact URL in a browser:
If the file downloads successfully, the repository is working correctly.
6. 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.
7. Prepare for Offline Dependency Usage
Ensure that all required dependencies are uploaded to Nexus beforehand.
For Kotlin projects this may include additional dependencies such as:
- kotlin-stdlib-common
- org.jetbrains.annotations
These must also be downloaded externally and uploaded to the mirror.
8. 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.