Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Fix binary Scala version detection for Scala 3 (#17)
Browse files Browse the repository at this point in the history
* Fix binary Scala version detection for Scala 3

Scala publishes with _3 suffix, not _3.1 and alike.
  • Loading branch information
ybasket authored Mar 5, 2022
1 parent 785b614 commit 514a1cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion core/src/main/scala/codeartifact/CodeArtifactPackage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ final case class CodeArtifactPackage(
val mvn = if (isScalaProject) {
sbt.CrossVersion
.partialVersion(scalaVersion)
.map { case (maj, min) => List(name, "_", maj, ".", min).mkString }
.map {
case (3, _) => s"${name}_3"
case (maj, min) => List(name, "_", maj, ".", min).mkString
}
.getOrElse { sys.error("Invalid scalaVersion.") }
} else {
name
Expand Down
11 changes: 7 additions & 4 deletions core/src/test/scala/codeartifact/CodeArtifactPackageSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ object CodeArtifactPackageSpec extends TestSuite {

val tests = Tests {
test("asMaven") {
test("scala") {
basePackage.asMaven ==> "name_3.2"
test("scala2") {
basePackage.copy(scalaVersion = "2.13.5").asMaven ==> "name_2.13"
}
test("scala3") {
basePackage.asMaven ==> "name_3"
}
test("java") {
basePackage.copy(isScalaProject = false).asMaven ==> "name"
}
test("sbt") {
basePackage.copy(sbtBinaryVersion = Some("1.0")).asMaven ==> "name_3.2_1.0"
basePackage.copy(sbtBinaryVersion = Some("1.0")).asMaven ==> "name_3_1.0"
}
}

test("versionPublishPath") {
basePackage.versionPublishPath ==> "org/example/name_3.2/1.2.3"
basePackage.versionPublishPath ==> "org/example/name_3/1.2.3"
}

test("mavenMetadata") {
Expand Down

0 comments on commit 514a1cd

Please sign in to comment.