[英]How to publish apks to the Maven Central with gradle?
I create an android project with android studio. 我用android studio创建了一个android项目。
It will generate some apks. 它会产生一些apks。
How can i publish apks to the Maven Central with gradle? 如何用gradle将apks发布到Maven Central?
What can i write in the artifacts for the apk? 我可以在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
}
}
We publish our APK files to our local Nexus repository using gradle. 我们使用gradle将APK文件发布到我们的本地Nexus存储库。 This is what I've come up with.
这就是我想出来的。 This example demonstrated using a "googlePlay" build flavor.
此示例演示了使用“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.