如何发布的APK到Maven的中央与摇篮? [英] How to publish apks to the Maven Central with gradle?
本文介绍了如何发布的APK到Maven的中央与摇篮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了Android工作室的Android项目。
这将产生一定的apk。
如何发布的APK到Maven的中央与摇篮?
我可以写在器物的APK?
应用插件:行家
应用插件:签约
配置{
档案 {
extendsFrom configurations.default
}
}
afterEvaluate {项目 - >
uploadArchives {
库{
mavenDeployer {
configurePOM(POM)
beforeDeployment {MavenDeployment部署 - > signing.signPom(部署)}
库(网址:sonatypeRepositoryUrl){
认证(用户名:nexusUsername,密码:nexusPassword)
}
}
}
}
......
文物{
档案文件:文件(导演:'。$ buildDir / APK / * APK,包括:* .apk文件)
//档案androidReleaseApklib
档案androidReleaseJar
档案androidSourcesJar
档案androidJavadocsJar
}
}
解决方案
我们发布我们的APK文件到本地的Nexus库使用摇篮。这是我想出来的。这个例子证明了使用googlePlay打造的味道。
//确保发布版本进行之前,我们尽量快点上传。
uploadArchives.dependsOn(getTasksByName(assembleRelease,真))
//创建一个知道如何处理APK文件的存档类。
// APK文件只是改名罐。
一流的.apk扩展罐{
DEF STRING getExtension(){
回归APK
}
}
//创建一个使用我们的apk任务类的任务。
任务googlePlayApk(类型:的.apk){
分类='googlePlay
从文件($ {project.buildDir} /outputs/apk/myApp-googlePlay-release.apk)
}
//添加项目到文物
文物{
档案googlePlay
}
I create an android project with android studio.
It will generate some apks.
How can i publish apks to the Maven Central with gradle?
What can i write in the artifacts for the 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. This is what I've come up with. This example demonstrated using a "googlePlay" build flavor.
// 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
}
这篇关于如何发布的APK到Maven的中央与摇篮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文