发布的Android库(AAR)到Bintray与选择的口味 [英] Publishing Android Library (aar) to Bintray with chosen flavors
问题描述
我中庸之道添加了一些味道
(或 productFlavors
如果你想)到我的项目。
的事实是,当我发布库的 bintray ,所有的味道都上传(这是伟大的),但我无法使用它们。使用该插件是官方这里。
上传的AAR:
androidsdk-0.0.4-fullRelease.aar
androidsdk-0.0.4-fullDebug.aar
androidsdk-0.0.4-lightRelease.aar
androidsdk-0.0.4-lightDebug.aar
正如您所指出的, fullRelease
被命名为分类
,看到的doc章23.4.1.3 。
我正在寻找一个解决方案,选择我要上传其风味。
我已经看了bintray实例(<一个href=\"https://github.com/bintray/bintray-examples/blob/master/gradle-bintray-plugin-examples/publications-example/build.gradle\">here和<一个href=\"https://github.com/bintray/bintray-examples/blob/master/gradle-aar-example/build.gradle\">here)和<一个href=\"http://stackoverflow.com/questions/27160087/how-to-upload-multiple-android-archives-one-for-each-flavor\">this,与其他同样的例子,但我仍然坚持。
下面是我当前的脚本:
应用插件:'com.android.library
应用插件:'com.github.dcendents.android-行家
应用插件:'com.jfrog.bintraybuildscript {
库{
jcenter()
}
}安卓{
compileSdkVersion 23
buildToolsVersion23.0.1 defaultConfig {
9的minSdkVersion
targetSdkVersion 23
版本code 64
的versionName0.0.4
} publishNonDefault真 productFlavors {
全{
}
光{
}
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
编译com.android.support:appcompat-v7:23.1.1
编译com.android.support:recyclerview-v7:23.1.1
fullCompile'com.squareup.picasso:毕加索:2.5.0
}版本= android.defaultConfig.versionNameuploadArchives {
repositories.mavenDeployer {
pom.project { 包装AAR }
}
}////////////////////////////////
// Bintray上传配置属性属性=新的属性()
properties.load(project.rootProject.file('local.properties')。newDataInputStream())bintray {
用户= properties.getProperty(bintray.user)
键= properties.getProperty(bintray.apikey) 配置= ['档案']
PKG {
回购=MyRepo//回购名称
userOrg ='胡戈'
NAME =AndroidSDK//包名称
websiteUrl = SITEURL
vcsUrl = gitUrl
发布=真
}
}
要导入目前我使用这个库:
编译('com.example.lib:SDK:0.0.8:fullRelease @ AAR'){
传递= TRUE;
}
我没有尝试,所以我会删除答案,如果不解决这个问题。
您应该张贴针对每种口味不同的工件(或建造变种,如果你preFER)。结果
这样,你会在jcenter x文物,他们每个人有一个POM文件。
是这样的:
的groupId
| --library满
| ---- POM
| ---- AAR
| --library光
| ---- POM
| ---- AAR
在您的顶层文件,你可以定义
allprojects {
库{
jcenter()
} project.ext {
的groupId =XXX
库名称=
......
}
}
那么你的库模块中:
productFlavors {
全{
project.ext.set(库名称,库已满);
}
光{
project.ext.set(库名称,图书馆之光);
}
}bintray { // ...
PKG {
//...Do其他变量相同
名称= project.ext.libraryName
}
}
最后,确认只发布发布版本类型(为什么还调试版本?)
I've juste added some flavors
(or productFlavors
if you want) to my project.
The fact is that when I publish the library to bintray, all flavors are uploaded (which is great), but I'm unable to use them. The plugin used is the official one here.
The uploaded aar:
androidsdk-0.0.4-fullRelease.aar
androidsdk-0.0.4-fullDebug.aar
androidsdk-0.0.4-lightRelease.aar
androidsdk-0.0.4-lightDebug.aar
As you noted, the fullRelease
is named as the classifier
, see doc chapter 23.4.1.3.
I am searching for a solution to choose which flavors that I want to upload.
I've already looked at bintray examples (here and here) and this, with also other examples but I'm still stuck.
Here is my current script:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
buildscript {
repositories {
jcenter()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 64
versionName "0.0.4"
}
publishNonDefault true
productFlavors {
full {
}
light {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
fullCompile 'com.squareup.picasso:picasso:2.5.0'
}
version = android.defaultConfig.versionName
uploadArchives {
repositories.mavenDeployer {
pom.project {
packaging 'aar'
}
}
}
////////////////////////////////
// Bintray Upload configuration
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "MyRepo" // repo name
userOrg = 'hugo'
name = "AndroidSDK" // Package name
websiteUrl = siteUrl
vcsUrl = gitUrl
publish = true
}
}
To import the library I'm currently using this:
compile ('com.example.lib:sdk:0.0.8:fullRelease@aar') {
transitive = true;
}
I didn't try it so I will delete the answer if it doesn't resolve the issue.
You should post a different artifact for each flavor (or build variant if you prefer).
In this way you will have in jcenter x artifacts, each of them with a pom file.
Something like:
groupId
|--library-full
|----.pom
|----.aar
|--library-light
|----.pom
|----.aar
In your top level file you can define
allprojects {
repositories {
jcenter()
}
project.ext {
groupId="xxx"
libraryName = ""
......
}
}
Then in your library module:
productFlavors {
full {
project.ext.set("libraryName", "library-full");
}
light {
project.ext.set("libraryName", "library-light");
}
}
bintray {
//...
pkg {
//...Do the same for other variables
name = project.ext.libraryName
}
}
Finally make sure to publish only the release build type (why also the debug version?)
这篇关于发布的Android库(AAR)到Bintray与选择的口味的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!