Port zinc-lm-integration

This commit is contained in:
Eugene Yokota 2022-01-30 13:31:10 -05:00
parent 4ff27d7ab7
commit 1459b8a79d
3 changed files with 10 additions and 7 deletions

View File

@ -184,7 +184,6 @@ lazy val sbtRoot: Project = (project in file("."))
(allProjects diff Seq(
actionsProj,
mainSettingsProj,
zincLmIntegrationProj,
scriptedSbtReduxProj,
scriptedSbtOldProj,
scriptedPluginProj,

View File

@ -12,7 +12,7 @@ sealed trait IfMissing
object IfMissing {
def fail: IfMissing = Fail
/** f is expected to call ZincComponentManager.define. */
/** f is expected to call ZincComponentManager.define. */
def define(useSecondaryCache: Boolean, f: => Unit): IfMissing = new Define(useSecondaryCache, f)
object Fail extends IfMissing
final class Define(val useSecondaryCache: Boolean, define: => Unit) extends IfMissing {

View File

@ -66,12 +66,14 @@ class ZincComponentManager(
lockLocalCache(getOrElse(fromSecondary))
}
/** Get the file for component 'id',
* throwing an exception if no files or multiple files exist for the component. */
/**
* Get the file for component 'id',
* throwing an exception if no files or multiple files exist for the component.
*/
def file(id: String)(ifMissing: IfMissing): File = {
files(id)(ifMissing).toList match {
case x :: Nil => x
case xs => invalid(s"Expected single file for component '$id', found: ${xs.mkString(", ")}")
case xs => invalid(s"Expected single file for component '$id', found: ${xs.mkString(", ")}")
}
}
@ -79,8 +81,10 @@ class ZincComponentManager(
def define(id: String, files: Iterable[File]): Unit =
lockLocalCache(provider.defineComponent(id, files.toSeq.toArray))
/** This is used to lock the local cache in project/boot/.
* By checking the local cache first, we can avoid grabbing a global lock. */
/**
* This is used to lock the local cache in project/boot/.
* By checking the local cache first, we can avoid grabbing a global lock.
*/
private def lockLocalCache[T](action: => T): T = lock(provider.lockFile)(action)
/** This is used to ensure atomic access to components in the global Ivy cache. */