maven android 多模块,Gradle和Android:包含多个Maven构件的pom配置出版物

使用Gradle(v 1.7)作为构建工具处理Android库时,我使用了maven插件并配置了任务uploadArchives以发布发行版和调试版lib到本地的maven仓库。

下面的代码工作正常:Gradle和Android:包含多个Maven构件的pom配置出版物

// [...]

apply plugin: 'android-library'

// [...] nothing unusual

/*

* Define name of the apk output file (build/apk/)

*/

android.libraryVariants.all

{

variant ->

def outputName = "MyModule-${android.defaultConfig.versionName}-${variant.baseName}.aar"

variant.outputFile = new File("$buildDir/libs", outputName)

}

/*

* Publish to maven local repo (older style maven plugin)

* Used while android plugin is not fixed regarding maven-publish plugin

*

* type command "gradle uploadArchives" to publish the module into the

* local .m2 repository

*/

apply plugin: 'maven'

android.libraryVariants.all

{

variant ->

// add final apk to the 'archives' configuration

project.artifacts

{

archives variant.outputFile

}

}

def localRepoPath = "file://" + new File(

System.getProperty("user.home"), ".m2/repository").absolutePath

uploadArchives

{

repositories.mavenDeployer

{

repository(url: localRepoPath)

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

artifact.name.contains("debug")

}

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

artifact.name.contains("release")

}

pom('debug').groupId = 'com.company'

pom('release').groupId = 'com.company'

pom('debug').artifactId = 'id'

pom('release').artifactId = 'id'

pom('debug').version = android.defaultConfig.versionName + "d"

pom('release').version = android.defaultConfig.versionName

pom.packaging = 'aar'

}

}

uploadArchives.dependsOn(assemble)

然而,当试图重构POM配置:

uploadArchives

{

repositories.mavenDeployer

{

repository(url: localRepoPath)

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

artifact.name.contains("debug")

}

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

artifact.name.contains("release")

}

pom.groupId = 'com.company'

pom.artifactId = 'id'

pom('debug').version = android.defaultConfig.versionName + "d"

pom('release').version = android.defaultConfig.versionName

pom.packaging = 'aar'

}

}

的artifactId被扩展为输出文件的名称,并的groupId为根目录的名称;从而给maven回购提供了不好的途径。

我想知道这是为什么,也许如果有一个更清晰的方式来实现我所需要的。

2013-08-23

mklj

+0

在我的项目中,我需要重命名输出'.aar'。因此,我在用于'artifactId'的'build.gradle'中设置了'archivesBaseName'。也许这有帮助。 –

+0

你有想过吗? –

+0

@YuchenZhong不幸的是,这项工作是短期实习的一部分。我不知道谁负责这个项目,因此从那以后如何处理。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值