mirror of https://github.com/sbt/sbt.git
Add support for Maven profiles from the SBT plugin
This commit is contained in:
parent
3c7d3b8443
commit
47e0d38a3b
|
|
@ -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