-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sbt
More file actions
78 lines (63 loc) · 2.81 KB
/
build.sbt
File metadata and controls
78 lines (63 loc) · 2.81 KB
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
/*
* Copyright 2021 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.00
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import sys.process._
import Dependencies._
ThisBuild / name := "spark-data-standardization"
ThisBuild / organization := "za.co.absa"
lazy val scala212 = "2.12.20"
lazy val scala213 = "2.13.16"
ThisBuild / crossScalaVersions := Seq(scala212, scala213)
ThisBuild / scalaVersion := scala212
ThisBuild / versionScheme := Some("early-semver")
// Java 11
ThisBuild / javacOptions ++= Seq("-source", "11", "-target", "11")
ThisBuild / scalacOptions ++= Seq("-release", "11")
libraryDependencies ++= dependencyList(scalaVersion.value)
lazy val printSparkScalaVersion = taskKey[Unit]("Print Spark and Scala versions for standardization")
ThisBuild / printSparkScalaVersion := {
val log = streams.value.log
val scalaVers = scalaVersion.value
log.info(s"Building with Spark ${getSparkVersion(scalaVers)}, Scala ${scalaVers}")
}
Test / parallelExecution := false
Test / logBuffered := false
Test / fork := true
// Only apply scalafmt to files that differ from master (i.e. files changed in the feature branch or so; n/a on Windows)
lazy val fmtFilterExpression: String = System.getProperty("os.name").toLowerCase match {
case win if win.contains("win") => ""
case nonWin =>
lazy val currBranchName = "git branch --show-current".!!.trim
lazy val baseBranchName = (
"git show-branch -a"
#| raw"grep \*"
#| s"grep -v $currBranchName"
#| "head -n1"
#| raw"sed s/.*\[\(.*\)\].*/\1/"
).!!.trim
s"diff-ref=${baseBranchName}"
}
scalafmtFilter.withRank(KeyRanks.Invisible) := fmtFilterExpression
// linting
Global / excludeLintKeys += ThisBuild / name // will be used in publish, todo #3 - confirm if lint ignore is still needed
// JaCoCo Method Filter Plugin
enablePlugins(JacocoFilterPlugin)
jacocoReportName := s"spark-data-standardization Jacoco Report - scala:${scalaVersion.value}"
jacocoReportFormats := Set("html", "xml")
// jacocoExcludes := Seq("za/co/absa/standardization/udf/UDFBuilder*", "za/co/absa/standardization/udf/UDFNames")
// Command aliases for JaCoCo coverage workflow
addCommandAlias("jacoco", "; jacocoOn; clean; test; jacocoReportAll; jacocoOff")
addCommandAlias("jacocoOn", "; set every jacocoPluginEnabled := true")
addCommandAlias("jacocoOff", "; set every jacocoPluginEnabled := false")