-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
171 lines (164 loc) · 6.67 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
//Definition of the managed dependencies
val sourceCode = "com.lihaoyi" %% "sourcecode" % "0.3.0"
val scalaz = "org.scalaz" %% "scalaz-core" % "7.3.7"
val scala_xml = "org.scala-lang.modules" %% "scala-xml" % "2.1.0"
val scopt = "com.github.scopt" %% "scopt" % "4.1.0"
val scalactic = "org.scalactic" %% "scalactic" % "3.2.15"
val scalatest = "org.scalatest" %% "scalatest" % "3.2.15" % "test"
val scalaplus = "org.scalatestplus" %% "scalacheck-1-15" % "3.2.11.0" % "test"
lazy val modelCode =
taskKey[Seq[(String, File)]]("files to be embedded in docker")
lazy val dockerProxySetting = (for {
httpProxy <- sys.env.get("http_proxy")
httpsProxy <- sys.env.get("https_proxy")
} yield {
Seq(
docker / dockerBuildArguments := Map(
"http_proxy" -> httpProxy,
"https_proxy" -> httpsProxy
)
)
}) getOrElse Seq.empty
lazy val dockerSettings = Seq(
docker / imageNames := Seq(
ImageName(
namespace = Some(organization.value),
repository = name.value,
tag = Some("v" + version.value)
)
),
modelCode := Seq(
"src/main/scala/onera/pmlanalyzer/pml/examples/mySys" -> (Compile / scalaSource).value / "onera" / "pmlanalyzer" / "pml" / "examples" / "mySys",
"src/main/scala/onera/pmlanalyzer/views/interference/examples/mySys" -> (Compile / scalaSource).value / "onera" / "pmlanalyzer" / "views" / "interference" / "examples" / "mySys",
"src/test" -> (Compile / baseDirectory).value / "src" / "test"
),
docker / dockerfile := {
// The assembly task generates a fat JAR file
val artifact: File = assembly.value
val generatedDoc = (Compile / doc).value
val artifactTargetPath = s"/home/user/code/lib/${artifact.name}"
val base = (Compile / baseDirectory).value
new Dockerfile {
from("openjdk:8")
customInstruction("RUN", "apt-get update && apt-get --fix-missing update && apt-get install -y graphviz gnupg libgmp3-dev make cmake build-essential zlib1g-dev")
env("SBT_VERSION", sbtVersion.value)
customInstruction(
"RUN",
"mkdir /working/ && cd /working/ && curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && dpkg -i sbt-$SBT_VERSION.deb && rm sbt-$SBT_VERSION.deb && apt-get update && apt-get install sbt && cd && rm -r /working/"
)
customInstruction(
"RUN",
"groupadd -r user && useradd --no-log-init -r -g user user"
)
customInstruction("RUN", "mkdir -p /home/user/code")
customInstruction("RUN", "mkdir -p /home/user/code/lib")
customInstruction("RUN", "mkdir -p /home/user/code/binlib")
customInstruction("RUN", "mkdir -p /home/user/code/src/main/scala/onera/pmlanalyzer/pml")
customInstruction("RUN", "mkdir -p /home/user/code/src/main/scala/onera/pmlanalyzer/views/interference")
customInstruction("RUN", "mkdir -p /home/user/code/src/test")
workDir("/home/user")
customInstruction("RUN", "git clone https://github.com/sambayless/monosat.git")
workDir("/home/user/monosat")
customInstruction("RUN", "cmake -DJAVA=ON .")
customInstruction("RUN", "make")
customInstruction("RUN", "cp libmonosat.so /home/user/code/binlib")
workDir("/home/user/code")
for ((to, from) <- modelCode.value)
copy(from, to)
copy((Compile / doc / target).value, "doc")
copy(artifact, artifactTargetPath)
copy(Seq(base / "AUTHORS.txt", base / "lesser.txt", base / "minimalBuildSBT.txt", base / "LICENSE", base / "Makefile"), "./")
customInstruction("RUN", "mv minimalBuildSBT.txt build.sbt")
env("LD_LIBRARY_PATH" -> "/home/user/code/binlib:${LD_LIBRARY_PATH}")
customInstruction(
"RUN",
"chown -R user /home/user && chgrp -R user /home/user"
)
user("user")
customInstruction("RUN", "sbt \"compile\" clean ")
entryPoint("/bin/bash")
}
}
) ++ dockerProxySetting
lazy val docSetting =
Compile / doc / scalacOptions ++= Seq(
"-groups",
"-siteroot",
"doc",
"-doc-root-content",
"doc/_assets/text/rootContent.txt",
"-skip-by-regex:pml.expertises,views.dependability.*,pml.examples,views.interference.examples,pml.model.relations,views.interference.model.relations",
"-project-logo",
"doc/_assets/images/phylog_logo.gif"
)
lazy val assemblySettings = Seq(
assembly / assemblyJarName := s"PMLAnalyzer_${version.value}.jar",
assembly / assemblyMergeStrategy := {
case PathList(ps@_*) if ps.contains("patterns") => MergeStrategy.discard
case PathList(ps@_*) if ps.contains("examples") => MergeStrategy.discard
case x =>
(ThisBuild / assemblyMergeStrategy).value(x)
}
)
//Definition of the common settings for the projects (ie the scala version, compilation options and library resolvers)
lazy val commonSettings = Seq(
organization := "io.github.onera",
homepage := Some(url("https://github.com/onera/pml-analyzer")),
scmInfo := Some(
ScmInfo(
url("https://github.com/onera/pml-analyzer"),
"git@github.com:onera/pml-analyzer.git"
)
),
developers := List(
Developer(
"kevin-delmas",
"kevin-delmas",
"kevin.delmas@onera.fr",
url("https://www.onera.fr/en/staff/kevin-delmas")
)
),
licenses += (
"LGPL-2.1",
url("https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html")
),
publishMavenStyle := true,
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credentials"),
pomIncludeRepository := { _ => false },
crossPaths := false,
publishTo := Some(
"releases" at "https://s01.oss.sonatype.org/" + "service/local/staging/deploy/maven2"
),
publishMavenStyle := true,
version := "1.1.1",
scalaVersion := "3.2.2",
sbtVersion := "1.8.2",
scalafixOnCompile := true,
semanticdbEnabled := true,
scalafmtOnCompile := true,
scalafixDependencies += "io.github.dedis" %% "scapegoat-scalafix" % "1.1.4",
semanticdbVersion := scalafixSemanticdb.revision,
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-Werror"),
resolvers ++= Resolver.sonatypeOssRepos("releases"),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
libraryDependencies ++= Seq(
scalaz,
scala_xml,
sourceCode,
scalatest,
scalactic,
scalaplus
),
docSetting
) ++ dockerSettings ++ assemblySettings
// The service project is the main project containing all the sources for
// PML modelling and analysis
lazy val PMLAnalyzer = (project in file("."))
.enablePlugins(DockerPlugin)
.settings(commonSettings: _*)
.settings(name := "pml_analyzer")
// Fork a new JVM on every sbt run task
// Fixes an issue with the classloader complaining that the Monosat library is
// "already loaded in another classloader" on successive runs of the analysis
// in the same sbt instance.
fork := true