-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild.sbt
135 lines (123 loc) · 4.98 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
import java.nio.file.Files
import sbt._
val assemblyCommon = Seq(
assembly / test := {},
// Without this assembly merge strategy, gives the following error:
// (codacyAnalysisCli / assembly) deduplicate: different file contents found in the following:
// [error] org/bouncycastle/bcpg-jdk15on/1.64/bcpg-jdk15on-1.64.jar:META-INF/versions/9/module-info.class
// Workaround:
// https://stackoverflow.com/questions/54834125/sbt-assembly-deduplicate-module-info-class
assembly / assemblyMergeStrategy := {
case "META-INF/versions/9/module-info.class" => MergeStrategy.discard
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
})
inThisBuild(
Seq(
scalaVersion := Common.scalaVersionNumber,
scalaBinaryVersion := Common.scalaBinaryVersionNumber,
scapegoatDisabledInspections := Seq(),
scapegoatVersion := "1.4.6"))
val sonatypeInformation = Seq(
startYear := Some(2018),
homepage := Some(url("https://github.com/codacy/codacy-analysis-cli")),
// HACK: This setting is not picked up properly from the plugin
pgpPassphrase := Option(System.getenv("SONATYPE_GPG_PASSPHRASE")).map(_.toCharArray),
scmInfo := Some(
ScmInfo(
url("https://github.com/codacy/codacy-analysis-cli"),
"scm:git:[email protected]:codacy/codacy-analysis-cli.git")))
lazy val codacyAnalysisCore = project
.in(file("core"))
.settings(name := "codacy-analysis-core")
.settings(coverageExcludedPackages := "<empty>;com\\.codacy\\..*Error.*")
.settings(Common.genericSettings)
.settings(
// App Dependencies
libraryDependencies ++= Seq(
Dependencies.caseApp,
Dependencies.betterFiles,
Dependencies.jodaTime,
Dependencies.scalajHttp,
Dependencies.jGit,
Dependencies.cats,
Dependencies.typesafeConfig) ++
Dependencies.circe ++
Dependencies.log4s ++
Dependencies.codacyPlugins,
// Test Dependencies
libraryDependencies ++= Dependencies.specs2,
sonatypeInformation,
description := "Library to analyze projects")
.settings(assemblyCommon: _*)
.dependsOn(codacyAnalysisModels)
lazy val codacyAnalysisCli = project
.in(file("cli"))
.settings(
name := "codacy-analysis-cli",
coverageExcludedPackages := "<empty>;com\\.codacy\\..*CLIError.*",
Common.genericSettings,
Universal / javaOptions ++= Seq("-XX:MinRAMPercentage=60.0", "-XX:MaxRAMPercentage=90.0"),
publish := (Docker / publish).value,
publishLocal := (Docker / publishLocal).value,
publishArtifact := false,
libraryDependencies ++= Dependencies.pprint +: Dependencies.specs2)
.settings(assemblyCommon: _*)
.enablePlugins(JavaAppPackaging)
.enablePlugins(DockerPlugin)
.dependsOn(codacyAnalysisCore % "compile->compile;test->test", toolRepositoryRemote)
.aggregate(codacyAnalysisCore, toolRepositoryRemote)
lazy val toolRepositoryRemote = project
.in(file("toolRepository-remote"))
.settings(Common.genericSettings, libraryDependencies ++= Dependencies.specs2)
.settings(assemblyCommon: _*)
.dependsOn(codacyAnalysisCore % "compile->compile;test->test", codacyAnalysisModels, codacyApiClient)
lazy val codacyAnalysisModels = project
.in(file("model"))
.settings(
crossScalaVersions := Common.supportedScalaVersions,
name := "codacy-analysis-cli-model",
Common.genericSettings,
libraryDependencies ++=
Dependencies.circe ++ Seq(Dependencies.pluginsApi) ++ Dependencies.specs2,
description := "Library with analysis models")
.settings(assemblyCommon: _*)
.settings(sonatypeInformation)
.enablePlugins(JavaAppPackaging)
lazy val apiSwaggerFile: File =
codacyApiClient.base / "target" / "api" / "codacy-api" / Dependencies.codacyApiVersion / "swagger.yaml"
lazy val downloadCodacyToolsSwaggerFile = Def.task[Unit] {
if (!Files.exists(apiSwaggerFile.toPath)) {
val result: String =
scala.io.Source
.fromURL(url(s"https://artifacts.codacy.com/api/codacy-api/${Dependencies.codacyApiVersion}/apiv3.yaml"))
.mkString
IO.write(apiSwaggerFile, result)
}
}
val silencerSettings =
Seq(libraryDependencies ++= Dependencies.silencer, scalacOptions += "-P:silencer:pathFilters=src_managed")
lazy val codacyApiClient = project
.in(file("codacy-api-client"))
.settings(name := "codacy-api-client", description := "Client library for codacy API")
.settings(
// Guardrail requirement
addCompilerPlugin(Dependencies.macroParadise.cross(CrossVersion.full)),
scalacOptions += "-Xexperimental")
.settings(
libraryDependencies ++= Dependencies.akka ++ Dependencies.circe ++ Seq(
Dependencies.typesafeConfig,
Dependencies.cats,
Dependencies.scalatest % Test))
.settings(
Compile / guardrail := (Compile / guardrail).dependsOn(downloadCodacyToolsSwaggerFile).value,
Compile / guardrailTasks := {
List(
ScalaClient(
specPath = apiSwaggerFile,
pkg = "com.codacy.analysis.clientapi",
tracing = false,
modules = List("circe", "akka-http")))
},
silencerSettings)