Powers
Powers

Reputation: 19328

sbt package: exclude Python files in JAR file

I'd like to figure out how to excluded the Python files from the JAR file generated by the sbt package command.

The Delta lake project uses SBT version 0.13.18 and the JAR file is built with sbt package.

The directory structure is as follows:

python/
  delta/
    testing/
      utils.py
  tests/
    test_sql.py
src/
  main/
    ...scala files
build.sbt
run-tests.py

It follows the standard SBT project structure with a couple of Python files added in.

The Python files are included in the JAR file when sbt package is run and I'd like to figure out how to exclude all the Python files.

Here's what I tried adding to the build.sbt file:

  1. mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith("py")) } per this answer
  2. excludeFilter in Compile := "*.py" per this answer

Neither of these worked.

Upvotes: 1

Views: 239

Answers (1)

Nik
Nik

Reputation: 300

Haven't tested it, but I think something like this when you make a fat jar.

assemblyMergeStrategry in assembly := {
  case PathList(parts @ _*) if parts.last.endsWith(".py") => MergeStrategy.discard
  case _ => MergeStrategy.first // or whatever you currently have for your other merges
}

Upvotes: 1

Related Questions