-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
115 lines (101 loc) · 4.19 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
import Dependencies.crossVersion
import sbt.Keys.organization
import sbtassembly.{Assembly, MergeStrategy, PathList}
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
lazy val scalafixSettings = Seq(
addCompilerPlugin(scalafixSemanticdb),
scalacOptions ++= List(
s"-P:semanticdb:targetroot:${System.getProperty("java.io.tmpdir")}/semanticdb",
"-Yrangepos",
"-language:postfixOps"))
lazy val jmhSettings = Seq(
sourceDirectory in Jmh := (sourceDirectory in Test).value,
classDirectory in Jmh := (classDirectory in Test).value,
dependencyClasspath in Jmh := (dependencyClasspath in Test).value
)
lazy val commonSettings = Seq(
scalaVersion := crossVersion.head,
fork := true,
crossScalaVersions := crossVersion,
parallelExecution in Test := true
)
lazy val dependenciesScope = "compile->compile;test->test"
lazy val utils = (project in file("utils"))
.settings(commonSettings: _*)
.settings(scalafixSettings: _*)
.settings(jmhSettings: _*)
.settings(Seq(name := "utils", organization := "io.github.wtog.utils"))
.settings(libraryDependencies ++= Dependencies.utils.dependencies)
.enablePlugins(JmhPlugin)
.disablePlugins(AssemblyPlugin)
lazy val core = (project in file("crawler-core"))
.settings(commonSettings: _*)
.settings(scalafixSettings: _*)
.settings(jmhSettings: _*)
.settings(Seq(name := "crawler-core", organization := "io.github.wtog.crawler"))
.settings(libraryDependencies ++= Dependencies.core.dependencies)
.dependsOn(utils % dependenciesScope)
.disablePlugins(AssemblyPlugin)
lazy val pipeline = (project in file("crawler-pipeline"))
.settings(commonSettings: _*)
.settings(scalafixSettings: _*)
.settings(jmhSettings: _*)
.settings(Seq(name := "crawler-pipeline", organization := "io.github.wtog.crawler.pipeline"))
.settings(libraryDependencies ++= Dependencies.pipeline.dependencies)
.dependsOn(core, utils % dependenciesScope)
.disablePlugins(AssemblyPlugin)
lazy val example = (project in file("crawler-example"))
.settings(commonSettings: _*)
.settings(scalafixSettings: _*)
.settings(Seq(name := "crawler-example", organization := "io.github.wtog.example"))
.settings(libraryDependencies ++= Dependencies.example.dependencies)
.settings(
Seq(
assemblyJarName in assembly := s"web-crawler-assembly.jar",
mainClass in Compile := Some("io.github.wtog.example.Main"),
test in assembly := {},
assemblyMergeStrategy in assembly := {
case x if Assembly.isConfigFile(x) =>
MergeStrategy.concat
case PathList(ps@_*) if Assembly.isReadme(ps.last) || Assembly.isLicenseFile(ps.last) =>
MergeStrategy.rename
case PathList(ps@_*) if Assembly.isSystemJunkFile(ps.last) =>
MergeStrategy.discard
case PathList("META-INF", xs@_*) =>
xs.map(_.toLowerCase) match {
case (x :: Nil) if Seq("manifest.mf", "index.list", "dependencies") contains x =>
MergeStrategy.discard
case ps@(x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") || ps.last.endsWith(".rsa") =>
MergeStrategy.discard
case "maven" :: xs =>
MergeStrategy.discard
case "plexus" :: xs =>
MergeStrategy.discard
case "services" :: xs =>
MergeStrategy.filterDistinctLines
case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) | ("spring.tooling" :: Nil) =>
MergeStrategy.filterDistinctLines
case _ => MergeStrategy.first
}
case _ => MergeStrategy.first
}
)
)
.dependsOn(core, pipeline)
.enablePlugins(DisablePublish, AssemblyPlugin)
.disablePlugins(ScoverageSbtPlugin)
lazy val root = (project in file("."))
.settings(commonSettings: _*)
.settings(Seq(name := "web-crawler"))
.aggregate(utils, core, pipeline, example)
.enablePlugins(JmhPlugin, DisablePublish)
.disablePlugins(AssemblyPlugin)
testOptions in Test += Tests.Argument(s"-P${java.lang.Runtime.getRuntime.availableProcessors()}")
javaOptions in test := Seq(
"-Dlog4j.configurationFile=log4j2-test.xml",
"-Xms512m", "-Xmx512m"
)
javaOptions in run := Seq(
"-Dlog4j.configurationFile=log4j2.xml",
"-Xms512m", "-Xmx512m"
)