将带有kotlin dsl的android库发布到maven存储库

问题描述 投票:0回答:1

我有一个用Kotlin编写的Android库。其build.gradle文件使用kotlin-dsl编写。我想发布由Jfrog提供支持的自己的Maven存储库。图书馆已成功发布,但是我无法通过示例应用程序访问我的图书馆。

这是我的图书馆gradle文件。这些版本号是从buildSrc模块获取的。

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

android {
    compileSdkVersion Android.compileSdk

    defaultConfig {
        minSdkVersion Android.minSdk
        targetSdkVersion Android.targetSdk
        versionCode Android.versionCode
        versionName Android.versionName
    }

    buildTypes {
        release {
            minifyEnabled true
        }
    }

    dataBinding {
        enabled = true
    }
}

dependencies {
    api AndroidX.appCompat
    api AndroidX.recyclerView
    api AndroidX.motionLayout
    api Libraries.rxAndroid
    api Libraries.material
    api Libraries.koin
    api Libraries.koinScope
    api Libraries.koinViewModel
    api Libraries.lifecycleExtensions
    api Libraries.ktxCore
}

def libraryGroupId = 'com.abc.framework'
def libraryArtifactId = 'ui'
def libraryVersion = '0.0.1-SNAPSHOT'

publishing {
    publications {
        aar(MavenPublication) {
            groupId libraryGroupId
            version libraryVersion
            artifactId libraryArtifactId

            artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
        }
    }
}

artifactory {
    contextUrl = 'http://mymavenrepo.com:8081/artifactory'
    publish {
        repository {
            repoKey = 'libs-snapshot-local'

            username = artifactory_username
            password = artifactory_password
        }
        defaults {
            publications('aar')
            publishArtifacts = true

            properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
            publishPom = true
        }
    }
}

这是我的示例应用程序gradle文件。

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.abc.sampleapp"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.abc.framework:ui:0.0.1-SNAPSHOT"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
android maven gradle kotlin dsl
1个回答
0
投票

删除library.gradle文件中的“ minifyEnabled = true”解决了该问题。

© www.soinside.com 2019 - 2024. All rights reserved.