How can I exclude a package from publication using sbt?

I want to publish a library that has some usage examples in runnable classes. When I call sbt run, he finds them and asks which of the main classes I found I want, and then starts it. This is neat, I would like this behavior to remain. But these examples complicate my Android build (more proguard configurations), so I don’t want to publish their artifacts.

Currently, I completely exclude them by putting this in build.sbt:

excludeFilter in Compile ~= { _ ||
  new FileFilter {
    def accept(f: File) = f.getPath.containsSlice("/examples/")
  } }

then when I start sbt publish-local, I get jars without examples, but then it is impossible to get the library source and see how it works, just by typing sbt run. How can I exclude the sample package only from the publication, but let it still be compiled for local launches?

+4
source share
1 answer

I would recommend breaking the examples into other subprojects instead.

0
source

All Articles