Attach sources to kotlin library project don't

2020-07-02 03:32发布

问题:

I want to attach the sources to an kotlin library project and it looks I succeeded as I have the source-jars now in here:

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

the version before I did not export the sources - so I thought it is successful.

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

Unfortunately AS does not show the sources. I am generating them like this:

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
    }
}

Also the source-jars contain the kotlin files. It is all in this project: https://github.com/walleth/kethereum

回答1:

This is what we have for Maven Publication.

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

And then you can use artifact androidSourcesJar.