Skip to content

Commit

Permalink
extract local dependencies into single file for easier updating
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Sep 27, 2024
1 parent 8662c87 commit f039e41
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 77 deletions.
89 changes: 37 additions & 52 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ lazy val aead = crossProject(JSPlatform, JVMPlatform).in(file("Modules/Aead"))
Dependencies.munitCheck,
)
.jvmSettings(
LocalSettings.tink
DependenciesLocal.tink
)
.jsSettings(
Compile / npmDependencies ++= Seq(
Expand All @@ -79,12 +79,12 @@ lazy val channels = crossProject(JSPlatform, JVMPlatform, NativePlatform).crossT
.jsSettings(
Settings.jsEnvDom,
Dependencies.scalajsDom,
Dependencies.scalatags,
Dependencies.scalatags(),
)
.jvmSettings(
Test / fork := true,
libraryDependencies ++= LocalSettings.jetty.map(_ % Provided),
LocalSettings.slf4jSimpleTest,
libraryDependencies ++= DependenciesLocal.jetty.map(_ % Provided),
DependenciesLocal.slf4jSimple,
)

lazy val deltalens = project.in(file("Modules/Deltalens"))
Expand All @@ -94,9 +94,7 @@ lazy val deltalens = project.in(file("Modules/Deltalens"))
Settings.explicitNulls(Compile / compile),
Settings.safeInit(Compile / compile),
Dependencies.munit,
libraryDependencies ++= Seq("flatspec", "shouldmatchers").map(m =>
"org.scalatest" %%% s"scalatest-$m" % "3.2.19" % Test
),
DependenciesLocal.scalatest,
)

lazy val dtn = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Full)
Expand All @@ -107,11 +105,8 @@ lazy val dtn = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Full)
Settings.explicitNulls(Compile / compile),
Settings.safeInit(Compile / compile),
Dependencies.jsoniterScala,
libraryDependencies ++= List(
"com.softwaremill.sttp.client4" %%% "core" % "4.0.0-M17",
"io.bullet" %%% "borer-core" % "1.14.1",
"io.bullet" %%% "borer-derivation" % "1.14.1"
)
DependenciesLocal.sttpCore,
DependenciesLocal.borer
)

lazy val exampleLenses = project.in(file("Modules/Examples/ReactiveLenses"))
Expand All @@ -121,8 +116,8 @@ lazy val exampleLenses = project.in(file("Modules/Examples/ReactiveLenses"))
scala3defaults,
Settings.explicitNulls(Compile / compile),
Settings.safeInit(Compile / compile),
Dependencies.scalatags,
LocalSettings.deployTask,
Dependencies.scalatags(),
SettingsLocal.deployTask,
)

lazy val examplesMiscJVM = project.in(file("Modules/Examples/Misc JVM"))
Expand All @@ -133,13 +128,11 @@ lazy val examplesMiscJVM = project.in(file("Modules/Examples/Misc JVM"))
fork := true,
Dependencies.jsoniterScala,
Dependencies.munitCheck,
LocalSettings.tink,
libraryDependencies += LocalSettings.scalafx,
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % "2.3.0",
"org.scala-lang.modules" %% "scala-swing" % "3.0.0"
),
libraryDependencies += "org.conscrypt" % "conscrypt-openjdk-uber" % "2.5.2",
DependenciesLocal.tink,
libraryDependencies += DependenciesLocal.scalafx,
DependenciesLocal.scalaXml,
DependenciesLocal.scalaSwing,
DependenciesLocal.conscript,
Settings.implicitConversions(), // reswing uses this in a million places for no reason
)

Expand All @@ -149,9 +142,9 @@ lazy val loCal = project.in(file("Modules/Examples/Lore Calendar"))
.settings(
scala3defaults,
Settings.resolverJitpack,
Dependencies.scalatags,
Dependencies.scalatags(),
Dependencies.jsoniterScala,
LocalSettings.deployTask
SettingsLocal.deployTask
)

lazy val lofiAcl = project.in(file("Modules/Local-first Access Control"))
Expand All @@ -164,25 +157,17 @@ lazy val lofiAcl = project.in(file("Modules/Local-first Access Control"))
Dependencies.munit,
Dependencies.munitCheck,
Dependencies.jsoniterScala,
LocalSettings.tink,
libraryDependencies ++=
List(
// Note, the below means JDK 1.4
"org.slf4j" % "slf4j-jdk14" % "2.0.16",
// Note, the below means JDK 1.8, aka Java 8
"org.bouncycastle" % "bcprov-jdk18on" % "1.78.1",
"org.bouncycastle" % "bcpkix-jdk18on" % "1.78.1",
"io.github.hakky54" % "sslcontext-kickstart" % "8.3.7",
"io.github.hakky54" % "sslcontext-kickstart-for-pem" % "8.3.7",
),
DependenciesLocal.tink,
DependenciesLocal.slf4j,
DependenciesLocal.bouncyCastle,
Test / fork := true,
)

