mirror of https://github.com/sbt/sbt.git
Implemented clean task + added integration test. Fixes #685
This commit is contained in:
parent
86de793517
commit
ebb7e66a26
|
|
@ -9,7 +9,7 @@ object CoursierPlugin extends AutoPlugin {
|
||||||
|
|
||||||
override def trigger = allRequirements
|
override def trigger = allRequirements
|
||||||
|
|
||||||
override def requires = sbt.plugins.IvyPlugin
|
override def requires = sbt.plugins.JvmPlugin
|
||||||
|
|
||||||
object autoImport {
|
object autoImport {
|
||||||
val coursierParallelDownloads = Keys.coursierParallelDownloads
|
val coursierParallelDownloads = Keys.coursierParallelDownloads
|
||||||
|
|
@ -153,6 +153,11 @@ object CoursierPlugin extends AutoPlugin {
|
||||||
shadedConfigOpt: Option[(String, String)],
|
shadedConfigOpt: Option[(String, String)],
|
||||||
packageConfigs: Seq[(Configuration, String)]
|
packageConfigs: Seq[(Configuration, String)]
|
||||||
) = hackHack ++ Seq(
|
) = hackHack ++ Seq(
|
||||||
|
clean := {
|
||||||
|
clean.value
|
||||||
|
Tasks.resolutionsCache.clear()
|
||||||
|
Tasks.reportsCache.clear()
|
||||||
|
},
|
||||||
coursierResolvers := Tasks.coursierResolversTask.value,
|
coursierResolvers := Tasks.coursierResolversTask.value,
|
||||||
coursierRecursiveResolvers := Tasks.coursierRecursiveResolversTask.value,
|
coursierRecursiveResolvers := Tasks.coursierRecursiveResolversTask.value,
|
||||||
coursierSbtResolvers := {
|
coursierSbtResolvers := {
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ object Tasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final case class ResolutionCacheKey(
|
private[coursier] final case class ResolutionCacheKey(
|
||||||
project: Project,
|
project: Project,
|
||||||
repositories: Seq[Repository],
|
repositories: Seq[Repository],
|
||||||
userEnabledProfiles: Set[String],
|
userEnabledProfiles: Set[String],
|
||||||
|
|
@ -406,7 +406,7 @@ object Tasks {
|
||||||
sbtClassifiers: Boolean
|
sbtClassifiers: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
private final case class ReportCacheKey(
|
private[coursier] final case class ReportCacheKey(
|
||||||
project: Project,
|
project: Project,
|
||||||
resolution: Map[Set[String], Resolution],
|
resolution: Map[Set[String], Resolution],
|
||||||
withClassifiers: Boolean,
|
withClassifiers: Boolean,
|
||||||
|
|
@ -414,10 +414,10 @@ object Tasks {
|
||||||
ignoreArtifactErrors: Boolean
|
ignoreArtifactErrors: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
private val resolutionsCache = new mutable.HashMap[ResolutionCacheKey, Map[Set[String], Resolution]]
|
private[coursier] val resolutionsCache = new mutable.HashMap[ResolutionCacheKey, Map[Set[String], Resolution]]
|
||||||
// these may actually not need to be cached any more, now that the resolutions
|
// these may actually not need to be cached any more, now that the resolutions
|
||||||
// are cached
|
// are cached
|
||||||
private val reportsCache = new mutable.HashMap[ReportCacheKey, UpdateReport]
|
private[coursier] val reportsCache = new mutable.HashMap[ReportCacheKey, UpdateReport]
|
||||||
|
|
||||||
private def forcedScalaModules(
|
private def forcedScalaModules(
|
||||||
scalaOrganization: String,
|
scalaOrganization: String,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
scalaVersion := "2.11.8"
|
||||||
|
|
||||||
|
val checkEmpty = TaskKey[Unit]("checkEmpty")
|
||||||
|
|
||||||
|
checkEmpty := {
|
||||||
|
assert(coursier.Helper.checkEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
val checkNotEmpty = TaskKey[Unit]("checkNotEmpty")
|
||||||
|
|
||||||
|
checkNotEmpty := {
|
||||||
|
assert(!coursier.Helper.checkEmpty)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package coursier
|
||||||
|
|
||||||
|
object Helper {
|
||||||
|
|
||||||
|
def checkEmpty(): Boolean = {
|
||||||
|
Tasks.resolutionsCache.isEmpty && Tasks.reportsCache.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
val pluginVersion = sys.props.getOrElse(
|
||||||
|
"plugin.version",
|
||||||
|
throw new RuntimeException(
|
||||||
|
"""|The system property 'plugin.version' is not defined.
|
||||||
|
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
> checkEmpty
|
||||||
|
> update
|
||||||
|
> checkNotEmpty
|
||||||
|
> clean
|
||||||
|
> checkEmpty
|
||||||
Loading…
Reference in New Issue