1
- import com .typesafe .sbt .packager .docker .{Cmd , LayeredMapping }
1
+ import java .nio .file .Paths
2
+
2
3
import sbt .*
3
4
import sbt .Keys .*
4
5
5
- import java . nio . file . Paths
6
+ import com . typesafe . sbt . packager . docker .{ Cmd , LayeredMapping }
6
7
7
8
ThisBuild / credentials += Credentials (
8
9
" GitHub Package Registry" ,
9
10
" maven.pkg.github.com" ,
10
11
" raw-labs" ,
11
- sys.env.getOrElse(" GITHUB_TOKEN" , " " )
12
- )
12
+ sys.env.getOrElse(" GITHUB_TOKEN" , " " ))
13
13
14
14
lazy val commonSettings = Seq (
15
15
homepage := Some (url(" https://www.raw-labs.com/" )),
@@ -19,17 +19,11 @@ lazy val commonSettings = Seq(
19
19
// Use cached resolution of dependencies
20
20
// http://www.scala-sbt.org/0.13/docs/Cached-Resolution.html
21
21
updateOptions := updateOptions.in(Global ).value.withCachedResolution(true ),
22
- resolvers += " RAW Labs GitHub Packages" at " https://maven.pkg.github.com/raw-labs/_"
23
- )
22
+ resolvers += " RAW Labs GitHub Packages" at " https://maven.pkg.github.com/raw-labs/_" )
24
23
25
24
lazy val buildSettings = Seq (
26
25
scalaVersion := " 2.13.15" ,
27
- javacOptions ++= Seq (
28
- " -source" ,
29
- " 21" ,
30
- " -target" ,
31
- " 21"
32
- ),
26
+ javacOptions ++= Seq (" -source" , " 21" , " -target" , " 21" ),
33
27
scalacOptions ++= Seq (
34
28
" -feature" ,
35
29
" -unchecked" ,
@@ -38,27 +32,23 @@ lazy val buildSettings = Seq(
38
32
" -Ywarn-dead-code" ,
39
33
" -Ywarn-macros:after" , // Fix for false warning of unused implicit arguments in traits/interfaces.
40
34
" -Ypatmat-exhaust-depth" ,
41
- " 160"
42
- )
43
- )
35
+ " 160" ))
44
36
45
37
lazy val compileSettings = Seq (
46
38
Compile / doc / sources := Seq .empty,
47
39
Compile / packageDoc / mappings := Seq (),
48
40
Compile / packageSrc / publishArtifact := true ,
49
41
Compile / packageDoc / publishArtifact := false ,
50
42
Compile / packageBin / packageOptions += Package .ManifestAttributes (
51
- " Automatic-Module-Name" -> name.value.replace('-' , '.' )
52
- ),
43
+ " Automatic-Module-Name" -> name.value.replace('-' , '.' )),
53
44
// Ensure Java annotations get compiled first, so that they are accessible from Scala.
54
- compileOrder := CompileOrder .JavaThenScala
55
- )
45
+ compileOrder := CompileOrder .JavaThenScala )
56
46
57
47
lazy val testSettings = Seq (
58
48
// Ensuring tests are run in a forked JVM for isolation.
59
49
Test / fork := true ,
60
50
// Disabling parallel execution of tests.
61
- // Test / parallelExecution := false,
51
+ // Test / parallelExecution := false,
62
52
// Pass system properties starting with "raw." to the forked JVMs.
63
53
Test / javaOptions ++= {
64
54
import scala .collection .JavaConverters .*
@@ -73,10 +63,8 @@ lazy val testSettings = Seq(
73
63
// Set up heap dump options for out-of-memory errors.
74
64
Test / javaOptions ++= Seq (
75
65
" -XX:+HeapDumpOnOutOfMemoryError" ,
76
- s " -XX:HeapDumpPath= ${Paths .get(sys.env.getOrElse(" SBT_FORK_OUTPUT_DIR" , " target/test-results" )).resolve(" heap-dumps" )}"
77
- ),
78
- Test / publishArtifact := true
79
- )
66
+ s " -XX:HeapDumpPath= ${Paths .get(sys.env.getOrElse(" SBT_FORK_OUTPUT_DIR" , " target/test-results" )).resolve(" heap-dumps" )}" ),
67
+ Test / publishArtifact := true )
80
68
81
69
val isCI = sys.env.getOrElse(" CI" , " false" ).toBoolean
82
70
@@ -85,31 +73,28 @@ lazy val publishSettings = Seq(
85
73
publish / skip := false ,
86
74
publishMavenStyle := true ,
87
75
publishTo := Some (" GitHub raw-labs Apache Maven Packages" at " https://maven.pkg.github.com/raw-labs/das-salesforce" ),
88
- publishConfiguration := publishConfiguration.value.withOverwrite(isCI)
89
- )
76
+ publishConfiguration := publishConfiguration.value.withOverwrite(isCI))
90
77
91
- lazy val strictBuildSettings = commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq (
92
- scalacOptions ++= Seq (
93
- " -Xfatal-warnings"
94
- )
95
- )
78
+ lazy val strictBuildSettings =
79
+ commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq (scalacOptions ++= Seq (" -Xfatal-warnings" ))
96
80
97
81
lazy val root = (project in file(" ." ))
98
82
.settings(
99
83
name := " das-salesforce" ,
100
84
strictBuildSettings,
101
85
publishSettings,
102
86
libraryDependencies ++= Seq (
87
+ // DAS
103
88
" com.raw-labs" %% " das-server-scala" % " 0.4.1" % " compile->compile;test->test" ,
104
89
" com.raw-labs" %% " protocol-das" % " 1.0.0" % " compile->compile;test->test" ,
90
+ // Salesforce client
105
91
" com.frejo" % " force-rest-api" % " 0.0.45" ,
92
+ // Jackson
106
93
" joda-time" % " joda-time" % " 2.12.7" ,
107
94
" com.fasterxml.jackson.datatype" % " jackson-datatype-jsr310" % " 2.18.2" ,
108
95
" com.fasterxml.jackson.datatype" % " jackson-datatype-jdk8" % " 2.18.2" ,
109
96
" com.fasterxml.jackson.datatype" % " jackson-datatype-joda" % " 2.18.2" ,
110
- " com.fasterxml.jackson.module" %% " jackson-module-scala" % " 2.18.2"
111
- )
112
- )
97
+ " com.fasterxml.jackson.module" %% " jackson-module-scala" % " 2.18.2" ))
113
98
114
99
val amzn_jdk_version = " 21.0.4.7-1"
115
100
val amzn_corretto_bin = s " java-21-amazon-corretto-jdk_ ${amzn_jdk_version}_amd64.deb "
@@ -122,17 +107,16 @@ lazy val dockerSettings = strictBuildSettings ++ Seq(
122
107
" vendor" -> " RAW Labs SA" ,
123
108
" product" -> " das-salesforce-server" ,
124
109
" image-type" -> " final" ,
125
- " org.opencontainers.image.source" -> " https://github.com/raw-labs/das-salesforce"
126
- ),
110
+ " org.opencontainers.image.source" -> " https://github.com/raw-labs/das-salesforce" ),
127
111
Docker / daemonUser := " raw" ,
128
112
dockerExposedVolumes := Seq (" /var/log/raw" ),
129
113
dockerExposedPorts := Seq (50051 ),
130
114
dockerEnvVars := Map (" PATH" -> s " ${(Docker / defaultLinuxInstallLocation).value}/bin: $$ PATH " ),
131
115
// We remove the automatic switch to USER 1001:0.
132
116
// We we want to run as root to install the JDK, also later we will switch to a non-root user.
133
117
dockerCommands := dockerCommands.value.filterNot {
134
- case Cmd (" USER" , args@ _* ) => args.contains(" 1001:0" )
135
- case cmd => false
118
+ case Cmd (" USER" , args @ _* ) => args.contains(" 1001:0" )
119
+ case cmd => false
136
120
},
137
121
dockerCommands ++= Seq (
138
122
Cmd (
@@ -145,13 +129,8 @@ lazy val dockerSettings = strictBuildSettings ++ Seq(
145
129
&& dpkg --install $amzn_corretto_bin \\
146
130
&& rm -f $amzn_corretto_bin \\
147
131
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \\
148
- wget gnupg software-properties-common """
149
- ),
150
- Cmd (
151
- " USER" ,
152
- " raw"
153
- )
154
- ),
132
+ wget gnupg software-properties-common """ ),
133
+ Cmd (" USER" , " raw" )),
155
134
dockerEnvVars += " LANG" -> " C.UTF-8" ,
156
135
dockerEnvVars += " JAVA_HOME" -> " /usr/lib/jvm/java-21-amazon-corretto" ,
157
136
Compile / doc / sources := Seq .empty, // Do not generate scaladocs
@@ -165,11 +144,11 @@ lazy val dockerSettings = strictBuildSettings ++ Seq(
165
144
case ClasspathPattern (classpath) => s """
166
145
|declare -r app_classpath=" $$ {app_home}/../conf: $classpath"
167
146
| """ .stripMargin
168
- case _@entry => entry
147
+ case _ @ entry => entry
169
148
}
170
149
},
171
150
Docker / dockerLayerMappings := (Docker / dockerLayerMappings).value.map {
172
- case lm@ LayeredMapping (Some (1 ), file, path) => {
151
+ case lm @ LayeredMapping (Some (1 ), file, path) => {
173
152
val fileName = java.nio.file.Paths .get(path).getFileName.toString
174
153
if (! fileName.endsWith(" .jar" )) {
175
154
// If it is not a jar, put it on the top layer. Configuration files and other small files.
@@ -182,7 +161,7 @@ lazy val dockerSettings = strictBuildSettings ++ Seq(
182
161
lm
183
162
}
184
163
}
185
- case lm@ _ => lm
164
+ case lm @ _ => lm
186
165
},
187
166
Compile / mainClass := Some (" com.rawlabs.das.server.DASServer" ),
188
167
Docker / dockerAutoremoveMultiStageIntermediateImages := false ,
@@ -193,22 +172,15 @@ lazy val dockerSettings = strictBuildSettings ++ Seq(
193
172
val baseAlias = dockerAlias.value.withRegistryHost(Some (devRegistry))
194
173
195
174
releaseRegistry match {
196
- case Some (releaseReg) => Seq (
197
- baseAlias,
198
- dockerAlias.value.withRegistryHost(Some (releaseReg))
199
- )
200
- case None => Seq (baseAlias)
175
+ case Some (releaseReg) => Seq (baseAlias, dockerAlias.value.withRegistryHost(Some (releaseReg)))
176
+ case None => Seq (baseAlias)
201
177
}
202
- }
203
- )
178
+ })
204
179
205
180
lazy val docker = (project in file(" docker" ))
206
- .dependsOn(
207
- root % " compile->compile;test->test"
208
- )
181
+ .dependsOn(root % " compile->compile;test->test" )
209
182
.enablePlugins(JavaAppPackaging , DockerPlugin )
210
183
.settings(
211
184
strictBuildSettings,
212
185
dockerSettings,
213
- libraryDependencies += " com.raw-labs" %% " das-server-scala" % " 0.4.1" % " compile->compile;test->test"
214
- )
186
+ libraryDependencies += " com.raw-labs" %% " das-server-scala" % " 0.4.1" % " compile->compile;test->test" )
0 commit comments