Skip to content

Commit

Permalink
Update scalafmt-core to 3.7.14 (#250)
Browse files Browse the repository at this point in the history
* Update scalafmt-core to 3.7.14

* Reformat with scalafmt 3.7.14

Executed command: scalafmt --non-interactive

* Add 'Reformat with scalafmt 3.7.14' to .git-blame-ignore-revs
  • Loading branch information
scala-steward authored Oct 18, 2023
1 parent acb4046 commit 457f7e2
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 193 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.7.14
5322317e378d136bf4d876be5d68dd5c9a637fa2
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.5.9"
version = "3.7.14"
runner.dialect = scala212
maxColumn = 120
project.git = true
Expand Down
158 changes: 73 additions & 85 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,105 +1,93 @@
import CustomGithubActions.{aggregateCC, generateCC, uploadCC}
import sbt.*
import sbt.Keys.*
import sbt.Defaults.*
import xerial.sbt.Sonatype.*
import ReleaseTransformations.*
import CustomGithubActions.*
import CustomGithubActions.aggregateCC
import CustomGithubActions.generateCC
import CustomGithubActions.uploadCC
import Dependencies.*
import ReleaseTransformations.*
import ScalaVer.*
import CustomGithubActions.*

import java.net.URL

import sbt.*
import sbt.Defaults.*
import sbt.Keys.*
import xerial.sbt.Sonatype.*

// https://github.com/xerial/sbt-sonatype/issues/71
ThisBuild / publishTo := sonatypePublishTo.value
ThisBuild / publishTo := sonatypePublishTo.value
ThisBuild / githubWorkflowTargetPaths := Paths.Ignore(List("**.md"))
ThisBuild / githubWorkflowScalaVersions := ScalaVer.values.map(_.full)
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11"))
ThisBuild / githubWorkflowBuildPostamble := Seq(generateCC, aggregateCC, uploadCC)

lazy val commons = ScalaVer.settings ++ Seq(

organization := "com.github.andyglow",

homepage := Some(new URL("http://github.com/andyglow/websocket-scala-client")),

startYear := Some(2019),

organizationName := "andyglow",

scalacOptions := CompilerOptions(scalaV.value),

Compile / doc / scalacOptions ++= Seq(
"-groups",
"-implicits",
"-no-link-warnings"),

licenses := Seq(("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))),

sonatypeProfileName := "com.github.andyglow",

publishMavenStyle := true,

sonatypeProjectHosting := Some(
GitHubHosting(
"andyglow",
"websocket-scala-client",
"[email protected]")),

scmInfo := Some(
ScmInfo(
url("https://github.com/andyglow/websocket-scala-client"),
"scm:[email protected]:andyglow/websocket-scala-client.git")),

developers := List(
Developer(
id = "andyglow",
name = "Andriy Onyshchuk",
email = "[email protected]",
url = url("https://ua.linkedin.com/in/andyglow"))),

releaseCrossBuild := true,

releasePublishArtifactsAction := PgpKeys.publishSigned.value,

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(action = Command.process("publishSigned", _), enableCrossBuild = true),
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _), enableCrossBuild = true),
pushChanges),

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.17" % Test,
"org.mockito" % "mockito-core" % "5.6.0" % Test
organization := "com.github.andyglow",
homepage := Some(new URL("http://github.com/andyglow/websocket-scala-client")),
startYear := Some(2019),
organizationName := "andyglow",
scalacOptions := CompilerOptions(scalaV.value),
Compile / doc / scalacOptions ++= Seq("-groups", "-implicits", "-no-link-warnings"),
licenses := Seq(("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))),
sonatypeProfileName := "com.github.andyglow",
publishMavenStyle := true,
sonatypeProjectHosting := Some(GitHubHosting("andyglow", "websocket-scala-client", "[email protected]")),
scmInfo := Some(
ScmInfo(
url("https://github.com/andyglow/websocket-scala-client"),
"scm:[email protected]:andyglow/websocket-scala-client.git"
)
),
developers := List(
Developer(
id = "andyglow",
name = "Andriy Onyshchuk",
email = "[email protected]",
url = url("https://ua.linkedin.com/in/andyglow")
)
),
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(action = Command.process("publishSigned", _), enableCrossBuild = true),
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _), enableCrossBuild = true),
pushChanges
),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.17" % Test,
"org.mockito" % "mockito-core" % "5.6.0" % Test
)
)

