-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
91 lines (84 loc) · 3.43 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
import BuildSettings.*
import Dependencies.*
import PublishSettings.*
import TestEnvironment.*
ThisBuild / scalaVersion := scalaV
//ThisBuild / conflictManager := ConflictManager.strict
lazy val pactOptions: Seq[Tests.Argument] = Seq(
Some(sys.env.getOrElse("PACT_BROKER_BASE_URL", "http://localhost:9292")).map(s => s"-Dpactbroker.url=$s"),
sys.env.get("PACT_BROKER_USERNAME").map(s => s"-Dpactbroker.auth.username=$s"),
sys.env.get("PACT_BROKER_PASSWORD").map(s => s"-Dpactbroker.auth.password=$s"),
sys.env.get("PACT_BROKER_TAG").map(s => s"-Dpactbroker.consumerversionselectors.tags=$s"),
).flatten.map(o => Tests.Argument(jupiterTestFramework, o))
lazy val plugin = moduleProject("plugin", "plugin")
.enablePlugins(
GitHubPagesPlugin,
JavaAppPackaging,
// https://sbt-native-packager.readthedocs.io/en/stable/recipes/longclasspath.html#long-classpaths
LauncherJarPlugin
)
.settings(
git.useGitDescribe := true,
name := "plugin",
maintainer := "[email protected]",
publishSettings,
testEnvSettings,
gitHubPagesOrgName := "austek",
gitHubPagesRepoName := "pact-avro-plugin",
gitHubPagesSiteDir := (`pact-avro-plugin` / baseDirectory).value / "build" / "site",
gitHubPagesAcceptedTextExtensions := Set(".css", ".html", ".js", ".svg", ".txt", ".woff", ".woff2", ".xml"),
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
libraryDependencies ++=
Dependencies.compile(apacheAvro, auPactMatchers, logback, scalaLogging, scalaPBRuntime) ++
Dependencies.protobuf(scalaPB) ++
Dependencies.test(scalaTest),
dependencyOverrides ++= Seq(grpcApi, grpcCore, grpcNetty)
)
lazy val pluginRef = LocalProject("plugin")
lazy val provider = moduleProject("provider", "examples/provider")
.settings(
Test / sbt.Keys.test := (Test / sbt.Keys.test).dependsOn(pluginRef / buildTestPluginDir).value,
Test / envVars := Map("PACT_PLUGIN_DIR" -> ((pluginRef / target).value / "plugin").absolutePath),
testOptions ++= pactOptions,
libraryDependencies ++=
Dependencies.compile(avroCompiler, logback, pulsar4sCore, pulsar4sAvro, scalacheck) ++
Dependencies.test(assertJCore, jUnitInterface, pactProviderJunit),
publish / skip := false
)
lazy val consumer = moduleProject("consumer", "examples/consumer")
.settings(
Compile / avroSource := (Compile / resourceDirectory).value / "avro",
Test / sbt.Keys.test := (Test / sbt.Keys.test).dependsOn(pluginRef / buildTestPluginDir).value,
Test / envVars := Map("PACT_PLUGIN_DIR" -> ((pluginRef / target).value / "plugin").absolutePath),
libraryDependencies ++=
Dependencies.compile(avroCompiler, logback, pulsar4sCore, pulsar4sAvro, scalaLogging) ++
Dependencies.test(assertJCore, jUnitInterface, pactConsumerJunit),
publish / skip := false
)
lazy val `pact-avro-plugin` = (project in file("."))
.aggregate(
pluginRef,
consumer,
provider
)
.settings(
basicSettings,
publish / skip := false
)
def moduleProject(name: String, path: String): Project = {
Project(name, file(s"modules/$path"))
.enablePlugins(GitVersioning, ScalafmtPlugin)
.settings(
basicSettings,
moduleName := name,
git.useGitDescribe := true,
git.gitTagToVersionNumber := { tag: String =>
if(tag matches "v[0-9].*") {
Some(tag.drop(1).replaceAll("-[0-9]+-.+", ""))
}
else None
}
)
}