Sbt: publishing generated sources

I have a project in which part of the sources is generated ( sourceGenerators in Compile). I noticed that (in most scenarios it is reasonable) these sources are not published with publishLocalor publishSigned. In this case, this is unfortunate, because when you use this project / library as a dependency, you cannot search for sources, for example, in IntelliJ, even if other project sources have been loaded.

Can I configure sbt publishing options to include generated sources in Maven -sources.jar?

+4
source share
2 answers
mappings in (Compile,packageSrc) := (managedSources in Compile).value map (s => (s,s.getName)),
+4
source

So, to be complete, this was my solution based on @pfn's answer:

mappings in (Compile, packageSrc) ++= {
  val base  = (sourceManaged  in Compile).value
  val files = (managedSources in Compile).value
  files.map { f => (f, f.relativeTo(base).get.getPath) }
}
+6

Source: https://habr.com/ru/post/1616235/


All Articles