sbt / sbt-projectmatrix

MIT License
124 stars 14 forks source link

Wrong artefact names #18

Closed tindzk closed 5 years ago

tindzk commented 5 years ago

I am in the process of publishing Pine to Sonatype. Unfortunately, sbt-projectmatrix uses wrong artefact names:

[info] Packaging /home/tim/dev/pine/./target/jvm-2.13/pinejvm2_13_2.13-0.1.5-javadoc.jar ...
[info] Done packaging.
[info]  published pinejvm2_13_2.13 to https://oss.sonatype.org/service/local/staging/deploy/maven2/tech/sparse/pinejvm2_13_2.13/0.1.5/pinejvm2_13_2.13-0.1.5.jar

The correct name would be pine_2.13-0.1.5.jar.

In the case of Scala Native and Scala.js, we must also include the compiler version:

tindzk commented 5 years ago

Here is a partial workaround:

def fixName: String => String = {
  case "pinejs2_11" => "pine_sjs0.6_2.11"
  case "pinejs2_12" => "pine_sjs0.6_2.12"
  case "pinejs2_13" => "pine_sjs0.6_2.13"
  case "pinenative2_11" => "pine_native0.3_2.11"
  case "pinejvm2_11" => "pine_2.11"
  case "pinejvm2_12" => "pine_2.12"
  case "pinejvm2_13" => "pine_2.13"
  case n => n
}

artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
  fixName(artifact.name) + "-" + module.revision + "." + artifact.extension
}

name in (Compile, packageBin) := {
  val old = (name in (Compile, packageBin)).value
  fixName(old.toLowerCase)
}
name in (Compile, packageSrc) := {
  val old = (name in (Compile, packageSrc)).value
  fixName(old.toLowerCase)
}
name in (Compile, packageDoc) := {
  val old = (name in (Compile, packageDoc)).value
  fixName(old.toLowerCase)
}

projectID in (Compile, packageBin) := {
  val old = (projectID in (Compile, packageBin)).value
  old.withName(fixName(old.name))
}
projectID in (Compile, packageSrc) := {
  val old = (projectID in (Compile, packageSrc)).value
  old.withName(fixName(old.name))
}
projectID in (Compile, packageDoc) := {
  val old = (projectID in (Compile, packageDoc)).value
  old.withName(fixName(old.name))
}

artifact in (Compile, packageBin) := {
  val old = (artifact in (Compile, packageBin)).value
  old.withName("pine")
}
artifact in (Compile, packageSrc) := {
  val old = (artifact in (Compile, packageSrc)).value
  old.withName("pine")
}
artifact in (Compile, packageDoc) := {
  val old = (artifact in (Compile, packageDoc)).value
  old.withName("pine")
}

The only remaining problem is that one of the artefact names in the Sonatype URL is wrong when I run publishSigned:

https://oss.sonatype.org/service/local/staging/deploy/maven2/tech/sparse/pinejs2_11_sjs0.6_2.11/0.1.5/pine_sjs0.6_2.11-0.1.5.jar

eed3si9n commented 5 years ago

@tindzk Thanks for the report!

eed3si9n commented 5 years ago

I swear at some point I had moduleName rewired. I don't know how this regressed. Sorry about this.

eed3si9n commented 5 years ago

I think it's due to the incorrect use of ThisBuild / name. Please see https://github.com/sparsetech/pine/pull/57