Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin sources are not packaged with sbt publish #38

Open
unoexperto opened this issue Dec 9, 2019 · 2 comments
Open

Kotlin sources are not packaged with sbt publish #38

unoexperto opened this issue Dec 9, 2019 · 2 comments

Comments

@unoexperto
Copy link

unoexperto commented Dec 9, 2019

@pfn
I noticed that Kotlin sources are not packaged with sbt publish or publishLocal. As result my maven source artifact is empty. Could you please suggest how I can fix it ?

Here is what I tried so far
https://stackoverflow.com/questions/59256494/how-do-i-make-sbt-include-non-java-sources-to-published-artifact

@makiftutuncu
Copy link

It affects me for javadoc artifact too. Any updates on this?

@makiftutuncu
Copy link

To workaround this, I made following: https://github.com/makiftutuncu/e/blob/master/project/Settings.scala#L105

Basically, I added following setting in SBT to properly generate sources artifact:

// Include Kotlin files in sources
    packageConfiguration in Compile := {
      val old = (packageConfiguration in Compile in packageSrc).value
      val newSources = (sourceDirectories in Compile).value.flatMap(_ ** "*.kt" get)

      new Package.Configuration(
        old.sources ++ newSources.map(f => f -> f.getName),
        old.jar,
        old.options
      )
    }

For the documentation artifact, I added Gradle build to my Kotlin module. I set it up as shown here https://github.com/makiftutuncu/e/blob/master/e-kotlin/build.gradle.kts. This way, I make Gradle build generate the Dokka documentation. And finally, added following setting in SBT to run Gradle while building docs:

// Delegate doc generation to Gradle and Dokka
    doc in Compile := {
      import sys.process._
      Process(Seq("./gradlew", "dokkaJavadoc"), baseDirectory.value).!
      target.value / "api"
    }

I admit, this is a lot of work just to get 2 artifacts but it did the trick for me. 🤷🏻 Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants