我是android Bintray上传脚本的新手。我写build.gradle
如
我的库.aar
和.jar
文件使用自定义名称生成。在本地我建立的项目工作正常。但我运行Bintray任务它上传.aar
文件,并附加-debug
字到文件名。
我不知道我错在哪里。请帮我。
我的build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray"
version "1.7.3"
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.kickdrill'
version = '0.1.1.0.1'
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
publishNonDefault true
compileSdkVersion 23
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName version
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
android.libraryVariants.all {
variant - >
variant.outputs.each {
output - >
def alignedOutputFile = variant.outputs[0].outputFile
// def unalignedOutputFile = output.packageApplication.outputFile
logger.warn('You got to variant: ' + variant + ' and output: ' + output)
// Customise APK filenames (to include build version)
if (variant.buildType.zipAlignEnabled) {
// normal APK
output.outputFile = new File(alignedOutputFile.parent, alignedOutputFile.name.replace("-debug.aar", "-" + defaultConfig.versionName + ".aar"))
}
// 'unaligned' APK
}
}
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
android.libraryVariants.all {
variant - >
variant.outputs.each {
output - >
def alignedOutputFile = variant.outputs[0].outputFile
// def unalignedOutputFile = output.packageApplication.outputFile
logger.warn('You got to variant: ' + variant + ' and output: ' + output)
// Customise APK filenames (to include build version)
if (variant.buildType.zipAlignEnabled) {
// normal APK
output.outputFile = new File(alignedOutputFile.parent, alignedOutputFile.name.replace("-release.aar", "-" + defaultConfig.versionName + ".aar"))
}
// 'unaligned' APK
}
}
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support',
module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.android.support:design:23.4.0'
testCompile 'junit:junit:4.12'
}
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives generateSourcesJar
}
bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
configurations = ['archives']
pkg {
repo = 'androidkickdrill'
name = 'easyandroid'
userOrg = 'androiddevs'
licenses = ['Apache-2.0']
publish = true
vcsUrl = 'https://github.com/kickdrilldev/KickDrillDevs'
version {
name = 'androidkickdrill'
desc = 'its for an android developer'
vcsTag = version
attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
}
答案 0 :(得分:2)
在您当前的配置中,您已将publishNonDefault
设置为true
,这意味着您要上传所有变体(debug
和release
)。如果您只想上传release
,请删除此行:
publishNonDefault true
仅上传版本变体:app-1.0.aar
将被上传。
如果您希望上传debug
和release
个变体,则无需执行任何操作,因为版本名称将显示在已发布的变体中:app-<version>-<variant>.aar
。在此删除-<variant>
并不重要,因为您无法区分已发布的变体。
如果要包含jar源和javadoc,可以添加以下内容:
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
在Bintray,它看起来像: