android通过gradle发布lib到sonatype平台

1.gradle版本4.0.1

2.提前在sonatype平台创建好账号的配置信息.

android通过gradle发布lib到sonatype平台_第1张图片

3.gradle.properties配置信息

#--------------------------秘钥配置--------------------------------------------------
#GPG秘钥ID
signing.keyId=后八位
#GPG秘钥密码
signing.password=密码
#GPG秘钥文件路径
signing.secretKeyRingFile=file://D://android/gpg/sign/xxxx.gpg

#sonatype平台账号信息
NEXUS_USERNAME=账号
#nexus的密码
NEXUS_PASSWORD=密码

4.ideal配置信息如下:

apply plugin: 'com.android.library'

        apply plugin: 'maven'
        apply plugin: 'signing'
        task javadocJar(type: Jar) {
            classifier 'javadoc'
            from android.sourceSets.main.java.srcDirs
        }

        task sourcesJar(type: Jar) {
            classifier 'sources'
            from android.sourceSets.main.java.srcDirs
        }

        artifacts {
            archives javadocJar, sourcesJar
        }


android {
    compileSdkVersion 29
    buildToolsVersion "30.0.3"

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "V1.0.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}

        sourceCompatibility = 1.8

        signing {
            sign configurations.archives
        }

        group = com.gitee.xx
        archivesBaseName = photo
        version = 1.0.0
        if(isSNAPSHOT){
            version+="-SNAPSHOT"
        }

        uploadArchives {
            repositories {
                mavenDeployer {
                beforeDeployment {
                    MavenDeployment deployment -> signing.signPom(deployment)
                }

                    repository(url: "https://s01.oss.sonatype.org/content/repositories/releases/") {
                        authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
                    }

                    snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
                        authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
                    }

                    pom.project {
                        name 'VinRichard'
                        packaging 'jar'
                        // optionally artifactId can be defined here
                        description 'A application used as an example on how to set up  pushing its components to the Central Repository . '
                        url 'https://gitee.com/vvv'

                        scm {
                            connection 'scm:git:[email protected]:vvv.git'
                            developerConnection 'scm:git:[email protected]:vvv.git'
                            url 'https://gitee.com/vv'
                        }

                        licenses {
                            license {
                                name 'The Apache License, Version 2.0'
                                url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                            }
                        }

                        developers {
                            developer {
                                id 'VinRichard'
                                name 'vinrichard'
                                email '[email protected]'
                            }
                        }
                    }
                }
            }
        }
    }




你可能感兴趣的:(Android,android,java,android发布lib)