-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1153 from ckipp01/sbt-by-example
refactor: update sbt-by-example
- Loading branch information
Showing
23 changed files
with
514 additions
and
529 deletions.
There are no files selected for viewing
262 changes: 127 additions & 135 deletions
262
src/reference/00-Getting-Started/02-sbt-by-example.md
Large diffs are not rendered by default.
Oops, something went wrong.
271 changes: 132 additions & 139 deletions
271
src/reference/es/00-Getting-Started/02-sbt-by-example.md
Large diffs are not rendered by default.
Oops, something went wrong.
287 changes: 140 additions & 147 deletions
287
src/reference/ja/00-Getting-Started/02-sbt-by-example.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.9.2", | ||
libraryDependencies += "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0", | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.7" % Test, | ||
libraryDependencies ++= Seq( | ||
"org.scala-lang" %% "toolkit" % "0.1.7", | ||
"org.scala-lang" %% "toolkit-test" % "0.1.7" % Test | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0", | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.7" % Test, | ||
libraryDependencies ++= Seq( | ||
"org.scala-lang" %% "toolkit" % "0.1.7", | ||
"org.scala-lang" %% "toolkit-test" % "0.1.7" % Test | ||
) | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
name := "Hello Core" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" | ||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % "0.1.7" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies ++= Seq( | ||
"org.scala-lang" %% "toolkit" % "0.1.7", | ||
toolkitTest % Test | ||
) | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += toolkitTest % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" | ||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % "0.1.7" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.aggregate(helloCore) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies ++= Seq( | ||
"org.scala-lang" %% "toolkit" % "0.1.7", | ||
toolkitTest % Test | ||
) | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += toolkitTest % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" | ||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % "0.1.7" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.aggregate(helloCore) | ||
.dependsOn(helloCore) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += toolkitTest % Test | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
libraryDependencies += "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7", | ||
libraryDependencies += toolkitTest % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
lazy val hello = project | ||
.in(file(".")) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += "org.scala-lang" %% "toolkit-test" % "0.1.7" % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
class HelloSuite extends munit.FunSuite { | ||
test("Hello should start with H") { | ||
assert("Hello".startsWith("H")) | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...-scalatest/src/test/scala/HelloSpec.scala → ...t/src/test/scala/example/HelloSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
> compile | ||
-> testQuick | ||
$copy-file changes/HelloSuite.scala src/test/scala/example/HelloSuite.scala | ||
> testQuick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" | ||
val gigahorse = "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0" | ||
val playJson = "com.typesafe.play" %% "play-json" % "2.9.2" | ||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % "0.1.7" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.aggregate(helloCore) | ||
.dependsOn(helloCore) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += toolkitTest % Test | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
libraryDependencies ++= Seq(gigahorse, playJson), | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7", | ||
libraryDependencies += toolkitTest % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" | ||
val gigahorse = "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0" | ||
val playJson = "com.typesafe.play" %% "play-json" % "2.9.2" | ||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % "0.1.7" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.aggregate(helloCore) | ||
.dependsOn(helloCore) | ||
.enablePlugins(JavaAppPackaging) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += toolkitTest % Test, | ||
maintainer := "A Scala Dev!" | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
libraryDependencies ++= Seq(gigahorse, playJson), | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7", | ||
libraryDependencies += toolkitTest % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
ThisBuild / version := "0.1.0" | ||
ThisBuild / scalaVersion := "2.13.6" | ||
ThisBuild / version := "0.1.0" | ||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / organization := "com.example" | ||
|
||
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" | ||
val gigahorse = "com.eed3si9n" %% "gigahorse-okhttp" % "0.5.0" | ||
val playJson = "com.typesafe.play" %% "play-json" % "2.9.2" | ||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % "0.1.7" | ||
|
||
lazy val hello = (project in file(".")) | ||
lazy val hello = project | ||
.in(file(".")) | ||
.aggregate(helloCore) | ||
.dependsOn(helloCore) | ||
.enablePlugins(JavaAppPackaging) | ||
.settings( | ||
name := "Hello", | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += toolkitTest % Test, | ||
maintainer := "A Scala Dev!" | ||
) | ||
|
||
lazy val helloCore = (project in file("core")) | ||
lazy val helloCore = project | ||
.in(file("core")) | ||
.settings( | ||
name := "Hello Core", | ||
libraryDependencies ++= Seq(gigahorse, playJson), | ||
libraryDependencies += scalaTest % Test, | ||
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7", | ||
libraryDependencies += toolkitTest % Test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.4") | ||
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.4") |
31 changes: 12 additions & 19 deletions
31
src/sbt-test/ref/example-weather/core/src/main/scala/example/core/Weather.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
package example.core | ||
|
||
import gigahorse._, support.okhttp.Gigahorse | ||
import scala.concurrent._, duration._ | ||
import play.api.libs.json._ | ||
import sttp.client4.quick._ | ||
import sttp.client4.Response | ||
|
||
object Weather { | ||
lazy val http = Gigahorse.http(Gigahorse.config) | ||
|
||
def weather: Future[String] = { | ||
val baseUrl = "https://www.metaweather.com/api/location" | ||
val locUrl = baseUrl + "/search/" | ||
val weatherUrl = baseUrl + "/%s/" | ||
val rLoc = Gigahorse.url(locUrl).get. | ||
addQueryString("query" -> "New York") | ||
import ExecutionContext.Implicits.global | ||
for { | ||
loc <- http.run(rLoc, parse) | ||
woeid = (loc \ 0 \ "woeid").get | ||
rWeather = Gigahorse.url(weatherUrl format woeid).get | ||
weather <- http.run(rWeather, parse) | ||
} yield (weather \\ "weather_state_name")(0).as[String].toLowerCase | ||
def weather() = { | ||
val response: Response[String] = quickRequest | ||
.get( | ||
uri"https://api.open-meteo.com/v1/forecast?latitude=$newYorkLatitude&longitude=$newYorkLongitude¤t_weather=true" | ||
) | ||
.send() | ||
val json = ujson.read(response.body) | ||
json.obj("current_weather")("temperature").num | ||
} | ||
|
||
private def parse = Gigahorse.asString andThen Json.parse | ||
private val newYorkLatitude: Double = 40.7143 | ||
private val newYorkLongitude: Double = -74.006 | ||
} |
8 changes: 3 additions & 5 deletions
8
src/sbt-test/ref/example-weather/src/main/scala/example/Hello.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package example | ||
|
||
import scala.concurrent._, duration._ | ||
import core.Weather | ||
import example.core.Weather | ||
|
||
object Hello { | ||
def main(args: Array[String]): Unit = { | ||
val w = Await.result(Weather.weather, 10.seconds) | ||
println(s"Hello! The weather in New York is $w.") | ||
Weather.http.close() | ||
val temp = Weather.weather() | ||
println(s"Hello! The current temperature in New York is $temp C.") | ||
} | ||
} |
File renamed without changes.