diff --git a/build.sbt b/build.sbt index 0251916d7..bd002a1d2 100644 --- a/build.sbt +++ b/build.sbt @@ -88,13 +88,7 @@ lazy val lm = (project in file("librarymanagement")) (((srcs --- sdirs --- base) pair (relativeTo(sdirs) | relativeTo(base) | flat)) toSeq) } ) - .configure( - addSbtIO, - addSbtUtilLogging, - addSbtUtilCollection, - addSbtUtilCompletion, - addSbtUtilCache - ) + .configure(addSbtIO, addSbtUtilLogging, addSbtUtilCollection, addSbtUtilCache) .enablePlugins(ContrabandPlugin, JsonCodecPlugin) def customCommands: Seq[Setting[_]] = Seq( diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RepositoriesParser.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RepositoriesParser.scala deleted file mode 100644 index a10741b64..000000000 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RepositoriesParser.scala +++ /dev/null @@ -1,117 +0,0 @@ -package sbt -package internal -package librarymanagement - -import java.io.File -import java.net.URL - -import scala.io.Source -import sbt.internal.util.complete.Parser -import sbt.internal.util.complete.DefaultParsers._ - -private[sbt] object RepositoriesParser { - - private case class AfterPattern(artifactPattern: Option[String], flags: Int) - final case class PredefinedRepository(override val id: xsbti.Predefined) - extends xsbti.PredefinedRepository - final case class MavenRepository(override val id: String, override val url: URL) - extends xsbti.MavenRepository - final case class IvyRepository( - override val id: String, - override val url: URL, - override val ivyPattern: String, - override val artifactPattern: String, - override val mavenCompatible: Boolean, - override val skipConsistencyCheck: Boolean, - override val descriptorOptional: Boolean, - val bootOnly: Boolean - ) extends xsbti.IvyRepository - - // Predefined repositories - def local: Parser[xsbti.Repository] = - "local" ^^^ new PredefinedRepository(xsbti.Predefined.Local) - def mavenLocal: Parser[xsbti.Repository] = - "maven-local" ^^^ new PredefinedRepository(xsbti.Predefined.MavenLocal) - def mavenCentral: Parser[xsbti.Repository] = - "maven-central" ^^^ new PredefinedRepository(xsbti.Predefined.MavenCentral) - def predefinedResolver: Parser[xsbti.Repository] = local | mavenLocal | mavenCentral - - // Options - def descriptorOptional: Parser[Int] = "descriptorOptional" ^^^ Flags.descriptorOptionalFlag - def skipConsistencyCheck: Parser[Int] = "skipConsistencyCheck" ^^^ Flags.skipConsistencyCheckFlag - def bootOnly: Parser[Int] = "bootOnly" ^^^ Flags.bootOnlyFlag - def mavenCompatible: Parser[Int] = "mavenCompatible" ^^^ Flags.mavenCompatibleFlag - - def option: Parser[Int] = descriptorOptional | skipConsistencyCheck | bootOnly | mavenCompatible - def options: Parser[Int] = rep1sep(option, separator) map (_ reduce (_ | _)) - - def name: Parser[String] = ID - def separator: Parser[String] = "," ~> charClass(c => c == ' ' || c == '\t').*.string - def nonComma: Parser[String] = charClass(_ != ',').*.string - def ivyPattern: Parser[String] = nonComma - def artifactPattern: Parser[String] = nonComma - private def afterPattern: Parser[AfterPattern] = { - def onlyOptions = options map (AfterPattern(None, _)) - def both = artifactPattern ~ (separator ~> options).? map { - case ap ~ opts => AfterPattern(Some(ap), opts getOrElse 0) - } - onlyOptions | both - } - - def customResolver: Parser[xsbti.Repository] = - name ~ ": " ~ basicUri ~ (separator ~> ivyPattern).? ~ (separator ~> afterPattern).? map { - case name ~ ": " ~ uri ~ None ~ _ => - new MavenRepository(name, uri.toURL) - case name ~ ": " ~ uri ~ Some(ivy) ~ ap => - // scalac complains about the recursion depth if we pattern match over `ap` directly. - ap match { - case Some(AfterPattern(artifactPattern, Flags(dOpt, sc, bo, mc))) => - new IvyRepository( - name, - uri.toURL, - ivy, - artifactPattern getOrElse ivy, - mc, - sc, - dOpt, - bo - ) - case None => - new IvyRepository(name, uri.toURL, ivy, ivy, false, false, false, false) - } - } - - def resolver: Parser[xsbti.Repository] = - predefinedResolver | customResolver - - def getResolver[T](in: String)(parser: Parser[T]): Option[T] = - Parser.parse(in.trim, parser).right.toOption - - def apply(lines: Iterator[String]): Seq[xsbti.Repository] = - if (lines.isEmpty) Nil - else { - if (lines.next != "[repositories]") - throw new Exception("Repositories file must start with '[repositories]'") - lines.flatMap(getResolver(_)(resolver)).toList - } - def apply(str: String): Seq[xsbti.Repository] = apply(str.lines) - def apply(file: File): Seq[xsbti.Repository] = { - if (!file.exists) Nil - else apply(Source.fromFile(file).getLines) - } - - object Flags { - val descriptorOptionalFlag = 1 << 0 - val skipConsistencyCheckFlag = 1 << 1 - val bootOnlyFlag = 1 << 2 - val mavenCompatibleFlag = 1 << 3 - - def unapply(flags: Int): Some[(Boolean, Boolean, Boolean, Boolean)] = { - val dOpt = (flags & descriptorOptionalFlag) != 0 - val sc = (flags & skipConsistencyCheckFlag) != 0 - val bo = (flags & bootOnlyFlag) != 0 - val mc = (flags & mavenCompatibleFlag) != 0 - Some((dOpt, sc, bo, mc)) - } - } -} diff --git a/librarymanagement/src/test/scala/sbt/internal/librarymanagement/RepositoriesParserSpecification.scala b/librarymanagement/src/test/scala/sbt/internal/librarymanagement/RepositoriesParserSpecification.scala deleted file mode 100644 index 0aec79d39..000000000 --- a/librarymanagement/src/test/scala/sbt/internal/librarymanagement/RepositoriesParserSpecification.scala +++ /dev/null @@ -1,175 +0,0 @@ -package sbt -package internal -package librarymanagement - -import java.net.URL - -/** - * Tests that we can correctly parse repositories definitions. - */ -class RepositoriesParserSpecification extends UnitSpec { - import RepositoriesParser._ - - "The RepositoriesParser" should "check that repositories file starts with [repositories]" in { - val file = """local - |maven-central""".stripMargin - a[Exception] should be thrownBy RepositoriesParser(file) - } - - it should "parse the local repository" in { - val file = """[repositories] - | local""".stripMargin - val repos = RepositoriesParser(file) - repos.size shouldBe 1 - repos(0) shouldBe PredefinedRepository(xsbti.Predefined.Local) - - } - - it should "parse the local maven repository" in { - val file = """[repositories] - | maven-local""".stripMargin - val repos = RepositoriesParser(file) - repos.size shouldBe 1 - repos(0) shouldBe PredefinedRepository(xsbti.Predefined.MavenLocal) - } - - it should "parse Maven Central repository" in { - val file = """[repositories] - | maven-central""".stripMargin - val repos = RepositoriesParser(file) - repos.size shouldBe 1 - repos(0) shouldBe PredefinedRepository(xsbti.Predefined.MavenCentral) - } - - it should "parse simple Maven repository" in { - val file = """[repositories] - | mavenRepo: https://repo1.maven.org""".stripMargin - val repos = RepositoriesParser(file) - repos.size shouldBe 1 - repos(0) shouldBe MavenRepository("mavenRepo", new URL("https://repo1.maven.org")) - } - - it should "parse `bootOnly` option" in { - val file = """[repositories] - | ivyRepo: https://repo1.maven.org, [orgPath], bootOnly""".stripMargin - val repos = RepositoriesParser(file) - val expected = - IvyRepository( - "ivyRepo", - new URL("https://repo1.maven.org"), - "[orgPath]", - "[orgPath]", - mavenCompatible = false, - skipConsistencyCheck = false, - descriptorOptional = false, - bootOnly = true - ) - repos.size shouldBe 1 - repos(0) shouldBe expected - } - - it should "parse `mavenCompatible` option" in { - val file = """[repositories] - | ivyRepo: https://repo1.maven.org, [orgPath], mavenCompatible""".stripMargin - val repos = RepositoriesParser(file) - val expected = - IvyRepository( - "ivyRepo", - new URL("https://repo1.maven.org"), - "[orgPath]", - "[orgPath]", - mavenCompatible = true, - skipConsistencyCheck = false, - descriptorOptional = false, - bootOnly = false - ) - repos.size shouldBe 1 - repos(0) shouldBe expected - } - - it should "parse `skipConsistencyCheck` option" in { - val file = """[repositories] - | ivyRepo: https://repo1.maven.org, [orgPath], skipConsistencyCheck""".stripMargin - val repos = RepositoriesParser(file) - val expected = - IvyRepository( - "ivyRepo", - new URL("https://repo1.maven.org"), - "[orgPath]", - "[orgPath]", - mavenCompatible = false, - skipConsistencyCheck = true, - descriptorOptional = false, - bootOnly = false - ) - repos.size shouldBe 1 - repos(0) shouldBe expected - } - - it should "parse `descriptorOptional` option" in { - val file = """[repositories] - | ivyRepo: https://repo1.maven.org, [orgPath], descriptorOptional""".stripMargin - val repos = RepositoriesParser(file) - val expected = - IvyRepository( - "ivyRepo", - new URL("https://repo1.maven.org"), - "[orgPath]", - "[orgPath]", - mavenCompatible = false, - skipConsistencyCheck = false, - descriptorOptional = true, - bootOnly = false - ) - repos.size shouldBe 1 - repos(0) shouldBe expected - } - - it should "parse complex ivy repository definition" in { - val file = - """[repositories] - | ivyRepo: https://repo1.maven.org, [orgPath], [artPath], descriptorOptional, skipConsistencyCheck""".stripMargin - val repos = RepositoriesParser(file) - val expected = - IvyRepository( - "ivyRepo", - new URL("https://repo1.maven.org"), - "[orgPath]", - "[artPath]", - mavenCompatible = false, - skipConsistencyCheck = true, - descriptorOptional = true, - bootOnly = false - ) - repos.size shouldBe 1 - repos(0) shouldBe expected - } - - it should "parse multiple repositories defined together" in { - val file = - """[repositories] - | local - | ivyRepo: https://repo1.maven.org, [orgPath], [artPath], descriptorOptional, skipConsistencyCheck - | mavenRepo: https://repo1.maven.org""".stripMargin - val expected0 = PredefinedRepository(xsbti.Predefined.Local) - val expected1 = - IvyRepository( - "ivyRepo", - new URL("https://repo1.maven.org"), - "[orgPath]", - "[artPath]", - mavenCompatible = false, - skipConsistencyCheck = true, - descriptorOptional = true, - bootOnly = false - ) - val expected2 = MavenRepository("mavenRepo", new URL("https://repo1.maven.org")) - - val repos = RepositoriesParser(file) - repos.size shouldBe 3 - repos(0) shouldBe expected0 - repos(1) shouldBe expected1 - repos(2) shouldBe expected2 - } - -} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 156539ddd..290dde04d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,7 +13,6 @@ object Dependencies { private val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion private val utilLogging = "org.scala-sbt" %% "util-logging" % utilVersion - private val utilCompletion = "org.scala-sbt" %% "util-completion" % utilVersion private val utilCache = "org.scala-sbt" %% "util-cache" % utilVersion def getSbtModulePath(key: String, name: String) = { @@ -38,8 +37,6 @@ object Dependencies { addSbtModule(p, sbtUtilPath, "utilCollection", utilCollection) def addSbtUtilLogging(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilLogging", utilLogging) - def addSbtUtilCompletion(p: Project): Project = - addSbtModule(p, sbtUtilPath, "utilComplete", utilCompletion) def addSbtUtilCache(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilCache", utilCache) val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.0"