current position:Home>(latest) detailed process of open source Android GitHub project to maven

(latest) detailed process of open source Android GitHub project to maven

2022-01-26 23:41:37 Monster NM

The article brief introduction

I opened up a Android Tree view control to github, Then I want to use it implementation 'io.github.guaishoun:gyso-treeview:1.0.1' This way for others to use , according to sonatype The recommended Android gradle The way has never been successful . Finally, open source by learning from others gradle Configuration and blog on the website realize . The detailed process is recorded below .

In particular, the system environment of this paper is windows.

Step summary :

 a  Upload your open source project to github
 b  stay https://issues.sonatype.org/ Create questions , And wait for the administrator to review to solved state 
 c  Create the key and upload the public key to the service 
 d  Configure open source library Of gradle And compile 
 e  Handle maven Open source status , And notify the administrator to synchronize 
 f  Test open source references 
 Copy code 

1 Upload open source projects to github

This one doesn't go into detail , Because this step, if not , This article is not suitable ~~~

The example used in this article is github.com/guaishouN/a…

2 sonatype Create questions

Get into issues.sonatype.org/ This website , If you don't have an account …, And remember the user name and password , For the back .

The next goal is to create a project for review as solved state , The screenshot is as follows

image-20210816144249479.png

image-20210816145510527.png

image-20210816145728104.png

Fill in instructions :

A--> choose Community Support - Open Source Project Repository Hosting (OSSRH)

B-->New Project

C--> Abstract , Such as An android open source project for tree view

D--> describe A custom view for tree nodes.

E--> This can't be filled in casually. Pay attention to the naming rules , Sure Reference link , For example, upload github project github.com/guaishouN/a…

F--> Such as github.com/guaishouN/a…

G--> Such as github.com/guaishouN/a…, contrast F There are too many items **.git**

H--> Registered sonatype user name

I--> choice No

Then after the creation is completed, it is like this

image-20210816151409951.png The new status is open( to open up ), After a while, the administrator will give you feedback . If it is github Open source project , For example, he asks you to standardize the naming and create a new github The warehouse proves that the open source warehouse is yours . If it's all right , Then the administrator will change the problem status to solved( Repair ), Then you can upload your open source library . Finally, the administrator will close it in two or three days , So when the status is solved , Take the time to upload your open source .

3 Create a key pair and upload it to the service

sonatype New issue status changes to resolved after , Download a signature tool www.gnupg.org/download/in…

dl-1629100273641.png File new key pair  Wechat screenshot _20210715101123.png image-20210816155604997.png image-20210816155635827.png image-20210816155710237.png And then everywhere GuaishouN_0x163517B0_public.asc Here's the picture  Screen capture  2021-08-16 161841-1629102090832.png Open the website and upload the public key OpenPGP Keyserver (ubuntu.com), as follows image-20210816161249369.png image-20210816161124771.png And then again search key You can search for image-20210816161337969.png Then export the private key GuaishouN_0x163517B0_SECRET.gpg  Screen capture  2021-08-16 163019.png image-20210816163121602.png among keyId Right click to see , Here's the picture  Wechat screenshot _20210811105849.png Record the following three messages , For the back

serect.gpg The path of file saving 
 secret key keyId( As the key ID After 8 position , As above, keyid by 163517b0)
 password 
 Copy code 

4 To configure library Of gradle file

This paragraph officially States , But I haven't uploaded it successfully , So see some open source github The project is changed gradle file .

The official link is OSSRH Guide - The Central Repository Documentation (sonatype.org) and chrisbanes/gradle-mvn-push: Helper to upload Gradle Android Artifacts to Maven repositories (github.com).

My practice method is as follows , It's successful packaging aar And upload .

First, in the C:\Users\Mr. Deng\.gradle New under the directory gradle.properties file

#https://issues.sonatype.org/ Username and password 
NEXUS_USERNAME=GuaishouN
NEXUS_PASSWORD=*******

#gpg Signature code , And to the exported signature file 
signing.keyId=163517b0
signing.password=********
signing.secretKeyRingFile=C\:\\Users\\Mr. Deng\\.gradle\\GuaishouN_0x163517B0_SECRET.gpg
 Copy code 

modify library In the catalog build.gradle( Note that it's not Engineering build.gradle)

apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

version = '1.0.1'
android {
	...
}

dependencies {
	...
}

task androidSourcesJar(type: Jar) {
    archiveClassifier.set("sources")
    from android.sourceSets.main.java.source
    exclude "**/R.class"
    exclude "**/BuildConfig.class"
}

publishing {
    publications {
        release(MavenPublication) {
            // group id, Dependencies referenced after publishing  group id
            groupId 'io.github.guaishoun'
            //  Dependencies referenced after publishing  artifact id
            artifactId 'gyso-treeview'
            //  Released version 
            version version
            //  released  arr  Files and source files 
            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
            artifact androidSourcesJar
            pom {
                //  Component name , You can customize 
                name = 'gyso-treeview'
                //  Component description 
                description = 'A custom tree view for Android, designed for easy drawing some tree nodes (e.g. think mind and tree nodes). Includes smoothly zoom, move, limit and center fix animation support, and allows easy extension so you can add your own child node\'s customs view and touch event detection.'
                //  Component home page 
                url = 'https://github.com/guaishouN/android-thinkmap-treeview'
                //  License name and address 
                licenses {
                    license {
                        name = 'MIT License'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                //  Developer Information 
                developers {
                    developer {
                        name = 'GuaishouN'
                        email = '[email protected]'
                    }
                }
                //  Version control warehouse address 
                scm {
                    url = 'https://github.com/guaishouN/android-thinkmap-treeview'
                    connection = 'scm:[email protected]:guaishouN/android-thinkmap-treeview.git'
                    developerConnection = 'scm:[email protected]:guaishouN/android-thinkmap-treeview.git'
                }
            }
        }
    }
    repositories {
        maven {
            //  The location of the release , Here we distinguish according to the released version  SNAPSHOT  And the final version 
            def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
            def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            credentials {
                //  This is where I was before  issues.sonatype.org  Registered account 
                username NEXUS_USERNAME
                password NEXUS_PASSWORD
            }
        }
    }
}

signing {
    sign publishing.publications
}
 Copy code 

Last but not least , Enter... In the project root directory

gradlew build publish

Compile and upload

image-20210816203213006.png

5 Handle maven Open source status , And notify the administrator to synchronize

open s01.oss.sonatype.org/, Use https://…

image-20210816172823817.png After successful uploading, you can see the search interface in the figure above

First check the item to be updated , The current state is open, Then click close, Finally, click release.

Then back issues.sonatype.org/ Reply to the administrator that you have finished uploading

image-20210816173150061.png Then the administrator will reply to you , The warehouse has been synchronized with other information

6 Waiting for synchronization , test Maven Warehouse synchronization

The warehouse is staging You can't use implement synchronous , It will take a short time , Synced to releas The warehouse can only be used .

dependencies {
    	implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
   		implementation 'io.github.guaishoun:gyso-treeview:1.0.1'
}

 Copy code 

You can go to maven Go search and see if you can find your warehouse

search.maven.org/

image-20210816173915435.png

7 summary

This paper aims at Android The open source of , Of course, the process also encountered many problems , The article didn't post . If something is wrong , Welcome to point out .

copyright notice
author[Monster NM],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262341328980.html

Random recommended