Gradle (v 1.7)을 빌드 도구로 사용하여 Android 라이브러리에서 작업하면서, 저는 Maven 플러그인을 사용하여 uploadArchives 작업을 구성하여 릴리스 및 디버그 버전을 모두 게시했습니다. lib를 로컬 Maven 저장소에 저장합니다.
아래 코드는 확인 작동합니다Gradle and Android : 다중 Maven 아티팩트가있는 구성 게시
// [...]
apply plugin: 'android-library'
// [...] nothing unusual
/*
* Define name of the apk output file (build/apk/<outputFile>)
*/
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)
을하지만, 치어 구성 리팩토링 할 때 :로 출력 파일의 이름으로 확장
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을 루트 디렉토리의 이름. 따라서 메이븐 레포에 나쁜 경로를 제공합니다.
왜 그런지 알고 싶습니다. 그리고 내가 원하는 것을 얻기위한 더 깨끗한 방법이 있다면 어떨까요?
내 프로젝트에서 나는'.aar' 출력의 이름을 바꾸라는 요구 사항이있었습니다. 그러므로'artifactId'에 사용되는'build.gradle'에'archivesBaseName'을 설정했습니다. 아마 이것은 도움이 될 것입니다. – JJD
이것을 알아 냈습니까? –
@YuchenZhong 불행히도이 작품은 단기 인턴쉽의 일부분이므로 아니요. 나는 누가 프로젝트를 담당했는지, 그리고 이후로 어떻게 처리되었는지를 모른다. – mklj