lazy val lofiAclExample = project.in(file("Modules/Local-first Access Control/Example"))
.dependsOn(lofiAcl)
.settings(
scala3defaults,
libraryDependencies += LocalSettings.scalafx,
libraryDependencies += DependenciesLocal.scalafx,
Dependencies.jsoniterScala,
Dependencies.munit,
publish / skip := true,
Expand All @@ -194,10 +179,10 @@ lazy val lore = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Full).
scala3defaults,
Settings.javaOutputVersion(17),
Dependencies.jsoniterScala,
libraryDependencies += "com.monovore" %%% "decline" % "2.4.1",
libraryDependencies += "org.typelevel" %%% "cats-parse" % "1.0.0",
libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.5.0",
libraryDependencies += "dev.optics" %%% "monocle-core" % "3.3.0",
DependenciesLocal.decline,
DependenciesLocal.catsParse,
DependenciesLocal.fansi,
DependenciesLocal.monocleCore,
Dependencies.munit,
Compile / mainClass := Some("lore.Compiler")
)
Expand Down Expand Up @@ -231,8 +216,8 @@ lazy val microbenchmarks = project.in(file("Modules/Microbenchmarks"))
Settings.safeInit(Compile / compile),
Dependencies.jsoniterScala,
Settings.jolSettings,
LocalSettings.tink,
libraryDependencies += "org.conscrypt" % "conscrypt-openjdk-uber" % "2.5.2",
DependenciesLocal.tink,
DependenciesLocal.conscript,
)

lazy val rdts = crossProject(JVMPlatform, JSPlatform, NativePlatform).crossType(CrossType.Pure)
Expand All @@ -242,7 +227,7 @@ lazy val rdts = crossProject(JVMPlatform, JSPlatform, NativePlatform).crossType(
Settings.javaOutputVersion(8),
Settings.safeInit(Compile / compile),
Settings.explicitNulls(Compile / compile),
LocalSettings.publishSonatype,
SettingsLocal.publishSonatype,
Dependencies.munit,
Dependencies.munitCheck,
)
Expand All @@ -259,16 +244,16 @@ lazy val reactives = crossProject(JVMPlatform, JSPlatform, NativePlatform).in(fi
// scaladoc
autoAPIMappings := true,
Compile / doc / scalacOptions += "-groups",
LocalSettings.publishSonatype,
SettingsLocal.publishSonatype,
Dependencies.munitCheck,
Dependencies.munit,
)
.jvmSettings(
libraryDependencies += LocalSettings.scalafx % Provided,
libraryDependencies += DependenciesLocal.scalafx % Provided,
)
.jsSettings(
Dependencies.scalajsDom,
libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.13.1" % Test,
Dependencies.scalatags(Test),
Settings.jsEnvDom,
Settings.sourcemapFromEnv(),
)
Expand Down Expand Up @@ -304,12 +289,12 @@ lazy val replicationExamples = crossProject(JVMPlatform, JSPlatform).crossType(C
.jvmSettings(
Dependencies.slips.script,
Dependencies.sqliteJdbc,
LocalSettings.slf4jSimpleTest,
libraryDependencies ++= LocalSettings.jetty,
DependenciesLocal.slf4jSimple,
libraryDependencies ++= DependenciesLocal.jetty,
)
.jsSettings(
Dependencies.scalatags,
LocalSettings.deployTask,
Dependencies.scalatags(),
SettingsLocal.deployTask,
)

lazy val todolist = project.in(file("Modules/Examples/TodoMVC"))
Expand All @@ -320,9 +305,9 @@ lazy val todolist = project.in(file("Modules/Examples/TodoMVC"))
Settings.explicitNulls(Compile / compile),
Settings.safeInit(Compile / compile),
Settings.resolverJitpack,
Dependencies.scalatags,
Dependencies.scalatags(),
Dependencies.jsoniterScala,
LocalSettings.deployTask,
SettingsLocal.deployTask,
Dependencies.pprint,
)

