我用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
}
}
答案 0 :(得分:1)
我们使用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
}