我用 android studio 创建了一个 android 项目。
它会生成一些apk。
如何使用 gradle 将 apk 发布到 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
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)