Expand All @@ -348,6 +333,6 @@ lazy val webview = project.in(file("Modules/Webview"))
.withIncrementalCompilation(true)
// The below disables LTO for macos as that seems to cause problems.
// Windows not implemented, macos has known issues.
LocalSettings.osSpecificWebviewConfig(d)
SettingsLocal.osSpecificWebviewConfig(d)
}
)
10 changes: 6 additions & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ object Dependencies {
def scalacheck = libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.18.1" % Test
def scalaJavaTime = libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.3.0"
def scalajsDom = libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.8.0"
def scalatags = libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.13.1"
def sqliteJdbc = libraryDependencies += "org.xerial" % "sqlite-jdbc" % "3.46.1.0"
def sqliteJdbc = libraryDependencies += "org.xerial" % "sqlite-jdbc" % "3.46.1.3"

def scalatags(conf: Configuration = Compile) = libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.13.1" % conf

def jsoniterScala =
libraryDependencies ++= Seq(
"com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-core" % "2.30.11",
"com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-macros" % "2.30.11" % Provided
"com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-core" % "2.30.12",
"com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-macros" % "2.30.12" % Provided
)

object slips {
Expand Down
48 changes: 48 additions & 0 deletions project/DependenciesLocal.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport.*
import sbt.*
import sbt.Keys.libraryDependencies

object DependenciesLocal {

val catsParse = libraryDependencies += "org.typelevel" %%% "cats-parse" % "1.0.0"
val conscript = libraryDependencies += "org.conscrypt" % "conscrypt-openjdk-uber" % "2.5.2"
val decline = libraryDependencies += "com.monovore" %%% "decline" % "2.4.1"
val fansi = libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.5.0"
val monocleCore = libraryDependencies += "dev.optics" %%% "monocle-core" % "3.3.0"
val scalaSwing = libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0"
val scalaXml = libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.3.0"
val slf4j = libraryDependencies += "org.slf4j" % "slf4j-jdk14" % "2.0.16" // jdk 1.4
val slf4jSimple = libraryDependencies += "org.slf4j" % "slf4j-simple" % "2.0.16" % Test
val sttpCore = libraryDependencies += "com.softwaremill.sttp.client4" %%% "core" % "4.0.0-M18"
val tink = libraryDependencies += "com.google.crypto.tink" % "tink" % "1.15.0"

val bouncyCastle = libraryDependencies ++=
List(
// Note, jdk18 means JDK 1.8
"org.bouncycastle" % "bcprov-jdk18on" % "1.78.1",
"org.bouncycastle" % "bcpkix-jdk18on" % "1.78.1",
"io.github.hakky54" % "sslcontext-kickstart" % "8.3.7",
"io.github.hakky54" % "sslcontext-kickstart-for-pem" % "8.3.7",
)

def borer = libraryDependencies ++= Seq(
"io.bullet" %%% "borer-core" % "1.14.1",
"io.bullet" %%% "borer-derivation" % "1.14.1"
)

def jetty = {
val jettyVersion = "12.0.13"
Seq(
"org.eclipse.jetty.websocket" % "jetty-websocket-jetty-server" % jettyVersion,
"org.eclipse.jetty.websocket" % "jetty-websocket-jetty-client" % jettyVersion,
"org.eclipse.jetty.websocket" % "jetty-websocket-jetty-api" % jettyVersion,
)
}

def scalafx: ModuleID = "org.scalafx" %% "scalafx" % "22.0.0-R33"

val scalatest = libraryDependencies ++= Seq("flatspec", "shouldmatchers").map(m =>
"org.scalatest" %%% s"scalatest-$m" % "3.2.19" % Test
)

}
5 changes: 0 additions & 5 deletions project/JarExport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ object JarExport extends sbt.AutoPlugin {
// though, it does not yet define behaviour
val packageJars = TaskKey[File]("packageJars", "copies classpath jars to a file in the target dir")


val writeClasspathPath = SettingKey[File]("writeClasspathPath", "The file to write the classpath to.")
// second additional command, same as the above
val writeClasspath = TaskKey[File]("writeClasspath", "writes the classpath to a file in the target dir")

// This defines settings the plugin makes.
// It is essentially the same as if this was in a `.settings()` block in the build.sbt
override lazy val projectSettings: Seq[Setting[?]] = Seq(


// copy all jars required in the class path to a `jars` folder in the target directory
packageJars := {
val cp = (Compile / fullClasspathAsJars).value
Expand All @@ -36,8 +33,6 @@ object JarExport extends sbt.AutoPlugin {
// the return value is what `show stageJars` will display
targetpath.toFile
},


writeClasspathPath := crossTarget.value.toPath.resolve("classpath.txt").toFile,

// write the classpath into a file that can be passed to java as a commandline argument file
Expand Down
17 changes: 1 addition & 16 deletions project/LocalSettings.scala → project/SettingsLocal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@ import sbt.Keys.*

import scala.scalanative.build.{LTO, NativeConfig}

object LocalSettings {

def tink = libraryDependencies += "com.google.crypto.tink" % "tink" % "1.15.0"

def scalafx: ModuleID = "org.scalafx" %% "scalafx" % "22.0.0-R33"

def slf4jSimpleTest = libraryDependencies += "org.slf4j" % "slf4j-simple" % "2.0.16" % Test

def jetty = {
val jettyVersion = "12.0.13"
Seq(
"org.eclipse.jetty.websocket" % "jetty-websocket-jetty-server" % jettyVersion,
"org.eclipse.jetty.websocket" % "jetty-websocket-jetty-client" % jettyVersion,
"org.eclipse.jetty.websocket" % "jetty-websocket-jetty-api" % jettyVersion,
)
}
object SettingsLocal {

val deployTask = TaskKey[File]("deploy", "generates a correct index.template.html") := {
val fastlink = (Compile / fastLinkJS).value
Expand Down

0 comments on commit f039e41

Please sign in to comment.