繁体   English   中英

如何使用gradle将apks发布到Maven Central?

[英]How to publish apks to the Maven Central with gradle?

我用android studio创建了一个android项目。

它会产生一些apks。

如何用gradle将apks发布到Maven Central?

我可以在apk的文件中写什么?

apply plugin: 'maven'
apply plugin: 'signing'

configurations {
    archives {
        extendsFrom configurations.default
    }
}

afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                configurePOM(pom)
                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

                repository(url: sonatypeRepositoryUrl) {
                    authentication(userName: nexusUsername, password: nexusPassword)
                }
            }
        }
    }

......

    artifacts {
       archives file: files(dir: '$buildDir/apk/*.apk', include: '*.apk')
        // archives androidReleaseApklib
        archives androidReleaseJar
        archives androidSourcesJar
        archives androidJavadocsJar
    }
}

我们使用gradle将APK文件发布到我们的本地Nexus存储库。 这就是我想出来的。 此示例演示了使用“googlePlay”构建风格。

// make sure the release builds are made before we try to upload them.    
uploadArchives.dependsOn(getTasksByName("assembleRelease", true))

// create an archive class that known how to handle apk files.
// apk files are just renamed jars.
class Apk extends Jar {
    def String getExtension() {
        return 'apk'
    }
}

// create a task that uses our apk task class.
task googlePlayApk(type: Apk) {
    classifier = 'googlePlay'
    from file("${project.buildDir}/outputs/apk/myApp-googlePlay-release.apk")
}

// add the item to the artifacts
artifacts {
    archives googlePlay
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM