Skip to content

Commit 7c08b2e

Browse files
authored
Merge branch 'Baeldung:master' into transparent-scala3
2 parents 582586e + f7efc28 commit 7c08b2e

File tree

25 files changed

+1058
-554
lines changed

25 files changed

+1058
-554
lines changed

app-packaging/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name := "app-packaging"
22
version := "1.0.2"
33

4-
ThisBuild / scalaVersion := "3.1.0"
4+
ThisBuild / scalaVersion := "3.2.0"
55

66
libraryDependencies ++= Seq(
77
"com.lihaoyi" %% "os-lib" % "0.7.8"

build.sbt

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
val scalaV = "2.12.15"
1+
val scalaV = "2.13.10"
22
ThisBuild / scalaVersion := scalaV
33
ThisBuild / version := "1.0-SNAPSHOT"
44
ThisBuild / organization := "com.baeldung"
55
ThisBuild / organizationName := "core-scala"
66

77
val scalaTest = "org.scalatest" %% "scalatest" % "3.1.2" % Test
88
val junit = "com.novocode" % "junit-interface" % "0.11" % "test"
9-
val catsEffect = "org.typelevel" % "cats-effect_2.12" % "2.1.4"
10-
val catsCore = "org.typelevel" % "cats-effect_2.12" % "2.1.4"
9+
val catsEffect = "org.typelevel" %% "cats-effect" % "2.1.4"
10+
val catsCore = "org.typelevel" %% "cats-effect" % "2.1.4"
1111

1212
lazy val scala_core = (project in file("scala-core"))
1313
.settings(
@@ -24,15 +24,15 @@ lazy val scala_core = (project in file("scala-core"))
2424
lazy val scala_core_2 = (project in file("scala-core-2"))
2525
.settings(
2626
name := "scala-core-2",
27-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
27+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
2828
libraryDependencies += "org.scalamock" %% "scalamock" % "4.4.0" % Test,
2929
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
3030
)
3131

3232
lazy val scala_core_3 = (project in file("scala-core-3"))
3333
.settings(
3434
name := "scala-core-3",
35-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
35+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
3636
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
3737
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaV,
3838
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.0.0-M1"
@@ -41,7 +41,7 @@ lazy val scala_core_3 = (project in file("scala-core-3"))
4141
lazy val scala_core_4 = (project in file("scala-core-4"))
4242
.settings(
4343
name := "scala-core-4",
44-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
44+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
4545
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
4646
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaV,
4747
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.0.0-M1"
@@ -50,7 +50,7 @@ lazy val scala_core_4 = (project in file("scala-core-4"))
5050
lazy val scala_core_5 = (project in file("scala-core-5"))
5151
.settings(
5252
name := "scala-core-5",
53-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
53+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
5454
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
5555
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaV,
5656
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.0.0-M1",
@@ -62,15 +62,15 @@ lazy val scala_core_5 = (project in file("scala-core-5"))
6262
lazy val scala_core_6 = (project in file("scala-core-6"))
6363
.settings(
6464
name := "scala-core-6",
65-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
65+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
6666
libraryDependencies += "org.scalamock" %% "scalamock" % "4.4.0" % Test,
6767
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
6868
)
6969

7070
lazy val scala_core_7 = (project in file("scala-core-7"))
7171
.settings(
7272
name := "scala-core-7",
73-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
73+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
7474
libraryDependencies += "org.scalamock" %% "scalamock" % "4.4.0" % Test,
7575
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
7676
libraryDependencies += "com.github.scopt" %% "scopt" % "4.0.1",
@@ -114,24 +114,24 @@ lazy val scala_core_fp = (project in file("scala-core-fp"))
114114
lazy val scala_lang = (project in file("scala-lang"))
115115
.settings(
116116
name := "scala-lang",
117-
scalacOptions += "-Ypartial-unification",
118117
libraryDependencies ++=
119118
Seq(scalaTest, junit)
120119
)
121120

122121
lazy val scala_lang_2 = (project in file("scala-lang-2"))
123122
.settings(
124123
name := "scala-lang",
125-
scalacOptions += "-Ypartial-unification",
126124
libraryDependencies ++=
127125
Seq(scalaTest, junit)
128126
)
129127

130128
lazy val scala_core_collections = (project in file("scala-core-collections"))
131129
.settings(
132130
name := "scala-core-collections",
133-
libraryDependencies +=
134-
scalaTest
131+
libraryDependencies ++= Seq(
132+
scalaTest,
133+
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
134+
)
135135
)
136136

137137
lazy val scala_core_collections_2 = (project in file("scala-core-collections-2"))
@@ -154,14 +154,14 @@ lazy val scala_test = (project in file("scala-test"))
154154
)
155155

156156
lazy val scala_akka_dependencies: Seq[ModuleID] = Seq(
157-
"com.typesafe.akka" % "akka-actor-typed_2.12" % "2.6.19",
157+
"com.typesafe.akka" %% "akka-actor-typed" % "2.6.19",
158158
"ch.qos.logback" % "logback-classic" % "1.2.3",
159-
"com.typesafe.akka" % "akka-actor-testkit-typed_2.12" % "2.6.19" % Test,
159+
"com.typesafe.akka" %% "akka-actor-testkit-typed" % "2.6.19" % Test,
160160
"com.lightbend.akka" %% "akka-stream-alpakka-mongodb" % "2.0.1",
161161
"com.typesafe.akka" %% "akka-stream" % "2.6.19",
162162
"org.mongodb.scala" %% "mongo-scala-driver" % "2.9.0",
163163
"com.lightbend.akka" %% "akka-stream-alpakka-file" % "2.0.2",
164-
"org.scalatest" %% "scalatest" % "3.0.5" % Test,
164+
"org.scalatest" %% "scalatest" % "3.1.2" % Test,
165165
"com.novocode" % "junit-interface" % "0.11" % "test",
166166
"de.flapdoodle.embed" % "de.flapdoodle.embed.mongo" % "2.2.0" % Test,
167167
"com.typesafe.akka" %% "akka-http" % "10.2.7"
@@ -237,6 +237,7 @@ val sparkVersion = "3.2.1"
237237

238238
lazy val scala_libraries_2 = (project in file("scala-libraries-2"))
239239
.settings(
240+
scalaVersion := "2.12.15",
240241
name := "scala-libraries",
241242
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
242243
libraryDependencies ++= Seq(
@@ -339,14 +340,14 @@ lazy val scala_libraries_4 = (project in file("scala-libraries-4"))
339340
lazy val scala_strings = (project in file("scala-strings"))
340341
.settings(
341342
name := "scala-strings",
342-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
343+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
343344
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
344345
)
345346

346347
lazy val scala_design_patterns = (project in file("scala-design-patterns"))
347348
.settings(
348349
name := "scala-design-patterns",
349-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test,
350+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.2" % Test,
350351
libraryDependencies += "org.scalamock" %% "scalamock" % "4.4.0" % Test,
351352
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
352353
)
@@ -405,3 +406,12 @@ lazy val scala3_libraries = (project in file("scala3-libraries"))
405406
)
406407

407408
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-eG")
409+
410+
lazy val scala212 = (project in file("scala212"))
411+
.settings(
412+
scalaVersion := "2.12.17",
413+
name := "scala212",
414+
libraryDependencies ++= Seq(
415+
scalaTest
416+
)
417+
)

scala-akka/src/main/scala/com/baeldung/scala/akka/supervision/SupervisionApplication.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ object SupervisionApplication {
123123
.supervise(search)
124124
.onFailure[IOException](SupervisorStrategy.resume))
125125
.onFailure[Exception](SupervisorStrategy.restart.withLimit(
126-
maxNrOfRetries = 10, withinTimeRange = 5 minutes))
126+
maxNrOfRetries = 10, withinTimeRange = 5.minutes))
127127
}
128128

129129
private def search: Behavior[FsFind] =

scala-akka/src/test/scala/com/baeldung/scala/akka/supervision/SupervisionApplicationUnitTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SupervisionApplicationUnitTest extends FlatSpec with BeforeAndAfterAll {
3838
val webServerClient = testKit.createTestProbe[Response]()
3939
webServer ! Get("http://restart", webServerClient.ref)
4040
webServer ! Get("http://a-valid-uri", webServerClient.ref)
41-
webServerClient.expectMessageType[Ok](5 seconds)
41+
webServerClient.expectMessageType[Ok](5.seconds)
4242
}
4343

4444
"The Cache actor" should "resume from an error" in {
@@ -47,7 +47,7 @@ class SupervisionApplicationUnitTest extends FlatSpec with BeforeAndAfterAll {
4747
val cacheClient = testKit.createTestProbe[Cache.Response]()
4848
cache ! Find("http://resume", cacheClient.ref)
4949
cache ! Find("http://a-valid-uri", cacheClient.ref)
50-
cacheClient.expectMessageType[Hit](5 seconds)
50+
cacheClient.expectMessageType[Hit](5.seconds)
5151
}
5252

5353
override protected def afterAll(): Unit = testKit.shutdownTestKit()

scala-core-3/src/main/scala/com/baeldung/scala/iteratorsvsstreamsvsviews/NonStrictDataStructures.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ object NonStrictDataStructures {
66
val data = Seq.range(0, 3)
77
val iter = data.iterator
88
val stream = data.toStream
9-
val view: AnyRef with SeqView[Int, Seq[Int]] = data.view
9+
//todo: check if this is ok, better to separate into separate module
10+
//val view: AnyRef with SeqView[Int, Seq[Int]] = data.view
11+
val view: AnyRef with SeqView[Int] = data.view
1012
}
1113

1214
case class Factorial() {

scala-core-3/src/test/scala/com/baeldung/scala/await/AwaitFutureUnitTest.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AwaitFutureUnitTest extends AwaitFutureTestUtil {
1616
val fut = AwaitFuture.fetchDataFrom(url)
1717

1818
fut.isCompleted shouldBe false
19-
val completedFuture = Await.ready(fut, 2 seconds)
19+
val completedFuture = Await.ready(fut, 2.seconds)
2020

2121
fut shouldBe completedFuture
2222
completedFuture.isCompleted shouldBe true
@@ -31,7 +31,7 @@ class AwaitFutureUnitTest extends AwaitFutureTestUtil {
3131
"throw a timeout Exception when the future doesn't complete within the stipulated time" in {
3232
val fut = AwaitFuture.fetchDataFrom(url, 3000)
3333
fut.isCompleted shouldBe false
34-
val exception = intercept[Exception](Await.ready(fut, 2 seconds))
34+
val exception = intercept[Exception](Await.ready(fut, 2.seconds))
3535

3636
val assertion = exception match {
3737
case _ : TimeoutException => true
@@ -45,7 +45,7 @@ class AwaitFutureUnitTest extends AwaitFutureTestUtil {
4545
val fut = AwaitFuture.futureWithException()
4646

4747
fut.isCompleted shouldBe false
48-
val completedFuture = Await.ready(fut, 2 seconds)
48+
val completedFuture = Await.ready(fut, 2.seconds)
4949

5050
fut shouldBe completedFuture
5151
completedFuture.isCompleted shouldBe true
@@ -62,13 +62,13 @@ class AwaitFutureUnitTest extends AwaitFutureTestUtil {
6262
val fut = AwaitFuture.fetchDataFrom(url)
6363

6464
fut.isCompleted shouldBe false
65-
val completedFutureResult = Await.result(fut, 2 seconds)
65+
val completedFutureResult = Await.result(fut, 2.seconds)
6666
completedFutureResult.isInstanceOf[String] shouldBe true
6767
}
6868
"throw a timeout Exception when the future doesn't complete within the stipulated time" in {
6969
val fut = AwaitFuture.fetchDataFrom("https://www.facebook.com", 5000)
7070
fut.isCompleted shouldBe false
71-
val exception = intercept[Exception](Await.result(fut, 2 seconds))
71+
val exception = intercept[Exception](Await.result(fut, 2.seconds))
7272

7373
val assertion = exception match {
7474
case _ : TimeoutException => true
@@ -81,7 +81,7 @@ class AwaitFutureUnitTest extends AwaitFutureTestUtil {
8181
val fut = AwaitFuture.futureWithException()
8282

8383
fut.isCompleted shouldBe false
84-
val exception = intercept[Exception](Await.result(fut, 2 seconds))
84+
val exception = intercept[Exception](Await.result(fut, 2.seconds))
8585

8686
val assertion = exception match {
8787
case _ : NullPointerException => true

scala-core-4/src/test/scala/com/baeldung/scala/structuraltypes/ResourceClosingUnitTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.baeldung.scala.structuraltypes
22

33
import org.scalatest.{FlatSpec, Matchers}
4-
5-
import scala.collection.convert.DecorateAsScala
4+
import scala.jdk.CollectionConverters._
65
import scala.io.Source
76

8-
class ResourceClosingUnitTest extends FlatSpec with Matchers with DecorateAsScala with ResourceClosing {
7+
class ResourceClosingUnitTest extends FlatSpec with Matchers with ResourceClosing {
98
"Scala Sources" should "be closed" in {
109
val file = Source.fromResource("animals")
1110
using(file) {

scala-core-4/src/test/scala/com/baeldung/scala/withfilter/WithFilterVsFilterUnitTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.baeldung.scala.withfilter
22

33
import java.util.concurrent.atomic.AtomicInteger
4-
54
import org.scalatest.{Matchers, WordSpec}
65

7-
import scala.collection.generic.FilterMonadic
6+
import scala.collection.WithFilter
87

98
class WithFilterVsFilterUnitTest extends WordSpec with Matchers {
109

@@ -71,7 +70,7 @@ class WithFilterVsFilterUnitTest extends WordSpec with Matchers {
7170
"filter programmers" in {
7271
implicit val counter: AtomicInteger = new AtomicInteger(0)
7372

74-
val desiredProgrammers: FilterMonadic[Programmer, List[Programmer]] =
73+
val desiredProgrammers: WithFilter[Programmer, List] =
7574
programmers
7675
.withFilter(isMidOrSenior)
7776
.withFilter(knowsMoreThan1Language)

scala-core-6/src/main/scala/com/baeldung/scala/functionalloops/FunctionalLoops.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.baeldung.scala.functionalloops
2-
2+
import scala.language.postfixOps
33
object FunctionalLoops {
44
def getSumOfList(list: List[Int]): Int = {
55
var sum = 0

0 commit comments

Comments
 (0)