27

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

msrd0
  • 7,816
  • 9
  • 47
  • 82
ligi
  • 39,001
  • 44
  • 144
  • 244
  • Hey, we got the same issue with our project and AS https://jitpack.io/com/github/gnosis/svalinn-kotlin/ethereum-rpc/feature~fix_estimate-v0.2.3-g8d4f5ae-5/. Did you find any solution or maybe open a issue on the AS issue tracker? – Wicket Mar 13 '18 at 21:02
  • 1
    It seems to work for us in tagged releases now (only extensions are broken) – Wicket Mar 13 '18 at 21:21
  • interesting - thanks for the data-point. Which AS version are you using? Are you coming to the crypto lunch tomorrow? Think it would be great to meet again anyway ;-) – ligi Mar 13 '18 at 23:25
  • This issue shows up when posting to Maven Central as well. – Johann Sep 02 '21 at 07:07

1 Answers1

0

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.

rtsketo
  • 1,168
  • 11
  • 18
  • In addition, as this post mention Kotlin libraries, you can also specify the srcDirs for Kotlin. by changing the from to " from (android.sourceSets.main.java.sourceFiles, android.sourceSets.main.kotlin.sourceFiles) " – Loïc Dumas Jun 14 '22 at 14:58