Publish the jar or AAR to the net mvn (using GitHub as a warehouse), Gradle dependency information integration

Source: Internet
Author: User
Tags sha1 git clone sonatype

With Android Studio user development, you want to integrate the remote repository jar, AAR files through maven. But how do you publish these files to it?

The sender will advertise the jar file to Sonatype for integration with 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 you can 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. Like Https://github.com/ione/mvn-repo-ione.

Step Two:

Clone the file locally using the git clone command.

Step Three:

1. Publication of AAR documents

In the project folder build.gradle file, add:

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        }}}    

amongaar.deployPathcan be ingradle.propertiesspecified in the file:

Aar.deploypath=e:\\dev\\workspace\\mvn-repo-ione\\repository

The path is the second step of clone repo the selected folder.

before publishing the Aar file. You just need to run the command under the project folder:

Gradlew uploadarchives

You can generate the required files to upload to GitHub as a maven repository.

Then push the updated files in the folder selected in the second step of clonerepo to GitHub. It can be announced after completion.

2. Publish the Jar file

Install the local jar package into this folder by using the following command:

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 executing the above command, there is a required Maven file under the local folder, For example:

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


And thenPush the generated maven file to GitHub via git push and you're ready to go.

Fourth Step:

Integration of jar files or AAR files in Android Studio

In 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:1.0 '  }



to complete the integration.









To publish the jar or AAR to the network MVN (using GitHub as the repository), through Gradle dependency information integration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.