diff --git a/build.sbt b/build.sbt index c5fed5ee9c..e1248f4277 100644 --- a/build.sbt +++ b/build.sbt @@ -209,7 +209,8 @@ lazy val googleCommon = alpakkaProject( "google.common", Dependencies.GoogleCommon, Test / fork := true, - headerSources / excludeFilter := HiddenFileFilter || "JwtSprayJsonParser.scala" + headerSources / excludeFilter := HiddenFileFilter || "JwtSprayJsonParser.scala", + Scala3.settings ) lazy val googleCloudBigQuery = alpakkaProject( @@ -246,7 +247,8 @@ lazy val googleCloudPubSub = alpakkaProject( Dependencies.GooglePubSub, Test / fork := true, // See docker-compose.yml gcloud-pubsub-emulator_prep - Test / envVars := Map("PUBSUB_EMULATOR_HOST" -> "localhost", "PUBSUB_EMULATOR_PORT" -> "8538") + Test / envVars := Map("PUBSUB_EMULATOR_HOST" -> "localhost", "PUBSUB_EMULATOR_PORT" -> "8538"), + Scala3.settings ).dependsOn(googleCommon) lazy val googleCloudPubSubGrpc = alpakkaProject( @@ -262,14 +264,16 @@ lazy val googleCloudPubSubGrpc = alpakkaProject( "-Wconf:src=.+/akka-grpc/main/.+:s", "-Wconf:src=.+/akka-grpc/test/.+:s" ), - compile / javacOptions := (compile / javacOptions).value.filterNot(_ == "-Xlint:deprecation") + compile / javacOptions := (compile / javacOptions).value.filterNot(_ == "-Xlint:deprecation"), + Scala3.settings ).enablePlugins(AkkaGrpcPlugin).dependsOn(googleCommon) lazy val googleCloudStorage = alpakkaProject( "google-cloud-storage", "google.cloud.storage", Test / fork := true, - Dependencies.GoogleStorage + Dependencies.GoogleStorage, + Scala3.settings ).dependsOn(googleCommon) lazy val googleFcm = alpakkaProject("google-fcm", "google.firebase.fcm", Dependencies.GoogleFcm, Test / fork := true) diff --git a/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/impl/PubSubApi.scala b/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/impl/PubSubApi.scala index 87586fe341..10068d7e75 100644 --- a/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/impl/PubSubApi.scala +++ b/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/impl/PubSubApi.scala @@ -169,7 +169,7 @@ private[pubsub] trait PubSubApi { .mapMaterializedValue(_ => NotUsed) private implicit val pullResponseUnmarshaller: FromResponseUnmarshaller[PullResponse] = - Unmarshaller.withMaterializer { implicit ec => implicit mat => response: HttpResponse => + Unmarshaller.withMaterializer { implicit ec => implicit mat => (response: HttpResponse) => response.status match { case StatusCodes.Success(_) if response.entity.contentType == ContentTypes.`application/json` => Unmarshal(response.entity).to[PullResponse] @@ -208,7 +208,7 @@ private[pubsub] trait PubSubApi { .mapMaterializedValue(_ => NotUsed) private implicit val acknowledgeResponseUnmarshaller: FromResponseUnmarshaller[Done] = - Unmarshaller.withMaterializer { implicit ec => implicit mat => response: HttpResponse => + Unmarshaller.withMaterializer { implicit ec => implicit mat => (response: HttpResponse) => response.status match { case StatusCodes.Success(_) => response.discardEntityBytes().future @@ -261,7 +261,7 @@ private[pubsub] trait PubSubApi { publish(topic, parallelism, None) private implicit val publishResponseUnmarshaller: FromResponseUnmarshaller[PublishResponse] = - Unmarshaller.withMaterializer { implicit ec => implicit mat => response: HttpResponse => + Unmarshaller.withMaterializer { implicit ec => implicit mat => (response: HttpResponse) => response.status match { case StatusCodes.Success(_) if response.entity.contentType == ContentTypes.`application/json` => Unmarshal(response.entity).to[PublishResponse] diff --git a/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/model.scala b/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/model.scala index 044c9dc7c7..b342a2979f 100644 --- a/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/model.scala +++ b/google-cloud-pub-sub/src/main/scala/akka/stream/alpakka/googlecloud/pubsub/model.scala @@ -60,7 +60,7 @@ object PubSubConfig { pullReturnImmediately = true, pullMaxMessagesPerInternalBatch = 1000, Some( - GoogleSettings().copy( + GoogleSettings.apply().copy( projectId = projectId, credentials = ServiceAccountCredentials(projectId, clientEmail, privateKey, Seq("https://www.googleapis.com/auth/pubsub")) @@ -85,7 +85,7 @@ object PubSubConfig { pullReturnImmediately = pullReturnImmediately, pullMaxMessagesPerInternalBatch = pullMaxMessagesPerInternalBatch, Some( - GoogleSettings().copy( + GoogleSettings.apply().copy( projectId = projectId, credentials = ServiceAccountCredentials(projectId, clientEmail, privateKey, Seq("https://www.googleapis.com/auth/pubsub")) diff --git a/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/Formats.scala b/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/Formats.scala index a441d6b533..da000fcc2c 100644 --- a/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/Formats.scala +++ b/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/Formats.scala @@ -11,20 +11,21 @@ import akka.stream.alpakka.googlecloud.storage._ import spray.json.{DefaultJsonProtocol, JsObject, JsValue, RootJsonFormat, RootJsonReader} import scala.util.Try +import spray.json.enrichAny @akka.annotation.InternalApi object Formats extends DefaultJsonProtocol { private final case class CustomerEncryption(encryptionAlgorithm: String, keySha256: String) private implicit val customerEncryptionJsonFormat: RootJsonFormat[CustomerEncryption] = jsonFormat2( - CustomerEncryption + CustomerEncryption.apply ) private final case class Owner(entity: String, entityId: Option[String]) - private implicit val OwnerJsonFormat: RootJsonFormat[Owner] = jsonFormat2(Owner) + private implicit val OwnerJsonFormat: RootJsonFormat[Owner] = jsonFormat2(Owner.apply) private final case class ProjectTeam(projectNumber: String, team: String) - private implicit val ProjectTeamJsonFormat: RootJsonFormat[ProjectTeam] = jsonFormat2(ProjectTeam) + private implicit val ProjectTeamJsonFormat: RootJsonFormat[ProjectTeam] = jsonFormat2(ProjectTeam.apply) private final case class ObjectAccessControls(kind: String, id: String, @@ -40,7 +41,7 @@ object Formats extends DefaultJsonProtocol { projectTeam: ProjectTeam, etag: String) private implicit val ObjectAccessControlsJsonFormat: RootJsonFormat[ObjectAccessControls] = jsonFormat13( - ObjectAccessControls + ObjectAccessControls.apply ) /** @@ -73,7 +74,7 @@ object Formats extends DefaultJsonProtocol { ) private implicit val storageObjectReadOnlyJson: RootJsonFormat[StorageObjectReadOnlyJson] = jsonFormat18( - StorageObjectReadOnlyJson + StorageObjectReadOnlyJson.apply ) // private sub class of StorageObjectJson used to workaround 22 field jsonFormat issue @@ -95,7 +96,7 @@ object Formats extends DefaultJsonProtocol { ) private implicit val storageObjectWritableJson: RootJsonFormat[StorageObjectWriteableJson] = jsonFormat14( - StorageObjectWriteableJson + StorageObjectWriteableJson.apply ) private implicit object StorageObjectJsonFormat extends RootJsonFormat[StorageObjectJson] { @@ -130,7 +131,7 @@ object Formats extends DefaultJsonProtocol { items: Option[List[StorageObjectJson]] ) - private implicit val bucketInfoJsonFormat: RootJsonFormat[BucketInfoJson] = jsonFormat6(BucketInfoJson) + private implicit val bucketInfoJsonFormat: RootJsonFormat[BucketInfoJson] = jsonFormat6(BucketInfoJson.apply) /** * Google API rewrite response object @@ -146,7 +147,7 @@ object Formats extends DefaultJsonProtocol { resource: Option[StorageObjectJson] ) - private implicit val rewriteResponseFormat: RootJsonFormat[RewriteResponseJson] = jsonFormat6(RewriteResponseJson) + private implicit val rewriteResponseFormat: RootJsonFormat[RewriteResponseJson] = jsonFormat6(RewriteResponseJson.apply) /** * Google API bucket response object @@ -162,7 +163,7 @@ object Formats extends DefaultJsonProtocol { etag: String ) - implicit val bucketInfoFormat: RootJsonFormat[BucketInfo] = jsonFormat2(BucketInfo) + implicit val bucketInfoFormat: RootJsonFormat[BucketInfo] = jsonFormat2(BucketInfo.apply) implicit object BucketListResultReads extends RootJsonReader[BucketListResult] { override def read(json: JsValue): BucketListResult = { @@ -177,7 +178,7 @@ object Formats extends DefaultJsonProtocol { } private implicit val bucketListResultJsonReads: RootJsonFormat[BucketListResultJson] = jsonFormat4( - BucketListResultJson + BucketListResultJson.apply ) implicit object RewriteResponseReads extends RootJsonReader[RewriteResponse] { diff --git a/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala b/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala index 9c96c9c494..c05ce2117f 100644 --- a/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala +++ b/google-cloud-storage/src/main/scala/akka/stream/alpakka/googlecloud/storage/impl/GCStorageStream.scala @@ -131,7 +131,7 @@ import scala.concurrent.Future metadata: Option[Map[String, String]] = None): Sink[ByteString, Future[StorageObject]] = Sink .fromMaterializer { (mat, attr) => - implicit val settings = { + implicit val settings: GoogleSettings = { val s = resolveSettings(mat, attr) s.copy(requestSettings = s.requestSettings.copy(uploadChunkSize = chunkSize)) } @@ -158,7 +158,7 @@ import scala.concurrent.Future }: PartialFunction[HttpResponse, Future[StorageObject]] }.withDefaultRetry - ResumableUpload[StorageObject](request).addAttributes(GoogleAttributes.settings(settings)) + ResumableUpload[StorageObject](request)(um).addAttributes(GoogleAttributes.settings(settings)) } .mapMaterializedValue(_.flatten) @@ -236,7 +236,7 @@ import scala.concurrent.Future getBucketPath(bucket) / "o" / objectName implicit def unmarshaller[T: FromEntityUnmarshaller]: Unmarshaller[HttpResponse, T] = - Unmarshaller.withMaterializer { implicit ec => implicit mat => response: HttpResponse => + Unmarshaller.withMaterializer { implicit ec => implicit mat => (response: HttpResponse) => response match { case HttpResponse(status, _, entity, _) if status.isSuccess() && !status.isRedirection() => Unmarshal(entity).to[T] @@ -248,7 +248,7 @@ import scala.concurrent.Future }.withDefaultRetry implicit def optionUnmarshaller[T: FromEntityUnmarshaller]: Unmarshaller[HttpResponse, Option[T]] = - Unmarshaller.withMaterializer { implicit ec => implicit mat => response: HttpResponse => + Unmarshaller.withMaterializer { implicit ec => implicit mat => (response: HttpResponse) => response match { case HttpResponse(status, _, entity, _) if status.isSuccess() && !status.isRedirection() => Unmarshal(entity).to[T].map(Some(_)) @@ -324,7 +324,7 @@ import scala.concurrent.Future ) } - GoogleSettings( + GoogleSettings.apply( legacySettings.projectId, credentials, settings.requestSettings diff --git a/google-common/src/main/scala/akka/stream/alpakka/google/GoogleSettings.scala b/google-common/src/main/scala/akka/stream/alpakka/google/GoogleSettings.scala index c10a0617db..ab32b9bd19 100644 --- a/google-common/src/main/scala/akka/stream/alpakka/google/GoogleSettings.scala +++ b/google-common/src/main/scala/akka/stream/alpakka/google/GoogleSettings.scala @@ -80,7 +80,7 @@ object GoogleSettings { } -final case class GoogleSettings @InternalApi private (projectId: String, +final case class GoogleSettings @InternalApi private[akka] (projectId: String, credentials: Credentials, requestSettings: RequestSettings) { def getProjectId = projectId @@ -125,7 +125,7 @@ object RequestSettings { apply(userIp.toScala, quotaUser.toScala, prettyPrint, chunkSize, retrySettings, forwardProxy.toScala) } -final case class RequestSettings @InternalApi private ( +final case class RequestSettings @InternalApi private[akka] ( userIp: Option[String], quotaUser: Option[String], prettyPrint: Boolean, @@ -247,7 +247,7 @@ object ForwardProxy { credentials: Option[BasicHttpCredentials], trustPem: Option[String])(implicit system: ClassicActorSystemProvider): ForwardProxy = { ForwardProxy( - trustPem.fold(Http(system).defaultClientHttpsContext)(ForwardProxyHttpsContext(_)), + trustPem.fold(Http(system.classicSystem).defaultClientHttpsContext)(ForwardProxyHttpsContext(_)), ForwardProxyPoolSettings(scheme, host, port, credentials)(system.classicSystem) ) } diff --git a/google-common/src/main/scala/akka/stream/alpakka/google/ResumableUpload.scala b/google-common/src/main/scala/akka/stream/alpakka/google/ResumableUpload.scala index 3fe9bf2f8c..423bd74fc9 100644 --- a/google-common/src/main/scala/akka/stream/alpakka/google/ResumableUpload.scala +++ b/google-common/src/main/scala/akka/stream/alpakka/google/ResumableUpload.scala @@ -91,7 +91,7 @@ private[alpakka] object ResumableUpload { import implicits._ implicit val um: FromResponseUnmarshaller[Uri] = Unmarshaller.withMaterializer { - implicit ec => implicit mat => response: HttpResponse => + implicit ec => implicit mat => (response: HttpResponse) => response.discardEntityBytes().future.map { _ => response.header[Location].fold(throw InvalidResponseException(ErrorInfo("No Location header")))(_.uri) } @@ -107,7 +107,7 @@ private[alpakka] object ResumableUpload { )(implicit mat: Materializer): Flow[Either[T, MaybeLast[Chunk]], Try[Option[T]], NotUsed] = { implicit val system: ActorSystem = mat.system - val um = Unmarshaller.withMaterializer { implicit ec => implicit mat => response: HttpResponse => + val um = Unmarshaller.withMaterializer { implicit ec => implicit mat => (response: HttpResponse) => response.status match { case PermanentRedirect => response.discardEntityBytes().future.map(_ => None) @@ -145,7 +145,7 @@ private[alpakka] object ResumableUpload { import implicits._ implicit val um: FromResponseUnmarshaller[Either[T, Long]] = Unmarshaller.withMaterializer { - implicit ec => implicit mat => response: HttpResponse => + implicit ec => implicit mat => (response: HttpResponse) => response.status match { case OK | Created => Unmarshal(response).to[T].map(Left(_)) case PermanentRedirect => diff --git a/google-common/src/main/scala/akka/stream/alpakka/google/auth/Credentials.scala b/google-common/src/main/scala/akka/stream/alpakka/google/auth/Credentials.scala index f9b52b38c4..8a2e6122f8 100644 --- a/google-common/src/main/scala/akka/stream/alpakka/google/auth/Credentials.scala +++ b/google-common/src/main/scala/akka/stream/alpakka/google/auth/Credentials.scala @@ -27,7 +27,7 @@ object Credentials { */ def apply(c: Config)(implicit system: ClassicActorSystemProvider): Credentials = c.getString("provider") match { case "application-default" => - val log = Logging(system.classicSystem, getClass) + val log = Logging(system.classicSystem, classOf[Credentials]) try { val creds = parseServiceAccount(c) log.info("Using service account credentials") diff --git a/google-common/src/main/scala/akka/stream/alpakka/google/scaladsl/`X-Upload-Content-Type`.scala b/google-common/src/main/scala/akka/stream/alpakka/google/scaladsl/`X-Upload-Content-Type`.scala index f22baa684b..0fe1aeab81 100644 --- a/google-common/src/main/scala/akka/stream/alpakka/google/scaladsl/`X-Upload-Content-Type`.scala +++ b/google-common/src/main/scala/akka/stream/alpakka/google/scaladsl/`X-Upload-Content-Type`.scala @@ -25,7 +25,7 @@ object `X-Upload-Content-Type` extends ModeledCustomHeaderCompanion[`X-Upload-Co ) } -final case class `X-Upload-Content-Type` private (contentType: ContentType) +final case class `X-Upload-Content-Type` private[akka] (contentType: ContentType) extends ModeledCustomHeader[`X-Upload-Content-Type`] with XUploadContentType { override def value(): String = contentType.toString()