-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
182 lines (164 loc) · 7.58 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import xerial.sbt.Sonatype.sonatypeCentralHost
import xerial.sbt.Sonatype.GitHubHosting
ThisBuild / version := "0.1.11"
ThisBuild / scalaVersion := scala.util.Properties.envOrElse("SCALA_VERSION", "2.12.15") // "2.13.14", "2.12.15"
ThisBuild / organization := "com.stabrise"
ThisBuild / organizationName := "StabRise"
ThisBuild / organizationHomepage := Some(url("https://www.stabrise.com"))
ThisBuild / sonatypeProfileName := "com.stabrise"
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/StabRise/spark-pdf"),
"scm:git@github.StabRise/spark-pdf.git"
)
)
ThisBuild / sonatypeProjectHosting := Some(GitHubHosting("StabRise", "spark-pdf", "mykola.melnyk.ml@gmail.com"))
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / developers := List(
Developer(
id = "mykolamelnykml",
name = "Mykola Melnyk",
email = "mykola.melnyk.ml@gmail.com",
url = url("https://stabrise.com")
)
)
ThisBuild / description := "PDF Datasource for Apache Spark. Read PDF files lazy to the DataFrame."
ThisBuild / licenses := List("AGPL-V3" -> new URL("https://www.gnu.org/licenses/agpl-3.0.html"))
ThisBuild / homepage := Some(url("https://stabrise.com/spark-pdf/"))
ThisBuild / sonatypeCredentialHost := sonatypeCentralHost
ThisBuild / sbtPluginPublishLegacyMavenStyle := false
ThisBuild / publishTo := sonatypePublishToBundle.value
root / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
root / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
// "4.0.0-preview2", "3.5.3","3.4.1", "3.3.2
val sparkVersion = scala.util.Properties.envOrElse("SPARK_VERSION", "3.5.3")
val packageName =
sparkVersion match {
case sparkVersion if sparkVersion.startsWith("3.3") => "spark-pdf-spark33"
case sparkVersion if sparkVersion.startsWith("3.4") => "spark-pdf-spark34"
case sparkVersion if sparkVersion.startsWith("4.0") => "spark-pdf-spark40"
case _ => "spark-pdf-spark35"
}
lazy val common = (project in file("common"))
.settings(
name := "common",
commonSettings
)
.disablePlugins(AssemblyPlugin)
lazy val spark40 = (project in file("spark40"))
.settings(
name := "spark40",
commonSettings,
)
.disablePlugins(AssemblyPlugin)
.dependsOn(common)
lazy val spark35 = (project in file("spark35"))
.settings(
name := "spark35",
commonSettings,
)
.disablePlugins(AssemblyPlugin)
.dependsOn(common)
lazy val spark34 = (project in file("spark34"))
.settings(
name := "spark34",
commonSettings,
)
.disablePlugins(AssemblyPlugin)
.dependsOn(common)
lazy val spark33 = (project in file("spark33"))
.settings(
name := "spark33",
commonSettings,
)
.disablePlugins(AssemblyPlugin)
.dependsOn(common)
lazy val root = (project in file("."))
.settings(
name := packageName,
commonSettings,
)
.dependsOn(dependencyModules():_*)
.aggregate(aggregatedModules(): _*)
def aggregatedModules(): List[sbt.ProjectReference] =
sparkVersion match {
case sparkVersion if sparkVersion.startsWith("3.3") => List(common, spark33)
case sparkVersion if sparkVersion.startsWith("3.4") => List(common, spark34)
case sparkVersion if sparkVersion.startsWith("4.0") => List(common, spark40)
case _ => List(common, spark35)
}
def dependencyModules(): List[ClasspathDependency] =
sparkVersion match {
case sparkVersion if sparkVersion.startsWith("3.3") => List(spark33).map(ClasspathDependency(_, None))
case sparkVersion if sparkVersion.startsWith("3.4") => List(spark34).map(ClasspathDependency(_, None))
case sparkVersion if sparkVersion.startsWith("4.0") => List(spark40).map(ClasspathDependency(_, None))
case _ => List(spark35).map(ClasspathDependency(_, None))
}
lazy val commonSettings = Seq(
scalacOptions ++= Seq("-deprecation", "-unchecked"),
libraryDependencies ++= commonDependencies
)
lazy val commonDependencies = Seq(
"org.apache.spark" %% "spark-core" % sparkVersion % "provided",
"org.apache.spark" %% "spark-sql" % sparkVersion % "provided",
"org.apache.spark" %% "spark-mllib" % sparkVersion % "provided",
"org.apache.pdfbox" % "pdfbox" % "2.0.24",
"org.scalatest" %% "scalatest" % "3.2.9" % "test",
"org.bytedeco" % "tesseract-platform" % "5.3.4-1.5.10",
"org.bytedeco" % "tesseract" % "5.3.4-1.5.10",
"net.sourceforge.tess4j" % "tess4j" % "5.11.0"
exclude("org.slf4j", "slf4j-log4j12")
exclude("org.slf4j", "log4j-over-slf4j")
exclude("org.slf4j", "jcl-over-slf4j")
exclude("ch.qos.logback", "logback-classic")
exclude("org.apache.pdfbox", "pdfbox"),
).map(_
exclude("log4j", "log4j")
exclude("org.apache.commons", "commons-csv")
exclude("org.apache.commons", "commons-math3")
exclude("commons-logging", "commons-logging")
exclude("commons-cli", "commons-cli")
exclude("org.junit.jupiter", "junit-jupiter")
)
lazy val assemblySettings = Seq(
assembly / assemblyMergeStrategy := {
case PathList("org", "xmlpull", xs@_*) => MergeStrategy.last
case PathList("apache", "commons", "logging", "impl", xs@_*) => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains ( "android")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains ( "macos")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains ( "windows")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains ( "ios")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(p => p.contains("linux-arm") || p.contains("arm64-v8a") ||
p.contains("armeabi") ).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains("linux-ppc")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contentEquals("linux-x86")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contentEquals("windows-x86")).nonEmpty => MergeStrategy.discard
case "versionchanges.txt" => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains("pom.xml")).nonEmpty => MergeStrategy.discard
case PathList(ps @ _*) if ps.filter(_.contains("pom.properties")).nonEmpty => MergeStrategy.discard
case "StaticLoggerBinder" => MergeStrategy.discard
case PathList("net", "imglib2", "util", "StopWatch.class") => MergeStrategy.first
case PathList("META-INF", fileName)
if List("NOTICE", "MANIFEST.MF", "DEPENDENCIES", "INDEX.LIST").contains(fileName) ||
fileName.endsWith(".txt") || fileName.endsWith(".RSA") ||
fileName.endsWith(".DSA") || fileName.endsWith(".SF")
=> MergeStrategy.discard
case "META-INF/services/javax.imageio.spi.ImageReaderSpi" => MergeStrategy.concat
case PathList("META-INF", "services", _@_*) => MergeStrategy.first
case PathList("META-INF", xs@_*) => MergeStrategy.first
case PathList("plugins.config", xs@_*) => MergeStrategy.discard
case PathList("LICENSE.txt", xs@_*) => MergeStrategy.discard
case PathList("org", "apache", "commons", "logging", xs@_*) => MergeStrategy.last
case PathList("org", "apache", "batik", xs@_*) => MergeStrategy.last
case PathList(ps @ _*) if ps.last contains ( ".DS_Store") => MergeStrategy.discard
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
},
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("net.imglib2.imglib2.util.**" -> "shadeio.imglib2.imglib2.util.@1").inAll,
ShadeRule.rename("org.apache.http.**" -> "org.apache.httpShaded@1").inAll
),
assembly / assemblyJarName := s"spark-pdf-${version.value}.jar",
assembly / test := {}
)