Skip to content

Scala 3 migration of remaining modules JAVA-29058 #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 12, 2023
Merged
27 changes: 18 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ lazy val scala_core_7 = (project in file("scala-core-modules/scala-core-7"))
name := "scala-core-7",
scalaVersion := scala3Version,
libraryDependencies ++= scalaTestDeps,
libraryDependencies += jUnitInterface,
libraryDependencies += jUnitInterface
)

lazy val scala_core_8 = (project in file("scala-core-modules/scala-core-8"))
Expand Down Expand Up @@ -194,11 +194,11 @@ lazy val scala_core_map =
lazy val scala_test = (project in file("scala-test"))
.settings(
name := "scala-test",
scalaVersion := scala3Version,
libraryDependencies ++=
Seq(
"org.scalatestplus" %% "mockito-3-4" % "3.2.10.0" % Test,
jUnitInterface,
scalaMock
jUnitInterface
) ++ scalaTestDeps
)

Expand Down Expand Up @@ -373,6 +373,7 @@ lazy val scala_libraries_3 = (project in file("scala-libraries-3"))
lazy val scala_libraries_os = (project in file("scala-libraries-os"))
.settings(
name := "scala-libraries",
scalaVersion := scala3Version,
libraryDependencies ++= scalaTestDeps,
libraryDependencies ++= Seq(
"org.apache.logging.log4j" %% "log4j-api-scala" % "13.0.0",
Expand Down Expand Up @@ -472,8 +473,9 @@ lazy val scala_strings = (project in file("scala-strings"))
lazy val scala_design_patterns = (project in file("scala-design-patterns"))
.settings(
name := "scala-design-patterns",
scalaVersion := scala3Version,
libraryDependencies ++= scalaTestDeps,
libraryDependencies += scalaMock,
libraryDependencies += "org.scalatestplus" %% "mockito-3-4" % "3.2.10.0" % Test,
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
)

Expand Down Expand Up @@ -534,16 +536,18 @@ lazy val doobie = (project in file("doobie"))
// lazy val scala_native = (project in file("scala-native"))
// .settings(
// name := "scala-native",
// libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.3.0"
// scalaVersion := scala3Version,
// libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.4.0"
// )

// ScalaPy Python Project is disabled as it needs clang and python to installed in the target machine.
// To test this code, install clang, python and then uncommment this build
// lazy val scala_python = (project in file("scala-python"))
// .settings(
// name := "scala-python",
// libraryDependencies += "me.shadaj" %% "scalapy-core" % "0.5.2",
// fork := true
// libraryDependencies += "dev.scalapy" %%% "scalapy-core" % "0.5.3",
// fork := true,
// scalaVersion := scala3Version
// )

lazy val reflection = (project in file("reflection"))
Expand All @@ -559,7 +563,9 @@ lazy val scala3_libraries = (project in file("scala3-libraries"))
name := "scala3-libraries",
libraryDependencies ++= Seq(
"com.github.japgolly.clearconfig" %% "core" % "3.1.0",
"org.scalameta" %% "munit" % "0.7.29" % Test
"org.scalameta" %% "munit" % "0.7.29" % Test,
"org.tpolecat" %% "doobie-core" % "1.0.0-RC2",
"org.tpolecat" %% "doobie-postgres" % "1.0.0-RC2"
)
)

Expand Down Expand Up @@ -612,7 +618,10 @@ addCommandAlias(
lazy val playGroup = (project in file("play-scala"))

//Uncomment this to enable scala-js module. It needs nodejs module as well in local machine
//lazy val scalajs = project in file("scala-js")
//lazy val scalajs = (project in file("scala-js"))
// .settings(
// scalaVersion := scala3Version
// )
lazy val scalatra = project in file("scalatra")
lazy val benchmark = project in file("specialized-benchmark")

Expand Down
3 changes: 0 additions & 3 deletions doobie/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.10")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.0")

addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.2.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.baeldung.scala.magnetpattern

import scala.language.implicitConversions

object MagnetPattern extends App {

/*
Expand All @@ -20,11 +22,15 @@ object MagnetPattern extends App {

def combineElements(magnet: CombineMagnet): magnet.Result = magnet()

implicit def intCombineMagnet(intList: List[Int]) = new CombineMagnet {
implicit def intCombineMagnet(
intList: List[Int]
): CombineMagnet { type Result = Int } = new CombineMagnet {
override type Result = Int
override def apply(): Result = intList.reduce((i, c) => i + c)
}
implicit def strCombineMagnet(stringList: List[String]) = new CombineMagnet {
implicit def strCombineMagnet(
stringList: List[String]
): CombineMagnet { type Result = String } = new CombineMagnet {
override type Result = String
override def apply(): Result = stringList.reduce((s, c) => s.concat(c))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package com.baeldung.scala.cakepattern

import com.baeldung.scala.cakepattern.CakePattern.Test
import org.scalamock.scalatest.MockFactory
import org.mockito.Mockito.when
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatestplus.mockito.MockitoSugar

trait TestRegistry
extends CakePattern.TestExecutorComponent
with CakePattern.TestEnvironmentComponent
with MockFactory {
with MockitoSugar {
override val env: TestEnvironment = mock[TestEnvironment]
override val testExecutor: TestExecutor = new TestExecutor
}

class CakePatternUnitTest extends AnyFlatSpec with TestRegistry {

"A TestExecutor" should "execute tests using a given environment" in {
(env.readEnvironmentProperties _).expects().returning(Map("ENV" -> "true"))
when(env.readEnvironmentProperties).thenReturn(Map("ENV" -> "true"))
val test = Test(
"test-1",
{ environment =>
Expand Down
6 changes: 2 additions & 4 deletions scala-js/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ version := "1.0-SNAPSHOT"

enablePlugins(ScalaJSPlugin)

scalaVersion := "2.13.12"

scalaJSUseMainModuleInitializer := true
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.2.0"
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.1.2" % Test
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.8.0"
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.2.17" % Test

//enable the below setting after installing npm package jsdom.
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ object NativeApp {
}

def main(args: Array[String]): Unit = {
printFromNative
simpleNative
nativeFromCFile
testCurl
printFromNative()
simpleNative()
nativeFromCFile()
testCurl()
}

}
1 change: 0 additions & 1 deletion scala-sbt/sbt-info/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8")

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class CollectionTest extends AnyFlatSpec with Matchers {
val cities2 = List("Barcelona", "Hamburg")
Random.shuffle(cities) should contain theSameElementsAs (cities2)
cities shouldBe cities2
cities ++ cities should contain only (cities2: _*) // but duplicates are allowed
cities should contain only (cities2: _*)
cities ++ cities should contain only ("Barcelona", "Hamburg") // but duplicates are allowed
cities should contain only ("Barcelona", "Hamburg")
}

it should "pass if both collections contains exactly same elements in same order" in {
Expand Down
1 change: 1 addition & 0 deletions scala3-libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
### Relevant Articles:
- [Scala App Configurations With Clarity Using ClearConfig](https://www.baeldung.com/scala/clearconfig)
- [Introduction to MUnit](https://www.baeldung.com/scala/munit-introduction)
- [Introduction to doobie – a JDBC Layer for Scala](https://www.baeldung.com/scala/doobie-intro)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.scala.doobie
package com.baledung.doobie

import cats.effect.{IO, IOApp}
import doobie.implicits._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.scala.doobie
package com.baledung.doobie

import cats.effect.{IO, IOApp}
import doobie.implicits._
Expand Down