Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ ThisBuild / versionScheme := Some("early-semver")

lazy val scala213 = "2.13.18"
lazy val scala212 = "2.12.21"
lazy val scala3 = "3.8.4"

ThisBuild / scalaVersion := scala213

ThisBuild / allowMismatchScala := true

lazy val commonSettings = List(
publishTo := {
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
Expand All @@ -34,7 +37,6 @@ lazy val commonSettings = List(
)

lazy val root = (project in file("."))
.dependsOn(core, coursier, plugin)
.aggregate(core, coursier, plugin)
.settings(
name := "gar-handler",
Expand All @@ -55,7 +57,7 @@ lazy val core = project
.settings(
moduleName := "gar-handler",
scalaVersion := scala212,
crossScalaVersions := Seq(scala212, scala213),
crossScalaVersions := Seq(scala212, scala213, scala3),
Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "dev" / "rolang" / "gar" / "version.scala"
val contents = version.value
Expand Down Expand Up @@ -94,7 +96,13 @@ lazy val plugin = project
.settings(
moduleName := "sbt-gar-handler",
scalaVersion := scala212,
crossScalaVersions := Seq(scala212),
crossScalaVersions := Seq(scala212, scala3),
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
case "2.12" => "1.12.11"
case _ => "2.0.0"
}
},
sbtPluginPublishLegacyMavenStyle := false,
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Expand Down
39 changes: 39 additions & 0 deletions modules/sbt/src/main/scala-2.12/dev/rolang/sbt/gar/GarCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dev.rolang.sbt.gar

import sbt._
import sbt.Keys._
import scala.util.{Failure, Success, Try}

object GarCompat {
def projectSettings: Seq[Def.Setting[_]] =
Seq(
onLoad in Global := (onLoad in Global).value.andThen { state =>
val sbtLogger = state.log
val logger = new dev.rolang.gar.Logger {
override def info(msg: String): Unit = sbtLogger.info(msg)
override def error(msg: String): Unit = sbtLogger.err(msg)
override def debug(msg: String): Unit = sbtLogger.debug(msg)
}

Try {
dev.rolang.gar.ArtifactRegistryUrlHandlerFactory.install(logger)
} match {
case Success(_) => state
case Failure(err) => {
sbtLogger.err(
s"Failed to install artifactregistry handler: ${err}. Publishing/resolving artifacts from Google Artifact Registry is disabled."
)
state
}
}
},
csrConfiguration := csrConfiguration.value.withProtocolHandlerDependencies(
Seq("dev.rolang" % "gar-coursier_2.13" % dev.rolang.gar.version.value)
),
publishTo := publishTo.value.map {
case m: sbt.librarymanagement.MavenRepository if m.root.startsWith("artifactregistry://") =>
ArtifactRegistryIvyResolver.create(m.name, m.root)
case other => other
}
)
}
35 changes: 35 additions & 0 deletions modules/sbt/src/main/scala-3/dev/rolang/sbt/gar/GarCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.rolang.sbt.gar

import sbt.*
import sbt.Keys.*
import scala.util.{Failure, Success, Try}

object GarCompat:
def projectSettings: Seq[Def.Setting[?]] =
Seq(
Global / onLoad := (Global / onLoad).value.andThen { state =>
val sbtLogger = state.log
val logger = new dev.rolang.gar.Logger {
override def info(msg: String): Unit = sbtLogger.info(msg)
override def error(msg: String): Unit = sbtLogger.err(msg)
override def debug(msg: String): Unit = sbtLogger.debug(msg)
}

Try {
dev.rolang.gar.ArtifactRegistryUrlHandlerFactory.install(logger)
} match {
case Success(_) => state
case Failure(err) => {
sbtLogger.err(
s"Failed to install artifactregistry handler: ${err}. Publishing/resolving artifacts from Google Artifact Registry is disabled."
)
state
}
}
},
publishTo := publishTo.value.map {
case m: sbt.librarymanagement.MavenRepository if m.root.startsWith("artifactregistry://") =>
m
case other => other
}
)
33 changes: 1 addition & 32 deletions modules/sbt/src/main/scala/dev/rolang/sbt/gar/GarPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.rolang.sbt.gar

import sbt._
import sbt.Keys._
import scala.util.{Failure, Success, Try}

object GarPlugin extends AutoPlugin {
override def trigger = allRequirements
Expand All @@ -11,35 +10,5 @@ object GarPlugin extends AutoPlugin {

import autoImport._

override def projectSettings: Seq[Def.Setting[_]] =
Seq(
onLoad in Global := (onLoad in Global).value.andThen { state =>
val sbtLogger = state.log
val logger = new dev.rolang.gar.Logger {
override def info(msg: String): Unit = sbtLogger.info(msg)
override def error(msg: String): Unit = sbtLogger.err(msg)
override def debug(msg: String): Unit = sbtLogger.debug(msg)
}

Try {
dev.rolang.gar.ArtifactRegistryUrlHandlerFactory.install(logger)
} match {
case Success(_) => state
case Failure(err) => {
sbtLogger.err(
s"Failed to install artigactregistry handler: ${err}. Publishing/resolving artifacts from Google Artifact Registry is disabled."
)
state
}
}
},
csrConfiguration := csrConfiguration.value.withProtocolHandlerDependencies(
Seq("dev.rolang" % "gar-coursier_2.13" % dev.rolang.gar.version.value)
),
publishTo := publishTo.value.map {
case m: sbt.librarymanagement.MavenRepository if m.root.startsWith("artifactregistry://") =>
ArtifactRegistryIvyResolver.create(m.name, m.root)
case other => other
}
) ++ super.projectSettings
override def projectSettings = GarCompat.projectSettings
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.12.11
sbt.version=2.0.1
Loading