Users who are developing with Android studio want to integrate the jar, AAR files through the MAVEN remote repository, but how are these files published?
Often developers will publish jar files to Sonatype to provide integration to other developers, but Sonatype requires the source code, and in some cases the publisher does not want to provide the source code, so the method described in this article can be used.
Here's how to create a warehouse on GitHub, publish the jar and AAR files to maven, and how to integrate them.
The first step:
Create a repo on github.com dedicated to use as a Maven repository. such as Https://github.com/ione/mvn-repo-ione
Step Two:
Clone the file locally using the git clone command.
Step Three:
1. Publishing AAR files
Add the files in the project catalog build.gradle
:
[Java]View PlainCopy
- Apply plugin: ' maven '
- android{
- // ...
- }
- Ext is a gradle closure allowing the declaration of global Properties
- ext {
- publish_group_id = ' Com.ione '
- publish_artifact_id = ' demo '
- Publish_version = Android.defaultConfig.versionName
- }
- uploadarchives {
- Repositories.mavendeployer {
- def deploypath = File (GetProperty (' Aar.deploypath '))
- Repository (URL: "File://${deploypath.absolutepath}")
- Pom.project {
- GroupId Project. publish_group_id
- Artifactid Project. publish_artifact_id
- Version Project. Publish_version
- }
- }
- }
Which aar.deployPath
can be gradle.properties
specified in the file:
[Java]View PlainCopy
- Aar.deploypath=e:\\dev\\workspace\\mvn-repo-ione\\repository
The path is the directory selected for the second step of clone repo.
Before you publish an AAR file, you only need to execute the command in the project directory:
[Java]View PlainCopy
- Gradlew uploadarchives
You can generate the required files to upload to GitHub as a maven repository. Then push the updated files in the directory selected in the second step Clonerepo to GitHub to complete the release.
2. Release the jar file
Install the local jar package into this directory by using the following command:
[Java]View PlainCopy
- MVN install:install-file-dgroupid=com.ione-dartifactid=demo-dversion=1.0-dfile=e:\dev\libs\ com.ione.demo.jar-dpackaging=jar-dgeneratepom=true-dlocalrepositorypath=e:\dev\workspace\ione\ Mvn-repo-ione\repository-dcreatechecksum=true
Note the package name and path
After running the above command, a maven file is required in the local directory, for example:
[Java]View PlainCopy
- Mvn-repo-demogit: (Master) tree
- .
- ├──license
- ├──readme.md
- └──repository
- └──com
- └──ione
- └──demo
- ├── 1.0
- │├──demo-1.0.jar
- │├──demo-1.0.jar.md5
- │├──demo-1.0.JAR.SHA1
- │├──demo-1.0.pom
- │├──deno-1.0.pom.md5
- │└──demo-1.0.POM.SHA1
- ├──maven-metadata-local.xml
- ├──maven-metadata-local.xml.md5
- └──maven-metadata-local.xml.sha1
- 5 directories, files
The resulting MAVEN file is then push to GitHub with Git push to complete the release.
Fourth Step:
Integration of jar files or AAR files in Android Studio
In the project's Build.grade file, add:
[Java]View PlainCopy
- repositories {
- Jcenter ()
- Maven {URL "https://raw.githubusercontent.com/ione/mvn-repo-ione/master/repository"}
- }
[Java]View PlainCopy
- dependencies {
- Compile ' com.ione:demo:1.0 '
- }
Integration can be completed.
Close the release of the jar or AAR to MVN (using GitHub as the repository), integrated through the Gradle dependency approach