android - 从 TravisCI 将 Android aar 库上传到 bintray

标签 android gradle travis-ci bintray

这是我第一次尝试向 maven 发布内容,但我有一个 Android 库,我正在尝试与 TravisCI 集成当任何事情都被推到掌握时构建它查看 Bintray gradle documentation连同我发现的一些关于两者之间集成的文章,我为我的 build.gradle 想出了这个文件

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

    publishing {
        publications {
            Production(MavenPublication) {
                artifact("$buildDir/outputs/aar/mlcamera-release.aar")
                groupId 'com.tycz'
                artifactId 'mlcamera'
                version '0.1.0'

                //The publication doesn't know about our dependencies, so we have to manually add them to the pom
                pom.withXml {
                    //def dependenciesNode = asNode().appendNode('dependencies')
                    //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
                    configurations.compile.allDependencies.each {
                        if (it.name != 'unspecified') {
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', it.group)
                            dependencyNode.appendNode('artifactId', it.name)
                            dependencyNode.appendNode('version', it.version)
                        }
                    }
                }
            }
        }
    }

    bintray {
        // Get Bintray credential from environment variable
        user = System.getenv('BINTRAY_USER')
        key = System.getenv('BINTRAY_API_KEY')
        dryRun = false
        override = false
        publish = true
        pkg {
            repo = 'MLCamera'
            name = project.name
            userOrg = 'tyczj359'
            desc = 'A wrapper library for the new CameraX API and Firebase MLKit to create easier setup for MLKit usage'
            vcsUrl = 'https://github.com/tyczj/MLCamera.git'

            version {
                name = '0.1.0'
                released = new Date()
            }
        }
        publications = ['Production']
    }

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"


    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "0.1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
    implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'
    implementation 'com.google.firebase:firebase-ml-vision-object-detection-model:19.0.3'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation "androidx.camera:camera-core:1.0.0-beta01"
    implementation "androidx.camera:camera-camera2:1.0.0-beta01"
    implementation "androidx.camera:camera-view:1.0.0-alpha08"
    implementation "androidx.camera:camera-lifecycle:1.0.0-beta01"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

该库本身似乎在 travis 中构建得很好,但是当我查看我的 bintray 存储库时,我发现那里什么都没有。

这是我的yml在 travis 上构建的文件
language: android
jdk: oraclejdk8
dist: trusty

android:
  components:
    - build-tools-29.0.3
    - android-29
    - extra-google-m2repository
    - extra-android-m2repository
    - extra-google-google_play_services
script:
  - ./gradlew build
before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    - $HOME/.android/build-cache

任何人都可以在这里帮助我将其发布到 bintray 吗?

这是完整的repo任何人都需要别的东西

最佳答案

特拉维斯 yml文件仅构建 aar但未按照 script 发布命令 ./gradlew build .将其更改为 ./gradlew build bintrayUpload应该像第 8 步 here .

关于android - 从 TravisCI 将 Android aar 库上传到 bintray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60627483/

相关文章:

android - layout_alignParentBottom 不起作用

android-studio - 使用 android studio 构建缓慢

android - 我应该在 Android Studio 的 Gradle 中将一些依赖项移动到 `runtime` 吗?

travis-ci - 忽略 postgresql 的 .travis.yml 版本设置

shell - 如何使用 Travis CI 环境变量 + .sh 脚本自动部署到 Github Pages?

android - 无法运行项目应用程序(Gradle 构建失败)

android - 从安卓市场安装。未知原因 102

android - 底部导航 View 的自定义形状(Android)?

android - android中的不同口味

github - 在哪里可以下载 64 位 Travis-CI VM 镜像?