android发布sdk到maven仓库

57 阅读1分钟

publishing {

// def publishType = 0 // 0是release 1 是snapshot ext.publishType = 0 String publish_type = project.getProperties().get("publish_type") if (publishType != null) { ext.publishType = Integer.parseInt(publish_type) }

repositories { maven { allowInsecureProtocol = true url = publishType == 0 ? "xxxxxxxxxx/" : "xxxxxxxxxxxxx/" } }

// 配置发布产物 publications { PublicationContainer publication -> // 名称可以随便定义,这里定义成 maven,是因为我的 aar 包是发布到 maven 仓库的,所以这里为了见名知义,定义成了 maven println("publish type: " + publishType) if (publishType == 0) { release(MavenPublication) {// 容器可配置的信息 MavenPublication // 依赖 bundleReleaseAar 任务,并上传其产出的aar afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) } groupId = "com.example.demo" artifactId = "test" version = "1.0.0" } } else { debug(MavenPublication) {// 容器可配置的信息 MavenPublication // 依赖 bundleDebugAar 任务,并上传其产出的aar afterEvaluate { artifact(tasks.getByName("bundleDebugAar")) } groupId = "com.example.demo" artifactId = "test" version = "1.0.0-SNAPSHOT" } } } }