resolvers ++= Seq("snapshots", "releases").flatMap(Resolver.sonatypeOssRepos)

lazy val root = (project in file("."))
.configs(Examples)
.settings(inConfig(Examples)(compileBase ++ compileSettings ++ Seq(
run := Defaults.runTask(Examples / fullClasspath , run / mainClass, run / runner).evaluated,
runMain := Defaults.runMainTask(Examples / fullClasspath, run / runner).evaluated)))
.settings(
commons,
name := "websocket-scala-client",
libraryDependencies ++= Seq(
nettyAll,
nettyHttp,
scalaStm,
slf4jApi,
slf4jSimple,
akkaHttp(scalaVersion.value).cross(CrossVersion.binary),
akkaStream(scalaVersion.value).cross(CrossVersion.binary)))

inConfig(Examples)(
compileBase ++ compileSettings ++ Seq(
run := Defaults.runTask(Examples / fullClasspath, run / mainClass, run / runner).evaluated,
runMain := Defaults.runMainTask(Examples / fullClasspath, run / runner).evaluated
)
)
)
.settings(
commons,
name := "websocket-scala-client",
libraryDependencies ++= Seq(
nettyAll,
nettyHttp,
scalaStm,
slf4jApi,
slf4jSimple,
akkaHttp(scalaVersion.value).cross(CrossVersion.binary),
akkaStream(scalaVersion.value).cross(CrossVersion.binary)
)
)
9 changes: 2 additions & 7 deletions project/CompilerOptions.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
object CompilerOptions {

private val base = Seq(
"-encoding", "UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-language:higherKinds")
private val base = Seq("-encoding", "UTF-8", "-feature", "-unchecked", "-deprecation", "-language:higherKinds")

private val opts211 = base ++ Seq(
"-Xfuture",
Expand Down Expand Up @@ -36,4 +31,4 @@ object CompilerOptions {
case ScalaVer._300 => opts300
}
}
}
}
3 changes: 2 additions & 1 deletion project/CustomGithubActions.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sbtghactions.GenerativePlugin.autoImport.{UseRef, WorkflowStep}
import sbtghactions.GenerativePlugin.autoImport.UseRef
import sbtghactions.GenerativePlugin.autoImport.WorkflowStep

