Kotlin项目使用Maven Publish Plugin发布aar包到maven仓库中添加(debug)源码支持

本文使用插件 Maven Publish Plugin发布aar。

不废话,直接上代码。将注释中标注的1、2两段代码加入到对应的gradle代码行中

apply plugin: 'maven-publish'

// 1.将源码打包任务
task androidSourcesJar(type: Jar) {
    archiveClassifier.set('sources')
    from android.sourceSets.main.java.srcDirs
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId = ''
                artifactId = ''
                version = '0.0.1'

                // 2.将源码打包到aar中
                artifact(androidSourcesJar)
            }
        }
        repositories {
            maven {
                allowInsecureProtocol = true
                name = "privateNexus"
                url = ""
                credentials {
                    username = ''
                    password = ''
                }
            }
        }
    }
}

猜你喜欢

转载自blog.csdn.net/u012218652/article/details/125636685