I have an Android aar library I am using with an Android application. It is working correctly with the aar library included directly in the Android project. I would like to move this library to my internal Nexus maven repository, so that other developers can use the library too.
How do I upload the aar to Nexus (the Maven repository)? There is no apparent option to do so in the web interface:
I used gradle's maven plugin to upload to Nexus by modifying the Android build.gradle file.
apply plugin: 'maven'
dependencies {
deployerJars "org.apache.maven.wagon:wagon-http:2.2"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "https://my.example.com/content/repositories/com.example/") {
authentication(userName: "exampleUser", password: "examplePassword")
pom.groupId = "com.example"
pom.artifactId = "myexample"
pom.version = '1.0.0'
}
}
}
To upload: gradlew upload
, using the gradlew
script that is provided by the Android Studio project.
You can also move the authentication parameters into a file that is not version controlled.
For Android, we normally have two build.gradle files the one at the top level folder, and another one in the specific module:
app/
---build.gradle
---module/
------build.gradle
In the app/build.gradle file of the clients of this library you will have to add:
repositories {
jcenter()
maven {
url "http://localhost:8081/repository/test-maven-repo/"
}
}
For you library app/module/build.gradle file:
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:8081/repository/test-maven-repo/") {
authentication(userName: "admin", password: "admin123")
pom.groupId = "com.example.test"
pom.artifactId = "myexample.test"
pom.version = '1.0.0'
}
}
}
}
And you might want to run it just with:
./gradlew upload
Link to official documentation: Maven Publish Plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With