android - 将源附加到 kotlin 库项目不显示在 AS

标签 android android-studio kotlin jitpack

我想将源附加到一个 kotlin 库项目中,看起来我成功了,因为我现在在这里有源 jar:

https://jitpack.io/com/github/walleth/kethereum/bip44/0.21/

我没有导出源之前的版本 - 所以我认为它是成功的。

https://jitpack.io/com/github/walleth/kethereum/bip44/0.20/

不幸的是,AS 没有显示来源。我正在像这样生成它们:

allprojects {
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
    }

    apply plugin: "kotlin"
    apply plugin: "jacoco"
    apply plugin: "maven"
    apply plugin: "com.github.ben-manes.versions"

    dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

        testCompile 'org.assertj:assertj-core:3.8.0'
        testCompile 'junit:junit:4.12'
    }

    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }

    task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier = 'javadoc'
        from javadoc.destinationDir
    }

    artifacts {
        archives sourcesJar
        archives javadocJar
    }
}

source-jars 也包含 kotlin 文件。
这一切都在这个项目中:https://github.com/walleth/kethereum

最佳答案

这就是我们为 Maven Publication 所拥有的。

task androidSourcesJar(type: Jar) {
    archiveClassifier.set('sources')
    from android.sourceSets.main.java.srcDirs
}

然后你可以使用 artifact androidSourcesJar .

关于android - 将源附加到 kotlin 库项目不显示在 AS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46565591/

相关文章:

android - 通过库中的 Intent 启动应用程序主 Activity 时出错

java - IllegalStateException textview 在 Kotlin 中不能为 null

android - Jetpack Compose TextField 剪切滚动条上的文本

android - 如何判断应用程序是否在后台?

android - 运行 Android 应用程序时出现错误 "The connection to adb is down"

Android Studio 找不到 com.android.tools.build :gradle:4. 0.1。错误

安卓工作室要求

android - Jacoco gradle 'exclude'无法在Kotlin的Android项目中使用

spring-boot - 为什么我的Spring Boot应用程序不在 mustache 模板中呈现messages.properties

intellij-idea - 包含的Gradle脚本Kotlin文件的IntelliJ自动补全