mirror of https://github.com/sbt/sbt.git
Merge pull request #306 from alexarchambault/topic/develop
Various changes
This commit is contained in:
commit
2c4d4eb271
|
|
@ -909,7 +909,7 @@ object Cache {
|
|||
|
||||
val fromEnv = sys.env.get("COURSIER_TTL").flatMap(fromString)
|
||||
def fromProps = sys.props.get("coursier.ttl").flatMap(fromString)
|
||||
def default = 24.days
|
||||
def default = 24.hours
|
||||
|
||||
fromEnv
|
||||
.orElse(fromProps)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ object CachePolicy {
|
|||
*
|
||||
* If no local file is found, *don't* try download it. Updates are only checked for files already
|
||||
* in cache.
|
||||
*
|
||||
* Follows the TTL parameter (assumes no update is needed if the last one is recent enough).
|
||||
*/
|
||||
case object LocalUpdateChanging extends CachePolicy
|
||||
|
||||
|
|
@ -22,6 +24,8 @@ object CachePolicy {
|
|||
* If no local file is found, *don't* try download it. Updates are only checked for files already
|
||||
* in cache.
|
||||
*
|
||||
* Follows the TTL parameter (assumes no update is needed if the last one is recent enough).
|
||||
*
|
||||
* Unlike `LocalUpdateChanging`, all found local files are checked for updates, not just the
|
||||
* changing ones.
|
||||
*/
|
||||
|
|
@ -31,12 +35,16 @@ object CachePolicy {
|
|||
* Pick local files, and download the missing ones.
|
||||
*
|
||||
* For changing ones, check for updates, and download those if any.
|
||||
*
|
||||
* Follows the TTL parameter (assumes no update is needed if the last one is recent enough).
|
||||
*/
|
||||
case object UpdateChanging extends CachePolicy
|
||||
|
||||
/**
|
||||
* Pick local files, download the missing ones, check for updates and download those if any.
|
||||
*
|
||||
* Follows the TTL parameter (assumes no update is needed if the last one is recent enough).
|
||||
*
|
||||
* Unlike `UpdateChanging`, all found local files are checked for updates, not just the changing
|
||||
* ones.
|
||||
*/
|
||||
|
|
@ -58,7 +66,11 @@ object CachePolicy {
|
|||
|
||||
|
||||
private val baseDefault = Seq(
|
||||
// first, try to update changing artifacts that were previously downloaded (follows TTL)
|
||||
CachePolicy.LocalUpdateChanging,
|
||||
// then, use what's available locally
|
||||
CachePolicy.LocalOnly,
|
||||
// lastly, try to download what's missing
|
||||
CachePolicy.FetchMissing
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -948,20 +948,13 @@ final case class Resolution(
|
|||
private def artifacts0(
|
||||
overrideClassifiers: Option[Seq[String]],
|
||||
keepAttributes: Boolean
|
||||
): Seq[Artifact] = {
|
||||
val res = for {
|
||||
dep <- minDependencies.toSeq
|
||||
(source, proj) <- projectCache
|
||||
.get(dep.moduleVersion)
|
||||
.toSeq
|
||||
artifact <- source
|
||||
.artifacts(dep, proj, overrideClassifiers)
|
||||
} yield (if (keepAttributes) artifact else artifact.copy(attributes = Attributes("", "")))
|
||||
): Seq[Artifact] =
|
||||
dependencyArtifacts0(overrideClassifiers).map {
|
||||
case (_, artifact) =>
|
||||
if (keepAttributes) artifact else artifact.copy(attributes = Attributes("", ""))
|
||||
}.distinct
|
||||
|
||||
res.distinct
|
||||
}
|
||||
|
||||
// temporary hack :-|
|
||||
// keepAttributes to false is a temporary hack :-|
|
||||
// if one wants the attributes field of artifacts not to be cleared, call dependencyArtifacts
|
||||
|
||||
def classifiersArtifacts(classifiers: Seq[String]): Seq[Artifact] =
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val coursierCachePolicies = Keys.coursierCachePolicies
|
||||
val coursierTtl = Keys.coursierTtl
|
||||
val coursierVerbosity = Keys.coursierVerbosity
|
||||
val mavenProfiles = Keys.mavenProfiles
|
||||
val coursierSourceRepositories = Keys.coursierSourceRepositories
|
||||
val coursierResolvers = Keys.coursierResolvers
|
||||
val coursierSbtResolvers = Keys.coursierSbtResolvers
|
||||
|
|
@ -64,6 +65,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
coursierCachePolicies := CachePolicy.default,
|
||||
coursierTtl := Cache.defaultTtl,
|
||||
coursierVerbosity := Settings.defaultVerbosityLevel,
|
||||
mavenProfiles := Set.empty,
|
||||
coursierSourceRepositories := Nil,
|
||||
coursierResolvers <<= Tasks.coursierResolversTask,
|
||||
coursierSbtResolvers <<= externalResolvers in updateSbtClassifiers,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ object Keys {
|
|||
|
||||
val coursierVerbosity = SettingKey[Int]("coursier-verbosity")
|
||||
|
||||
val mavenProfiles = SettingKey[Set[String]]("maven-profiles")
|
||||
|
||||
val coursierSourceRepositories = SettingKey[Seq[File]]("coursier-source-repositories")
|
||||
val coursierResolvers = TaskKey[Seq[Resolver]]("coursier-resolvers")
|
||||
val coursierSbtResolvers = TaskKey[Seq[Resolver]]("coursier-sbt-resolvers")
|
||||
|
|
|
|||
|
|
@ -374,6 +374,7 @@ object Tasks {
|
|||
|
||||
val verbosityLevel = coursierVerbosity.value
|
||||
|
||||
val userEnabledProfiles = mavenProfiles.value
|
||||
|
||||
val startRes = Resolution(
|
||||
currentProject.dependencies.map {
|
||||
|
|
@ -381,6 +382,7 @@ object Tasks {
|
|||
dep.copy(exclusions = dep.exclusions ++ exclusions)
|
||||
}.toSet,
|
||||
filter = Some(dep => !dep.optional),
|
||||
profileActivation = Some(core.Resolution.userProfileActivation(userEnabledProfiles)),
|
||||
forceVersions =
|
||||
// order matters here
|
||||
userForceVersions ++
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
scalaVersion := "2.11.8"
|
||||
|
||||
libraryDependencies += "org.apache.spark" %% "spark-sql" % "1.6.2"
|
||||
|
||||
mavenProfiles += "hadoop-2.6"
|
||||
|
||||
coursierCachePolicies := {
|
||||
if (sys.props("os.name").startsWith("Windows"))
|
||||
coursierCachePolicies.value
|
||||
else
|
||||
Seq(coursier.CachePolicy.ForceDownload)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
OK
|
||||
|
|
@ -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,19 @@
|
|||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
object Main extends App {
|
||||
val p = new java.util.Properties
|
||||
p.load(
|
||||
Thread.currentThread()
|
||||
.getContextClassLoader
|
||||
.getResource("common-version-info.properties")
|
||||
.openStream()
|
||||
)
|
||||
|
||||
val hadoopVersion = p.getProperty("version")
|
||||
Console.err.println(s"Found hadoop version $hadoopVersion")
|
||||
|
||||
assert(hadoopVersion == "2.6.0")
|
||||
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
$ delete output
|
||||
> run
|
||||
$ exists output
|
||||
Loading…
Reference in New Issue