Created
August 18, 2021 22:06
-
-
Save er1c/ed01078a26c30b142a8e7a0d7d4dff1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import sbt.Keys._ | |
import sbtassembly.AssemblyKeys._ | |
import sbtassembly.AssemblyPlugin.autoImport.ShadeRule | |
import scala.sys.process._ | |
import com.dotdata.sbt.SbtDatabricksPlugin.autoImport._ | |
object Assembly { | |
private lazy val shadedPackages = | |
Seq("breeze", "com.github.fommil", "org.netlib") | |
private val sbtAssemblyDirectory = taskKey[File]("Directory to cache sbt assembly output.") | |
def assemblySettings(mainClassName: String) = | |
Seq( | |
moduleName := mainClassName, | |
sbtAssemblyDirectory := { | |
val workDir: String = ("git rev-parse --show-toplevel" !!).trim | |
val relativeWorkDir = | |
baseDirectory.value | |
.getCanonicalPath | |
.stripPrefix(workDir) | |
.stripPrefix(java.io.File.pathSeparator) | |
val sbtAssemblyLocalCache: File = | |
localCacheDirectory.value / "assembly" / relativeWorkDir | |
println(s"project: ${projectID.value} - sbtAssemblyLocalCache: $sbtAssemblyLocalCache") | |
sbtAssemblyLocalCache | |
}, | |
// Cache sbt assembly intermediate files in a shared location instead of target/ | |
assembly / assemblyOption := { | |
val opt = (assembly / assemblyOption).value | |
val dir = sbtAssemblyDirectory.value | |
opt.withAssemblyDirectory(dir) | |
}, | |
assembly / assemblyShadeRules ++= shadedPackages.map(pkg => ShadeRule.rename(s"$pkg.**" -> "dotdata_shaded.@0").inAll) ++ DatabricksAssemblyShadeRules, | |
assembly / assemblyJarName := mainClassName + ".jar", | |
assembly / mainClass := Some(mainClassName) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment