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
:
Apply plugin: ' maven ' android{ //...} Ext is a gradle closure allowing the declaration of global Propertiesext { publish_group_id = ' Com.ione ' publis h_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 }}}
whichaar.deployPath
can be ingradle.properties
specified in the file:
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:
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:
MVN Install:install-file-dgroupid=com.ione-dartifactid=demo-dversion=1.4.1-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 in the local directory there is the need for maven files, For example:
Mvn-repo-demogit: (master) tree . ├──license ├──readme.md └──repository └──com └──ione └──demo ├──1.4.1 │ ├── Demo-1.4.1.jar │ ├──demo-1.4.1.jar.md5 │ ├──demo-1.4.1.jar.sha1 │ ├── Demo-1.4.1.pom │ ├──deno-1.4.1.pom.md5 │ └──demo-1.4.1.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:
repositories { jcenter () maven {URL "https://raw.githubusercontent.com/ione/mvn-repo-ione/master/ Repository "} }
dependencies { compile ' Com.ione.demo ' }
Integration can be completed.
Publish the jar or AAR to MVN (using GitHub as a warehouse) and integrate it through the gradle dependency approach