如何使用 -debug.aar 文件名删除 bintray 上传文件
how remove bintray upload file with -debug.aar filename
我是 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']
}
}
}
在您当前的配置中,您已将 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 中,它看起来像:
我是 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']
}
}
}
在您当前的配置中,您已将 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 中,它看起来像: