|
1 |
| -import java.nio.file.Paths |
2 |
| - |
3 |
| -import sbt.Keys._ |
4 |
| -import sbt._ |
5 |
| - |
6 |
| -import com.typesafe.sbt.packager.docker.{Cmd, LayeredMapping} |
7 |
| - |
8 |
| -ThisBuild / credentials += Credentials( |
9 |
| - "GitHub Package Registry", |
10 |
| - "maven.pkg.github.com", |
11 |
| - "raw-labs", |
12 |
| - sys.env.getOrElse("GITHUB_TOKEN", "")) |
13 |
| - |
14 |
| -lazy val commonSettings = Seq( |
15 |
| - homepage := Some(url("https://www.raw-labs.com/")), |
16 |
| - organization := "com.raw-labs", |
17 |
| - organizationName := "RAW Labs SA", |
18 |
| - organizationHomepage := Some(url("https://www.raw-labs.com/")), |
19 |
| - // Use cached resolution of dependencies |
20 |
| - // http://www.scala-sbt.org/0.13/docs/Cached-Resolution.html |
21 |
| - updateOptions := updateOptions.in(Global).value.withCachedResolution(true), |
22 |
| - resolvers ++= Seq(Resolver.mavenLocal), |
23 |
| - resolvers += "RAW Labs GitHub Packages" at "https://maven.pkg.github.com/raw-labs/_") |
24 |
| - |
25 |
| -lazy val buildSettings = Seq( |
26 |
| - scalaVersion := "2.13.15", |
27 |
| - javacOptions ++= Seq("-source", "21", "-target", "21"), |
28 |
| - scalacOptions ++= Seq( |
29 |
| - "-feature", |
30 |
| - "-unchecked", |
31 |
| - "-deprecation", |
32 |
| - "-Xlint:-stars-align,_", |
33 |
| - "-Ywarn-dead-code", |
34 |
| - "-Ywarn-macros:after", // Fix for false warning of unused implicit arguments in traits/interfaces. |
35 |
| - "-Ypatmat-exhaust-depth", |
36 |
| - "160")) |
37 |
| - |
38 |
| -lazy val compileSettings = Seq( |
39 |
| - Compile / doc / sources := Seq.empty, |
40 |
| - Compile / packageDoc / mappings := Seq(), |
41 |
| - Compile / packageSrc / publishArtifact := true, |
42 |
| - Compile / packageDoc / publishArtifact := false, |
43 |
| - Compile / packageBin / packageOptions += Package.ManifestAttributes( |
44 |
| - "Automatic-Module-Name" -> name.value.replace('-', '.')), |
45 |
| - // Ensure Java annotations get compiled first, so that they are accessible from Scala. |
46 |
| - compileOrder := CompileOrder.JavaThenScala, |
47 |
| - Compile / mainClass := Some("com.rawlabs.das.server.DASServer") |
48 |
| - ) |
49 |
| - |
50 |
| -lazy val testSettings = Seq( |
51 |
| - // Ensuring tests are run in a forked JVM for isolation. |
52 |
| - Test / fork := true, |
53 |
| - // Disabling parallel execution of tests. |
54 |
| - // Test / parallelExecution := false, |
55 |
| - // Pass system properties starting with "raw." to the forked JVMs. |
56 |
| - Test / javaOptions ++= { |
57 |
| - import scala.collection.JavaConverters._ |
58 |
| - val props = System.getProperties |
59 |
| - props |
60 |
| - .stringPropertyNames() |
61 |
| - .asScala |
62 |
| - .filter(_.startsWith("raw.")) |
63 |
| - .map(key => s"-D$key=${props.getProperty(key)}") |
64 |
| - .toSeq |
65 |
| - }, |
66 |
| - // Set up heap dump options for out-of-memory errors. |
67 |
| - Test / javaOptions ++= Seq( |
68 |
| - "-XX:+HeapDumpOnOutOfMemoryError", |
69 |
| - s"-XX:HeapDumpPath=${Paths.get(sys.env.getOrElse("SBT_FORK_OUTPUT_DIR", "target/test-results")).resolve("heap-dumps")}"), |
70 |
| - Test / publishArtifact := true) |
71 |
| - |
72 |
| -val isCI = sys.env.getOrElse("CI", "false").toBoolean |
73 |
| - |
74 |
| -lazy val publishSettings = Seq( |
75 |
| - versionScheme := Some("early-semver"), |
76 |
| - publish / skip := false, |
77 |
| - publishMavenStyle := true, |
78 |
| - publishTo := Some("GitHub raw-labs Apache Maven Packages" at "https://maven.pkg.github.com/raw-labs/das-salesforce"), |
79 |
| - publishConfiguration := publishConfiguration.value.withOverwrite(isCI)) |
80 |
| - |
81 |
| -lazy val strictBuildSettings = |
82 |
| - commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq(scalacOptions ++= Seq("-Xfatal-warnings")) |
| 1 | +import SbtDASPlugin.autoImport.* |
83 | 2 |
|
84 | 3 | lazy val root = (project in file("."))
|
85 |
| - .enablePlugins(JavaAppPackaging, DockerPlugin) |
| 4 | + .enablePlugins(SbtDASPlugin) |
86 | 5 | .settings(
|
87 |
| - name := "das-salesforce", |
88 |
| - strictBuildSettings, |
89 |
| - publishSettings, |
| 6 | + repoNameSetting := "das-salesforce", |
90 | 7 | libraryDependencies ++= Seq(
|
91 | 8 | // DAS
|
92 |
| - "com.raw-labs" %% "das-server-scala" % "0.4.1" % "compile->compile;test->test", |
93 |
| - "com.raw-labs" %% "protocol-das" % "1.0.0" % "compile->compile;test->test", |
| 9 | + "com.raw-labs" %% "das-server-scala" % "0.6.0" % "compile->compile;test->test", |
94 | 10 | // Salesforce client
|
95 | 11 | "com.frejo" % "force-rest-api" % "0.0.45",
|
96 | 12 | // Jackson
|
97 | 13 | "joda-time" % "joda-time" % "2.12.7",
|
98 | 14 | "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.18.2",
|
99 | 15 | "com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % "2.18.2",
|
100 | 16 | "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.18.2",
|
101 |
| - "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.18.2" |
102 |
| - ) |
103 |
| - , |
104 |
| - dependencyOverrides ++= Seq( |
105 |
| - "io.netty" % "netty-handler" % "4.1.118.Final", |
106 |
| - "com.google.protobuf" % "protobuf-java" % "3.25.5" |
107 |
| - ), |
108 |
| - dockerSettings |
109 |
| - ) |
110 |
| - |
111 |
| -lazy val dockerSettings = Seq( |
112 |
| - Docker/ packageName := "das-salesforce-server", |
113 |
| - dockerBaseImage := "eclipse-temurin:21-jre", |
114 |
| - dockerLabels ++= Map( |
115 |
| - "vendor" -> "RAW Labs SA", |
116 |
| - "product" -> "das-salesforce-server", |
117 |
| - "image-type" -> "final", |
118 |
| - "org.opencontainers.image.source" -> "https://github.com/raw-labs/das-salesforce"), |
119 |
| - Docker / daemonUser := "raw", |
120 |
| - Docker / daemonUserUid := Some("1001"), |
121 |
| - Docker / daemonGroup := "raw", |
122 |
| - Docker / daemonGroupGid := Some("1001"), |
123 |
| - dockerExposedVolumes := Seq("/var/log/raw"), |
124 |
| - dockerExposedPorts := Seq(50051), |
125 |
| - dockerEnvVars := Map("PATH" -> s"${(Docker / defaultLinuxInstallLocation).value}/bin:$$PATH"), |
126 |
| - dockerEnvVars += "LANG" -> "C.UTF-8", |
127 |
| - updateOptions := updateOptions.value.withLatestSnapshots(true), |
128 |
| - Linux / linuxPackageMappings += packageTemplateMapping(s"/var/lib/${packageName.value}")(), |
129 |
| - bashScriptDefines := { |
130 |
| - val ClasspathPattern = "declare -r app_classpath=\"(.*)\"\n".r |
131 |
| - bashScriptDefines.value.map { |
132 |
| - case ClasspathPattern(classpath) => s""" |
133 |
| - |declare -r app_classpath="$${app_home}/../conf:$classpath" |
134 |
| - |""".stripMargin |
135 |
| - case _ @entry => entry |
136 |
| - } |
137 |
| - }, |
138 |
| - Docker / dockerLayerMappings := (Docker / dockerLayerMappings).value.map { |
139 |
| - case lm @ LayeredMapping(Some(1), file, path) => { |
140 |
| - val fileName = java.nio.file.Paths.get(path).getFileName.toString |
141 |
| - if (!fileName.endsWith(".jar")) { |
142 |
| - // If it is not a jar, put it on the top layer. Configuration files and other small files. |
143 |
| - LayeredMapping(Some(2), file, path) |
144 |
| - } else if (fileName.startsWith("com.raw-labs") && fileName.endsWith(".jar")) { |
145 |
| - // If it is one of our jars, also top layer. These will change often. |
146 |
| - LayeredMapping(Some(2), file, path) |
147 |
| - } else { |
148 |
| - // Otherwise it is a 3rd party library, which only changes when we change dependencies, so leave it in layer 1 |
149 |
| - lm |
150 |
| - } |
151 |
| - } |
152 |
| - case lm @ _ => lm |
153 |
| - }, |
154 |
| - dockerAlias := dockerAlias.value.withTag(Option(version.value.replace("+", "-"))), |
155 |
| - dockerAliases := { |
156 |
| - val devRegistry = sys.env.getOrElse("DEV_REGISTRY", "ghcr.io/raw-labs/das-salesforce") |
157 |
| - val releaseRegistry = sys.env.get("RELEASE_DOCKER_REGISTRY") |
158 |
| - val baseAlias = dockerAlias.value.withRegistryHost(Some(devRegistry)) |
159 |
| - |
160 |
| - releaseRegistry match { |
161 |
| - case Some(releaseReg) => Seq(baseAlias, dockerAlias.value.withRegistryHost(Some(releaseReg))) |
162 |
| - case None => Seq(baseAlias) |
163 |
| - } |
164 |
| - }) |
165 |
| - |
166 |
| -lazy val printDockerImageName = taskKey[Unit]("Prints the full Docker image name that will be produced") |
167 |
| - |
168 |
| -printDockerImageName := { |
169 |
| - // Get the main Docker alias (the first one in the sequence) |
170 |
| - val alias = (Docker / dockerAliases).value.head |
171 |
| - // The toString method already returns the full image name with registry and tag |
172 |
| - println(s"DOCKER_IMAGE=${alias}") |
173 |
| -} |
| 17 | + "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.18.2"), |
| 18 | + dependencyOverrides ++= Seq( |
| 19 | + "io.netty" % "netty-handler" % "4.1.118.Final" |
| 20 | + )) |
0 commit comments