android 更改档案名称,如何上传多个android档案(每个档案一个)

我正在尝试使用maven gradle插件为每个项目上传多个工件:

53.6.4.1. Multiple artifacts per project

Maven can only deal with one artifact per project. This is reflected in the structure of the Maven POM. We think there are many situations where it makes sense to have more than one artifact per project. In such a case you need to generate multiple POMs. In such a case you have to explicitly declare each artifact you want to publish to a Maven repository. The MavenDeployer and the MavenInstaller both provide an API for this:

Example 53.9. Generation of multiple poms

build.gradle

uploadArchives {

repositories {

mavenDeployer {

repository(url: "file://localhost/tmp/myRepo/")

addFilter('api') {artifact, file ->

artifact.name == 'api'

}

addFilter('service') {artifact, file ->

artifact.name == 'service'

}

pom('api').version = 'mySpecialMavenVersion'

}

}

}

You need to declare a filter for each artifact you want to publish. This filter defines a boolean expression for which Gradle artifact it accepts. Each filter has a POM associated with it which you can configure. To learn more about this have a look at PomFilterContainer and its associated classes.

我真正要做的是上传不同档案的不同档案.

这是我的项目build.gradle文件:

apply plugin: 'com.android.library'

apply plugin: 'maven'

group 'com.test'

version '0.0.1'

android {

compileSdkVersion 19

buildToolsVersion "21.1.1"

defaultConfig {

minSdkVersion 14

targetSdkVersion 19

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

}

}

lintOptions {

abortOnError false

}

productFlavors {

flavor1 { }

flavor2 { }

}

packagingOptions {

exclude 'META-INF/LICENSE'

exclude 'META-INF/LICENSE.txt'

exclude 'META-INF/NOTICE'

exclude 'META-INF/NOTICE.txt'

}

}

uploadArchives {

repositories {

mavenDeployer {

repository(url: "file://${System.properties['user.home']}/.m2/repository")

addFilter('debugFlavor1') { artifact, file ->

artifact.name.contains("debugFlavor1")

}

addFilter('releaseFlavor1') { artifact, file ->

artifact.name.contains("releaseFlavor1")

}

addFilter('debugFlavor2') { artifact, file ->

artifact.name.contains("debugFlavor2")

}

addFilter('releaseFlavor2') { artifact, file ->

artifact.name.contains("releaseFlavor2")

}

pom('debug').artifactId = ${artifactId} + "-" ${flavor} + "-debug"

pom('release').artifactId = ${artifactId} + "-" ${flavor}

}

}

}

dependencies {

compile 'com.android.support:support-v4:21.0.2'

compile 'org.apache.commons:commons-lang3:3.3.2'

}

这样的事情可能吗?

如何在每个发布中获得artifactId和flavor?我使用${artifactId}和${flavor}作为占位符,但我知道这是不对的.

编辑:

好吧,我想出了如何为每种口味获得不同的神器.其中一个关键是设置:

publishNonDefault true

但是,当我这样做时,我没有得到每个工件的pom文件.我有传递依赖,需要被拉进去,我不认为他们会在没有pom的情况下被拉进去.

这是我当前的gradle脚本,如何为每个脚本生成一个pom.

apply plugin: 'com.android.library'

apply plugin: 'maven'

group 'com.test'

version '0.0.1'

android {

compileSdkVersion 19

buildToolsVersion "21.1.1"

publishNonDefault true

defaultConfig {

minSdkVersion 14

targetSdkVersion 19

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

}

}

lintOptions {

abortOnError false

}

packagingOptions {

exclude 'META-INF/LICENSE'

exclude 'META-INF/LICENSE.txt'

exclude 'META-INF/NOTICE'

exclude 'META-INF/NOTICE.txt'

}

productFlavors {

flavor1 {}

flavor2 {}

}

}

uploadArchives {

repositories {

mavenDeployer {

repository(url: "file://${System.properties['user.home']}/.m2/repository")

addFilter('flavor1Release') { artifact, file ->

artifact.attributes.classifier.equals("flavor1Release")

}

addFilter('flavor2Release') { artifact, file ->

artifact.attributes.classifier.equals("flavor2Release")

}

pom('flavor1Release').artifactId = project.archivesBaseName + "-flavor1"

pom('flavor2Release').artifactId = project.archivesBaseName + "-flavor2";

}

}

}

dependencies {

compile 'com.android.support:support-v4:21.0.2'

compile 'org.apache.commons:commons-lang3:3.3.2'

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值