address review

This commit is contained in:
Eugene Yokota 2019-07-12 10:52:02 -04:00
parent c31e0b6b55
commit 9755234a16
2 changed files with 8 additions and 6 deletions

View File

@ -376,7 +376,7 @@ object Keys {
val packagedArtifacts = taskKey[Map[Artifact, File]]("Packages all artifacts for publishing and maps the Artifact definition to the generated file.").withRank(CTask)
val publishMavenStyle = settingKey[Boolean]("Configures whether to generate and publish a pom (true) or Ivy file (false).").withRank(BSetting)
val credentials = taskKey[Seq[Credentials]]("The credentials to use for updating and publishing.").withRank(BMinusTask)
val allCredentials = taskKey[Seq[Credentials]]("Aggregated credentials.").withRank(DTask)
val allCredentials = taskKey[Seq[Credentials]]("Aggregated credentials across current and root subprojects. Do not rewire this task.").withRank(DTask)
val makePom = taskKey[File]("Generates a pom for publishing when publishing Maven-style.").withRank(BPlusTask)
val deliver = taskKey[File]("Generates the Ivy file for publishing to a repository.").withRank(BTask)

View File

@ -9,7 +9,7 @@ package sbt
package coursierint
import java.io.File
import scala.collection.mutable
import java.util.concurrent.ConcurrentHashMap
import lmcoursier.definitions.{
Classifier,
Configuration => CConfiguration,
@ -26,8 +26,8 @@ import sbt.io.syntax._
import xsbti.AppConfiguration
object LMCoursier {
private[sbt] val credentialRegistry: mutable.Map[(String, String), IvyCredentials] =
mutable.Map.empty
private[this] val credentialRegistry: ConcurrentHashMap[(String, String), IvyCredentials] =
new ConcurrentHashMap
def defaultCacheLocation: File =
sys.props.get("sbt.coursier.home") match {
@ -196,14 +196,16 @@ object LMCoursier {
private[sbt] def registerCredentials(creds: IvyCredentials): Unit = {
val d = IvyCredentials.toDirect(creds)
credentialRegistry((d.host, d.realm)) = d
credentialRegistry.put((d.host, d.realm), d)
()
}
// This emulates Ivy's credential registration which basically keeps mutating global registry
def allCredentialsTask: Def.Initialize[Task[Seq[IvyCredentials]]] = Def.task {
import scala.collection.JavaConverters._
(Keys.credentials in ThisBuild).value foreach registerCredentials
(Keys.credentials in LocalRootProject).value foreach registerCredentials
Keys.credentials.value foreach registerCredentials
credentialRegistry.values.toVector
credentialRegistry.values.asScala.toVector
}
}