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:
You can upload it with Maven or Gradle or manually.
For the manual upload you can just type the package value in the input to be 'aar' and upload as you desire.
I used gradle's maven plugin to upload to Nexus by modifying the Android build.gradle file.
To upload:
gradlew upload
, using thegradlew
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:
In the app/build.gradle file of the clients of this library you will have to add:
For you library app/module/build.gradle file:
And you might want to run it just with:
./gradlew upload
Here's a good example for a more complex setup: http://zserge.com/blog/gradle-maven-publish.html
Use maven deploy plugin. Example command:
This assumes you have correctly configured your pom.xml with distributonManagement section, telling all it needs to know about your Nexus repo
If you're that kind of people who dislike changing your pom.xml, or worse if your code doesn't even have pom.xml but you still want to upload to Nexus anyway, then you can still do it using
Refer to maven deploy plugin doc for more info: https://maven.apache.org/plugins/maven-deploy-plugin/
If you are building your project using Gradle, here there is a good tutorial to push your artifacts to Nexus:
https://medium.com/@scottyab/how-to-publish-your-open-source-library-to-maven-central-5178d9579c5#.acynm6j49
Basically, it adds a new Gradle task (uploadArchives) to push your artifacts. So doing something like:
It doesn't make any sense that why nexus package have nothing for @aar file but if you try to upload it as a jar then it will not block you and everything is work as it is..