-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
125 lines (117 loc) · 5.75 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
//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/pml/examples/simpleKeystone" -> (Compile / scalaSource).value / "pml" / "examples" / "simpleKeystone",
"src/main/scala/pml/examples/simpleT1042" -> (Compile / scalaSource).value / "pml" / "examples" / "simpleT1042",
"src/main/scala/views/interference/examples/simpleKeystone" -> (Compile / scalaSource).value / "views" / "interference" / "examples" / "simpleKeystone",
"src/main/scala/views/interference/examples/simpleT1042" -> (Compile / scalaSource).value / "views" / "interference" / "examples" / "simpleT1042",
),
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
val binlib = base / "binlib"
new Dockerfile {
from("openjdk:8")
customInstruction("RUN", "apt-get update && apt-get --fix-missing update && apt-get install -y graphviz gnupg libgmp3-dev make")
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/src/main/scala/pml")
customInstruction("RUN", "mkdir -p /home/user/code/src/main/scala/views/interference")
workDir("/home/user/code")
for((to,from) <- modelCode.value)
copy(from, to)
copy((Compile / doc / target).value, "doc")
copy(binlib, "binlib")
copy(artifact, artifactTargetPath)
copy(Seq(base / "AUTHORS.txt", base / "lesser.txt", base / "minimalBuildSBT.txt", base / "LICENCE", 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"), "[email protected]:onera/pml-analyzer.git")) ,
developers := List (Developer("kevin-delmas", "kevin-delmas", "[email protected]", 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.0.1",
scalaVersion := "3.2.2",
sbtVersion := "1.8.2",
scalacOptions := Seq("-unchecked", "-deprecation", "-feature"),
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")