FPORT: Make Make JCenter opt in

Forward-port of sbt/sbt#2335.
This commit is contained in:
Dale Wijnand 2016-01-16 15:44:55 +00:00
parent 22d12cf996
commit f87eabdc98
2 changed files with 47 additions and 15 deletions

View File

@ -206,15 +206,45 @@ object Resolver {
/** Add the local and Maven Central repositories to the user repositories. */
def withDefaultResolvers(userResolvers: Seq[Resolver]): Seq[Resolver] =
withDefaultResolvers(userResolvers, true)
withDefaultResolvers(userResolvers, mavenCentral = true)
/**
* Add the local Ivy repository to the user repositories.
* If `mavenCentral` is true, add the Maven Central repository.
*/
def withDefaultResolvers(userResolvers: Seq[Resolver], mavenCentral: Boolean): Seq[Resolver] =
withDefaultResolvers(userResolvers, jcenter = false, mavenCentral)
/**
* Add the local Ivy repository to the user repositories.
* If `jcenter` is true, add the JCenter.
* If `mavenCentral` is true, add the Maven Central repository.
*/
def withDefaultResolvers(userResolvers: Seq[Resolver], jcenter: Boolean, mavenCentral: Boolean): Seq[Resolver] =
Seq(Resolver.defaultLocal) ++
userResolvers ++
single(JCenterRepository, jcenter) ++
single(DefaultMavenRepository, mavenCentral)
/**
* Reorganize the built-in resolvers that is configured for this application by the sbt launcher.
* If `jcenter` is true, add the JCenter.
* If `mavenCentral` is true, add the Maven Central repository.
*/
private[sbt] def reorganizeAppResolvers(appResolvers: Seq[Resolver], jcenter: Boolean, mavenCentral: Boolean): Seq[Resolver] =
appResolvers.partition(_ == Resolver.defaultLocal) match {
case (locals, xs) =>
locals ++
(xs.partition(_ == JCenterRepository) match {
case (jc, xs) =>
single(JCenterRepository, jcenter) ++
(xs.partition(_ == DefaultMavenRepository) match {
case (m, xs) =>
single(DefaultMavenRepository, mavenCentral) ++ xs // TODO - Do we need to filter out duplicates?
})
})
}
private def single[T](value: T, nonEmpty: Boolean): Seq[T] = if (nonEmpty) Seq(value) else Nil
/** A base class for defining factories for interfaces to Ivy repositories that require a hostname , port, and patterns. */

View File

@ -5,36 +5,38 @@ import sbt.internal.librarymanagement.BaseIvySpecification
class EvictionWarningSpec extends BaseIvySpecification {
// This is a specification to check the eviction warnings
"Eviction of scala-library whose scalaVersion" should "be detected" in scalaVersionWarn1()
"""Eviction of scala-library whose scalaVersion
""" should "be detected" in scalaVersionWarn1()
it should "not be detected if it's diabled" in scalaVersionWarn2()
it should "print out message about the eviction" in scalaVersionWarn3()
it should "print out message about the eviction with callers" in scalaVersionWarn4()
"""Including two (suspect) binary incompatible Java libraries to
direct dependencies""" should "be detected as eviction" in javaLibWarn1()
"""Including two (suspect) binary incompatible Java libraries to direct dependencies
""" should "be detected as eviction" in javaLibWarn1()
it should "not be detected if it's disabled" in javaLibWarn2()
it should "print out message about the eviction" in javaLibWarn3()
it should "print out message about the eviction with callers" in javaLibWarn4()
"""Including two (suspect) binary compatible Java libraries to
direct dependencies""" should "not be detected as eviction" in javaLibNoWarn1()
"""Including two (suspect) binary compatible Java libraries to direct dependencies
""" should "not be detected as eviction" in javaLibNoWarn1()
it should "print out message about the eviction" in javaLibNoWarn2()
"""Including two (suspect) transitively binary incompatible Java libraries to
direct dependencies""" should "be not detected as eviction" in javaLibTransitiveWarn1()
"""Including two (suspect) transitively binary incompatible Java libraries to direct dependencies
""" should "be not detected as eviction" in javaLibTransitiveWarn1()
it should "be detected if it's enabled" in javaLibTransitiveWarn2()
it should "print out message about the eviction if it's enabled" in javaLibTransitiveWarn3()
"""Including two (suspect) binary incompatible Scala libraries to
direct dependencies""" should "be detected as eviction" in scalaLibWarn1()
//it should "print out message about the eviction if it's enabled" in javaLibTransitiveWarn3()
"""Including two (suspect) binary incompatible Scala libraries to direct dependencies
""" should "be detected as eviction" in scalaLibWarn1()
it should "print out message about the eviction" in scalaLibWarn2()
"""Including two (suspect) binary compatible Scala libraries to
direct dependencies""" should "not be detected as eviction" in scalaLibNoWarn1()
"""Including two (suspect) binary compatible Scala libraries to direct dependencies
""" should "not be detected as eviction" in scalaLibNoWarn1()
it should "print out message about the eviction" in scalaLibNoWarn2()
"""Including two (suspect) transitively binary incompatible Scala libraries to
direct dependencies""" should "be not detected as eviction" in scalaLibTransitiveWarn1()
"""Including two (suspect) transitively binary incompatible Scala libraries to direct dependencies
""" should "be not detected as eviction" in scalaLibTransitiveWarn1()
it should "be detected if it's enabled" in scalaLibTransitiveWarn2()
it should "print out message about the eviction if it's enabled" in scalaLibTransitiveWarn3()