object CustomGithubActions {

Expand Down
10 changes: 5 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ object Dependencies {
val slf4jVersion = "2.0.9"
val nettyVersion = "4.1.100.Final"

val nettyAll = "io.netty" % "netty-all" % nettyVersion % Compile
val nettyHttp = "io.netty" % "netty-codec-http" % nettyVersion % Compile
val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion % Compile
val slf4jSimple = "org.slf4j" % "slf4j-simple" % slf4jVersion % Examples
val scalaStm = "org.scala-stm" %% "scala-stm" % "0.11.1" % Compile
val nettyAll = "io.netty" % "netty-all" % nettyVersion % Compile
val nettyHttp = "io.netty" % "netty-codec-http" % nettyVersion % Compile
val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion % Compile
val slf4jSimple = "org.slf4j" % "slf4j-simple" % slf4jVersion % Examples
val scalaStm = "org.scala-stm" %% "scala-stm" % "0.11.1" % Compile

object akkaHttp {

Expand Down
13 changes: 8 additions & 5 deletions project/ScalaVer.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sbt.Keys.{crossScalaVersions, scalaVersion}
import sbt.Def
import sbt.Keys.crossScalaVersions
import sbt.Keys.scalaVersion
import sbt.librarymanagement.CrossVersion
import sbt.{Def, settingKey}
import sbt.settingKey

sealed abstract class ScalaVer(val full: String)

Expand Down Expand Up @@ -31,7 +33,8 @@ object ScalaVer {
lazy val scalaV = settingKey[ScalaVer]("Current Scala Version")

def settings: Seq[Def.Setting[? >: String & Seq[String] & ScalaVer <: Object]] = Seq(
scalaVersion := (ScalaVer.fromEnv getOrElse ScalaVer.default).full,
crossScalaVersions := ScalaVer.values.map(_.full),
scalaV := ScalaVer.fromString(scalaVersion.value) getOrElse ScalaVer.default)
scalaVersion := (ScalaVer.fromEnv getOrElse ScalaVer.default).full,
crossScalaVersions := ScalaVer.values.map(_.full),
scalaV := ScalaVer.fromString(scalaVersion.value) getOrElse ScalaVer.default
)
}
8 changes: 5 additions & 3 deletions src/example/scala/BinaryEchoWebSocketOrg.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import java.nio.charset.Charset
import com.github.andyglow.websocket.{WebsocketHandler, WebsocketClient}
import io.netty.buffer.{Unpooled, ByteBuf}
import com.github.andyglow.websocket._
import com.github.andyglow.websocket.WebsocketClient
import com.github.andyglow.websocket.WebsocketHandler
import io.netty.buffer.ByteBuf
import io.netty.buffer.Unpooled
import java.nio.charset.Charset

object BinaryEchoWebSocketOrg extends WaitForStop[ByteBuf] {

Expand Down
8 changes: 4 additions & 4 deletions src/example/scala/SimplifiedTextEchoWebSocketOrg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ object SimplifiedTextEchoWebSocketOrg extends WaitForStop[String] {

val client = {
val builder = WebsocketClient.Builder[String](stringUri) {
case "stop" => logger.info(s"<<! stop"); done()
case str => logger.info(s"<<| $str")
} onFailure {
case ex: Throwable => logger.error(s"Error occurred.", ex)
case "stop" => logger.info(s"<<! stop"); done()
case str => logger.info(s"<<| $str")
} onFailure { case ex: Throwable =>
logger.error(s"Error occurred.", ex)
} onClose {
logger.info(s"<<! connection closed"); done()
}
Expand Down
15 changes: 8 additions & 7 deletions src/example/scala/WaitForStop.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import com.github.andyglow.websocket.Websocket
import com.github.andyglow.websocket.WebsocketClient
import com.github.andyglow.websocket.util.ServerAddressBuilder
import com.github.andyglow.websocket.{Websocket, WebsocketClient}
import org.slf4j.LoggerFactory

import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
import scala.concurrent.duration._
import scala.util.Failure
import scala.util.Success

trait WaitForStop[T] {

val host = "localhost:8080"
val host = "localhost:8080"
val binaryUri = ServerAddressBuilder(s"ws://$host/?encoding=binary")
val stringUri = ServerAddressBuilder(s"ws://$host")

Expand All @@ -23,8 +24,8 @@ trait WaitForStop[T] {
def run(): Unit

def done(): Unit = {
socket.close andThen {
case _ => roundtrip.success(())
socket.close andThen { case _ =>
roundtrip.success(())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package com.github.andyglow.websocket.testserver

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.ws.UpgradeToWebSocket
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.Materializer

import java.util.concurrent.Callable
import scala.concurrent.Future

trait PlatformDependent {

@inline def launchServer(
interface: String,
port: Int,
handler: HttpRequest => HttpResponse)(implicit system: ActorSystem, mat: Materializer): Future[Http.ServerBinding] = {
@inline def launchServer(interface: String, port: Int, handler: HttpRequest => HttpResponse)(implicit
system: ActorSystem,
mat: Materializer
): Future[Http.ServerBinding] = {

Http().bindAndHandleSync(handler, interface, port)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ package com.github.andyglow.websocket.testserver

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.AttributeKeys
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.ws.WebSocketUpgrade
import akka.http.scaladsl.model.{AttributeKeys, HttpRequest, HttpResponse}
import akka.stream.Materializer

import java.util.concurrent.Callable
import scala.concurrent.Future

trait PlatformDependent {

@inline def launchServer(
interface: String,
port: Int,
handler: HttpRequest => HttpResponse)(implicit system: ActorSystem, mat: Materializer): Future[Http.ServerBinding] = {
@inline def launchServer(interface: String, port: Int, handler: HttpRequest => HttpResponse)(implicit
system: ActorSystem,
mat: Materializer
): Future[Http.ServerBinding] = {

Http().newServerAt(interface, port).bindSync(handler)
}

@inline def websocketAttribution(x: HttpRequest): Option[WebSocketUpgrade] = x.attribute(AttributeKeys.webSocketUpgrade)
@inline def websocketAttribution(x: HttpRequest): Option[WebSocketUpgrade] =
x.attribute(AttributeKeys.webSocketUpgrade)
}

object PlatformDependent {

@inline def callable[T](fn: () => T): Callable[T] = () => fn()
}
}
Loading

0 comments on commit 457f7e2

Please sign in to comment.