android通过gradle发布lib到sonatype平台

1.gradle版本4.0.1

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

在这里插入图片描述

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:git@gitee.com:vvv.git'
                            developerConnection 'scm:git:git@gitee.com: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 'fz@126.com'
                            }
                        }
                    }
                }
            }
        }
    }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值