Remove old sbt parser

This commit is contained in:
Dale Wijnand 2016-06-19 22:52:22 +01:00
parent a0193d28ea
commit 01a7a00915
29 changed files with 5 additions and 1570 deletions

View File

@ -212,51 +212,17 @@ private[sbt] object EvaluateConfigurations {
case _ => Nil
}
}
private[this] def isSpace = (c: Char) => Character isWhitespace c
private[this] def fstS(f: String => Boolean): ((String, Int)) => Boolean = { case (s, i) => f(s) }
private[this] def firstNonSpaceIs(lit: String) = (_: String).view.dropWhile(isSpace).startsWith(lit)
private[this] def or[A](a: A => Boolean, b: A => Boolean): A => Boolean = in => a(in) || b(in)
/** Configures the use of the old sbt parser. */
private[sbt] def useOldParser: Boolean =
sys.props.get("sbt.parser.simple").exists(java.lang.Boolean.parseBoolean)
/**
* Splits a set of lines into (imports, expressions). That is,
* anything on the right of the tuple is a scala expression (definition or setting).
*/
private[sbt] def splitExpressions(file: File, lines: Seq[String]): (Seq[(String, Int)], Seq[(String, LineRange)]) =
{
if (useOldParser) splitExpressions(lines)
else {
val split = SbtParser(file, lines)
// TODO - Look at pulling the parsed expression trees from the SbtParser and stitch them back into a different
// scala compiler rather than re-parsing.
(split.imports, split.settings)
}
}
def splitExpressions(lines: Seq[String]): (Seq[(String, Int)], Seq[(String, LineRange)]) = {
val blank = (_: String).forall(isSpace)
val isImport = firstNonSpaceIs("import ")
val comment = firstNonSpaceIs("//")
val blankOrComment = or(blank, comment)
val importOrBlank = fstS(or(blankOrComment, isImport))
val (imports, settings) = lines.zipWithIndex span importOrBlank
(imports filterNot fstS(blankOrComment), groupedLines(settings, blank, blankOrComment))
}
def groupedLines(lines: Seq[(String, Int)], delimiter: String => Boolean, skipInitial: String => Boolean): Seq[(String, LineRange)] =
{
val fdelim = fstS(delimiter)
@tailrec def group0(lines: Seq[(String, Int)], accum: Seq[(String, LineRange)]): Seq[(String, LineRange)] =
if (lines.isEmpty) accum.reverse
else {
val start = lines dropWhile fstS(skipInitial)
val (next, tail) = start.span { case (s, _) => !delimiter(s) }
val grouped = if (next.isEmpty) accum else (next.map(_._1).mkString("\n"), LineRange(next.head._2, next.last._2 + 1)) +: accum
group0(tail, grouped)
}
group0(lines, Nil)
val split = SbtParser(file, lines)
// TODO - Look at pulling the parsed expression trees from the SbtParser and stitch them back into a different
// scala compiler rather than re-parsing.
(split.imports, split.settings)
}
private[this] def splitSettingsDefinitions(lines: Seq[(String, LineRange)]): (Seq[(String, LineRange)], Seq[(String, LineRange)]) =

View File

@ -1 +0,0 @@
*

View File

@ -1,66 +0,0 @@
import SonatypeKeys._
xerial.sbt.Sonatype.sonatypeSettings
organization := "me.benoitguigal"
name := "twitter"
version := "1.1-SNAPSHOT"
scalaVersion := "2.10.2"
resolvers += "spray repo" at "http://repo.spray.io"
libraryDependencies ++= {
val sprayV = "1.2.1"
Seq(
"com.typesafe.akka" %% "akka-actor" % "2.2.3",
"joda-time" % "joda-time" % "2.3",
"org.joda" % "joda-convert" % "1.2",
"io.spray" % "spray-http" % sprayV,
"io.spray" % "spray-httpx" % sprayV,
"io.spray" % "spray-util" % sprayV,
"io.spray" % "spray-client" % sprayV,
"io.spray" % "spray-can" % sprayV,
"com.netflix.rxjava" % "rxjava-scala" % "0.19.6",
"io.spray" %% "spray-json" % "1.2.6",
"org.scalatest" % "scalatest_2.10" % "2.1.3" % "test",
"org.mockito" % "mockito-core" % "1.9.5" % "test")
}
publishMavenStyle := true
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
pomIncludeRepository := { _ => false }
pomExtra := (
<url>https://github.com/benoitguigal/twitter-spray</url>
<licenses>
<license>
<name>BSD-style</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:benoitguigal/twitter-spray.git</url>
<connection>scm:git:git@github.com:benoitguigal/twitter-spray.git</connection>
</scm>
<developers>
<developer>
<id>BGuigal</id>
<name>Benoit Guigal</name>
<url>http://benoitguigal.me</url>
</developer>
</developers>
)

View File

@ -1,81 +0,0 @@
//////////////////////////////////////
// Root project settings
//////////////////////////////////////
name := Common.PROJECT_NAME
unidocSettings
Common.commonSettings
//////////////////////////////////////
// Subproject definitions
//////////////////////////////////////
lazy val core = Common.subproject("core").dependsOn(util)
lazy val util = Common.subproject("util")
//////////////////////////////////////
// Common settings shared by all projects
//////////////////////////////////////
version in ThisBuild := Common.PROJECT_VERSION
organization in ThisBuild := Common.ORGANIZATION
scalaVersion in ThisBuild := Common.SCALA_VERSION
libraryDependencies in ThisBuild ++= Seq(
"org.scala-lang" % "scala-reflect" % Common.SCALA_VERSION,
"org.slf4j" % "slf4j-api" % Common.SLF4J_VERSION,
"ch.qos.logback" % "logback-classic" % Common.LOGBACK_VERSION % "runtime",
"org.scalatest" %% "scalatest" % Common.SCALATEST_VERSION % "test"
)
scalacOptions in (ThisBuild, Compile) ++= Seq(
"-unchecked",
"-deprecation",
"-feature"
)
parallelExecution in (ThisBuild, Test) := false
fork in (ThisBuild, Test) := true
//////////////////////////////////////
// Publishing settings
//////////////////////////////////////
publishMavenStyle in (ThisBuild) := true
pomIncludeRepository in (ThisBuild) := { _ => false }
licenses in (ThisBuild) := Seq(
"BSD-style" -> url("http://opensource.org/licenses/BSD-2-Clause")
)
homepage in (ThisBuild) := Some(url("http://genslerappspod.github.io/scalavro/"))
pomExtra in (ThisBuild) := (
<scm>
<url>git@github.com:GenslerAppsPod/scalavro.git</url>
<connection>scm:git:git@github.com:GenslerAppsPod/scalavro.git</connection>
</scm>
<developers>
<developer>
<id>ConnorDoyle</id>
<name>Connor Doyle</name>
<url>http://gensler.com</url>
</developer>
</developers>
)
publishTo in (ThisBuild) <<= version { (v: String) =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

View File

@ -1,52 +0,0 @@
name := "core"
resolvers += "spray repo" at "http://repo.spray.io"
libraryDependencies ++= Seq(
"com.github.scala-incubator.io" %% "scala-io-core" % "0.4.2",
"com.github.scala-incubator.io" %% "scala-io-file" % "0.4.2",
"com.typesafe.akka" %% "akka-actor" % "2.2.4",
"com.typesafe.akka" %% "akka-slf4j" % "2.2.4",
"com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
"io.spray" % "spray-client" % "1.2.1",
"jline" % "jline" % "2.12",
"org.apache.curator" % "curator-recipes" % "2.4.2",
"org.apache.zookeeper" % "zookeeper" % "3.4.6",
"org.fusesource" % "sigar" % "1.6.4" classifier "native" classifier "",
"org.mozilla" % "rhino" % "1.7R4",
"org.reactivemongo" %% "play2-reactivemongo" % "0.10.2",
"org.reactivemongo" %% "reactivemongo" % "0.10.0",
"org.scalaz" %% "scalaz-core" % "7.0.6"
).map(_.exclude("org.slf4j", "slf4j-log4j12"))
val copyNativeLibraries = taskKey[Set[File]]("Copy native libraries to native libraries directory")
copyNativeLibraries := {
val cp = (managedClasspath in Runtime).value
// FIXME: Currently, only sigar has a native library.
// Extract this as a setting when more native libraries are added.
val nativeJarFile = cp.map(_.data).find(_.getName == "sigar-1.6.4-native.jar").get
val nativeLibrariesDirectory = target.value / "native_libraries" / (System.getProperty("sun.arch.data.model") + "bits")
IO.unzip(nativeJarFile, nativeLibrariesDirectory)
}
run <<= (run in Runtime) dependsOn copyNativeLibraries
(test in Test) <<= (test in Test) dependsOn copyNativeLibraries
val toolsJar = if (System.getProperty("os.name") != "Mac OS X") {
Seq(Attributed.blank(file(System.getProperty("java.home").dropRight(3) + "lib/tools.jar")))
} else {
Nil
}
// adding the tools.jar to the unmanaged-jars seq
unmanagedJars in Compile ~= (toolsJar ++ _)
lazy val root = (project in file(".")).enablePlugins(PlayScala)
org.scalastyle.sbt.ScalastylePlugin.Settings
scalariformSettings
Common.settings

View File

@ -1,55 +0,0 @@
name := "play-recaptcha"
description := "Google reCAPTCHA integration for Play Framework"
organization := "com.nappin"
version := "0.9-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
crossScalaVersions := Seq("2.10.4", "2.11.1")
libraryDependencies ++= Seq(
ws,
"org.mockito" % "mockito-core" % "1.+" % "test"
)
// needed to publish to maven central
publishMavenStyle := true
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
publishArtifact in Test := false
pomIncludeRepository := { _ => false }
pomExtra := (
<url>http://chrisnappin.github.io/play-recaptcha</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:chrisnappin/play-recaptcha.git</connection>
<developerConnection>scm:git:git@github.com:chrisnappin/play-recaptcha.git</developerConnection>
<url>git@github.com:chrisnappin/play-recaptcha.git</url>
</scm>
<developers>
<developer>
<id>chrisnappin</id>
<name>Chris Nappin</name>
<email>chris@nappin.com</email>
<timezone>UTC</timezone>
</developer>
</developers>)

View File

@ -1,75 +0,0 @@
name := """FTL"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.1"
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
ws,
filters,
"org.webjars" % "bootstrap" % "3.0.2",
"com.typesafe.play.plugins" %% "play-plugins-util" % "2.3.0",
"com.typesafe.play.plugins" %% "play-plugins-mailer" % "2.3.0",
"org.mindrot" % "jbcrypt" % "0.3m",
"org.specs2" %% "specs2" % "2.3.12" % "test",
"org.mockito" % "mockito-all" % "1.9.5" % "test",
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.0-SNAPSHOT",
"org.reactivemongo" %% "reactivemongo" % "0.11.0-SNAPSHOT"
)
resolvers ++= Seq(
Resolver.typesafeRepo("releases")
)
organization := "ws.securesocial"
organizationName := "SecureSocial"
organizationHomepage := Some(new URL("http://www.securesocial.ws"))
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := { _ => false }
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
startYear := Some(2012)
description := "An authentication module for Play Framework applications supporting OAuth, OAuth2, OpenID, Username/Password and custom authentication schemes."
licenses := Seq("The Apache Software License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
homepage := Some(url("http://www.securesocial.ws"))
pomExtra := (
<scm>
<url>https://github.com/jaliss/securesocial</url>
<connection>scm:git:git@github.com:jaliss/securesocial.git</connection>
<developerConnection>scm:git:https://github.com/jaliss/securesocial.git</developerConnection>
</scm>
<developers>
<developer>
<id>jaliss</id>
<name>Jorge Aliss</name>
<email>jaliss [at] gmail.com</email>
<url>https://twitter.com/jaliss</url>
</developer>
</developers>
)
scalacOptions := Seq("-feature", "-deprecation")

View File

@ -1,41 +0,0 @@
name := "cms"
organization := "org.qirx"
scalaVersion := "2.11.1"
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.3.0",
"com.typesafe.play" %% "play-test" % "2.3.0",
"com.typesafe.play" %% "play-json" % "2.3.0",
"org.qirx" %% "little-spec" % "0.4-SNAPSHOT" % "test",
"org.qirx" %% "little-spec-extra-documentation" % "0.4-SNAPSHOT" % "test"
)
unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value)
unmanagedSourceDirectories in Test := Seq((scalaSource in Test).value)
testFrameworks += new TestFramework("org.qirx.littlespec.sbt.TestFramework")
val x = taskKey[Unit /* Geef niets terug */]("test")
x := {
val cacheDir = (streams in x).value.cacheDirectory / "unzipped"
val dependencies = (externalDependencyClasspath in Compile).value
val possibleJar = dependencies
.map(a => a.data)
.filter(f => f.getName contains "play-json")
.headOption
possibleJar match {
case Some(file) =>
val unzippedFiles = IO.unzip(from = file, toDirectory = cacheDir)
// use flatmap because relativize returns an option, which can be flattened
val names = unzippedFiles.flatMap(file => IO.relativize(base = cacheDir, file))
println(s"Unzipped the following files in `$cacheDir`")
names.foreach(println)
case None => sys.error("Could not find jar")
}
}

View File

@ -1,18 +0,0 @@
name := "play-html-compressor"
scalaVersion := "2.11.1"
val pom = <scm>
<url>git@github.com:mohiva/play-html-compressor.git</url>
<connection>scm:git:git@github.com:mohiva/play-html-compressor.git</connection>
</scm>
<developers>
<developer>
<id>akkie</id>
<name>Christian Kaps</name>
<url>http://mohiva.com</url>
</developer>
</developers>
publishMavenStyle := true

View File

@ -1,141 +0,0 @@
import sbt._
import AssemblyKeys._
import aether.Aether._
name := "conjecture"
version := "0.1.2-SNAPSHOT"
organization := "com.etsy"
scalaVersion := "2.9.3"
sbtVersion := "0.12.1"
scalacOptions ++= Seq("-unchecked", "-deprecation")
compileOrder := CompileOrder.JavaThenScala
javaHome := Some(file("/usr/java/latest"))
publishArtifact in packageDoc := false
resolvers ++= {
Seq(
"Concurrent Maven Repo" at "http://conjars.org/repo",
"cloudera" at "https://repository.cloudera.com/artifactory/cloudera-repos/"
)
}
libraryDependencies += "cascading" % "cascading-core" % "2.0.0"
libraryDependencies += "cascading" % "cascading-local" % "2.0.0" exclude("com.google.guava", "guava")
libraryDependencies += "cascading" % "cascading-hadoop" % "2.0.0"
libraryDependencies += "cascading.kryo" % "cascading.kryo" % "0.4.6"
libraryDependencies += "com.google.code.gson" % "gson" % "2.2.2"
libraryDependencies += "com.twitter" % "maple" % "0.2.4"
libraryDependencies += "com.twitter" % "algebird-core_2.9.2" % "0.1.12"
libraryDependencies += "com.twitter" % "scalding-core_2.9.2" % "0.8.5"
libraryDependencies += "commons-lang" % "commons-lang" % "2.4"
libraryDependencies += "com.joestelmach" % "natty" % "0.7"
libraryDependencies += "io.backchat.jerkson" % "jerkson_2.9.2" % "0.7.0"
libraryDependencies += "com.google.guava" % "guava" % "13.0.1"
libraryDependencies += "org.apache.commons" % "commons-math3" % "3.2"
libraryDependencies += "org.apache.hadoop" % "hadoop-common" % "2.0.0-cdh4.1.1" exclude("commons-daemon", "commons-daemon")
libraryDependencies += "org.apache.hadoop" % "hadoop-hdfs" % "2.0.0-cdh4.1.1" exclude("commons-daemon", "commons-daemon")
libraryDependencies += "org.apache.hadoop" % "hadoop-tools" % "2.0.0-mr1-cdh4.1.1" exclude("commons-daemon", "commons-daemon")
libraryDependencies += "net.sf.trove4j" % "trove4j" % "3.0.3"
libraryDependencies += "com.esotericsoftware.kryo" % "kryo" % "2.21"
libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test"
parallelExecution in Test := false
publishArtifact in Test := false
seq(assemblySettings: _*)
publishTo <<= version { v : String =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT")) {
Some("snapshots" at nexus + "content/repositories/snapshots")
} else {
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
}
publishMavenStyle := true
pomIncludeRepository := { x => false }
pomExtra := (
<url>https://github.com/etsy/Conjecture</url>
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:etsy/Conjecture.git</url>
<connection>scm:git:git@github.com:etsy/Conjecture.git</connection>
</scm>
<developers>
<developer>
<id>jattenberg</id>
<name>Josh Attenberg</name>
<url>github.com/jattenberg</url>
</developer>
<developer>
<id>rjhall</id>
<name>Rob Hall</name>
<url>github.com/rjhall</url>
</developer>
</developers>
)
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")
seq(aetherPublishSettings: _*)
pomIncludeRepository := { _ => false }
// Uncomment if you don't want to run all the tests before building assembly
// test in assembly := {}
// Janino includes a broken signature, and is not needed:
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
val excludes = Set("jsp-api-2.1-6.1.14.jar", "jsp-2.1-6.1.14.jar",
"jasper-compiler-5.5.12.jar", "janino-2.5.16.jar")
cp filter { jar => excludes(jar.data.getName)}
}
// Some of these files have duplicates, let's ignore:
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case s if s.endsWith(".class") => MergeStrategy.last
case s if s.endsWith("project.clj") => MergeStrategy.concat
case s if s.endsWith(".html") => MergeStrategy.last
case s if s.contains("servlet") => MergeStrategy.last
case x => old(x)
}
}

View File

@ -1,52 +0,0 @@
name := "Programming Scala, Second Edition: Code examples"
version := "2.0"
organization := "org.programming-scala"
scalaVersion := "2.11.2"
// Build against several versions of Scala
crossScalaVersions := Seq("2.11.2", "2.10.4")
// Scala 2.11 split the standard library into smaller components.
// The XML and parser combinator support are now separate jars.
// I use the if condition to conditionally add these extra dependencies.
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.3",
"org.scalaz" %% "scalaz-core" % "7.0.6",
"org.scalacheck" %% "scalacheck" % "1.11.4" % "test",
"org.scalatest" %% "scalatest" % "2.2.0" % "test",
"org.specs2" %% "specs2" % "2.3.12" % "test",
// JUnit is used for some Java interop. examples. A driver for JUnit:
"junit" % "junit-dep" % "4.10" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
) ++ (
if (scalaVersion.value startsWith "2.11")
Seq(
// Could use this to get everything:
// "org.scala-lang.modules" %% "scala-library-all" % "2.11.1")
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1",
"org.scala-lang.modules" %% "scala-xml" % "1.0.2")
else Seq.empty)
val commonOptions = Seq(
"-encoding", "UTF-8", "-optimise",
"-deprecation", "-unchecked", "-feature", "-Xlint")
// "-explaintypes" - Use when you need more detailed messages for type errors.
// "-Yinline-warnings" - Warns if constructs have the @inline annotation, but
// inlining isn't possible. Can be more annoying than useful most of the time,
// but consider using it for performance critical code.
// Options passed to the Scala and Java compilers:
scalacOptions <<= scalaVersion map { version: String =>
if (version.startsWith("2.10")) commonOptions
else commonOptions ++ Seq("-Ywarn-infer-any") // Warn if "Any" is inferred
}
javacOptions ++= Seq(
"-Xlint:unchecked", "-Xlint:deprecation") // Java 8: "-Xdiags:verbose")
// Enable improved incremental compilation feature in 2.11.X.
// see http://www.scala-lang.org/news/2.11.1
incOptions := incOptions.value.withNameHashing(true)

View File

@ -1,93 +0,0 @@
//
// Copyright (c) 2013-2014 Alexey Aksenov ezh@ezh.msk.ru
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
ScriptedPlugin.scriptedSettings
name := "sbt-osgi-manager"
description := "OSGi development bridge based on Bndtools and Tycho."
licenses := Seq("The Apache Software License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
organization := "org.digimead"
organizationHomepage := Some(url("http://digimead.org"))
homepage := Some(url("https://github.com/digimead/sbt-osgi-manager"))
version <<= (baseDirectory) { (b) => scala.io.Source.fromFile(b / "version").mkString.trim }
// There is no "-Xfatal-warnings" because we have cross compilation against different Scala versions
scalacOptions ++= Seq("-encoding", "UTF-8", "-unchecked", "-deprecation", "-Xcheckinit")
// http://vanillajava.blogspot.ru/2012/02/using-java-7-to-target-much-older-jvms.html
javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6")
javacOptions in doc := Seq("-source", "1.6")
if (sys.env.contains("XBOOTCLASSPATH")) Seq(javacOptions += "-Xbootclasspath:" + sys.env("XBOOTCLASSPATH")) else Seq()
sbtPlugin := true
resourceGenerators in Compile <+=
(resourceManaged in Compile, name, version) map { (dir, n, v) =>
val file = dir / "version-%s.properties".format(n)
val contents = "name=%s\nversion=%s\nbuild=%s\n".format(n, v, ((System.currentTimeMillis / 1000).toInt).toString)
IO.write(file, contents)
Seq(file)
}
libraryDependencies ++= {
val mavenVersion = "3.0" // based on Tycho, MUST be the same
val mavenWagonVersion = "2.4"
val tychoVersion = "0.18.0"
val aetherAPIVersion = "1.7" // based on Tycho, MUST be the same
Seq(
"biz.aQute.bnd" % "bndlib" % "2.1.0",
"org.apache.felix" % "org.apache.felix.resolver" % "1.0.0",
"org.apache.maven" % "maven-aether-provider" % mavenVersion,
"org.apache.maven" % "maven-artifact" % mavenVersion,
"org.apache.maven" % "maven-compat" % mavenVersion,
"org.apache.maven" % "maven-core" % mavenVersion,
"org.apache.maven" % "maven-plugin-api" % mavenVersion,
"org.apache.maven" % "maven-embedder" % mavenVersion, // provide org.apache.maven.cli.MavenCli
"org.apache.maven.wagon" % "wagon-http" % mavenWagonVersion, // HTTP connector for remore repositories
"org.apache.maven.wagon" % "wagon-file" % mavenWagonVersion, // File connector for local repositories
"org.eclipse.tycho" % "tycho-core" % tychoVersion,
"org.eclipse.tycho" % "tycho-p2-facade" % tychoVersion,
"org.osgi" % "org.osgi.core" % "5.0.0",
"org.osgi" % "org.osgi.enterprise" % "5.0.0",
"org.sonatype.aether" % "aether-connector-wagon" % aetherAPIVersion
)
}
scriptedBufferLog := false
resolvers ++= Seq(
"sbt-osgi-mananger-digimead-maven" at "http://storage.googleapis.com/maven.repository.digimead.org/",
Resolver.url("sbt-osgi-manager-typesafe-ivy-releases", url("http://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns),
Resolver.url("sbt-osgi-manager-typesafe-ivy-snapshots", url("http://repo.typesafe.com/typesafe/ivy-snapshots/"))(Resolver.defaultIvyPatterns),
Resolver.url("sbt-osgi-manager-typesafe-repository", url("http://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns),
Resolver.url("sbt-osgi-manager-typesafe-shapshots", url("http://repo.typesafe.com/typesafe/ivy-snapshots/"))(Resolver.defaultIvyPatterns))
sourceGenerators in Compile <+= (sbtVersion, sourceDirectory in Compile, sourceManaged in Compile) map { (v, sourceDirectory, sourceManaged) =>
val interface = v.split("""\.""").take(2).mkString(".")
val source = sourceDirectory / ".." / "patch" / interface
val generated = (PathFinder(source) ***) x Path.rebase(source, sourceManaged)
IO.copy(generated, true, false)
generated.map(_._2).filter(_.getName endsWith ".scala")
}
//logLevel := Level.Debug

View File

@ -1,2 +0,0 @@
//import sbt._
// val a = 3

View File

@ -1,39 +0,0 @@
import AssemblyKeys._
name := "s3_website"
version := "0.0.1"
scalaVersion := "2.11.2"
scalacOptions += "-feature"
scalacOptions += "-language:implicitConversions"
scalacOptions += "-language:postfixOps"
scalacOptions += "-target:jvm-1.6"
libraryDependencies += "org.yaml" % "snakeyaml" % "1.13"
libraryDependencies += "org.jruby" % "jruby" % "1.7.11"
libraryDependencies += "com.amazonaws" % "aws-java-sdk" % "1.7.7"
libraryDependencies += "log4j" % "log4j" % "1.2.17"
libraryDependencies += "commons-codec" % "commons-codec" % "1.9"
libraryDependencies += "commons-io" % "commons-io" % "2.4"
libraryDependencies += "org.apache.tika" % "tika-core" % "1.4"
libraryDependencies += "com.lexicalscope.jewelcli" % "jewelcli" % "0.8.9"
libraryDependencies += "org.specs2" %% "specs2" % "2.3.11" % "test"
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
jarName in assembly := "s3_website.jar"
test in assembly := {}

View File

@ -1,18 +0,0 @@
/* */
/** Project */
name := "signal-collect-yarn"
/* */
/*
AAA
*/
val a = 3
// OK
libraryDependencies ++= Seq("org.scala-lang" % "scala-compiler" % "2.10.4") map {
(dependency) =>{
dependency
} /* OK */
}

View File

@ -1,5 +0,0 @@
val x = bar
{
val a,b = project
}

View File

@ -1,71 +0,0 @@
name := "scala-stm"
organization := "org.scala-stm"
version := "0.8-SNAPSHOT"
scalaVersion := "2.11.2"
crossScalaVersions := Seq("2.11.2", "2.10.4", "2.9.3")
libraryDependencies += ("org.scalatest" %% "scalatest" % "[1.5,)" % "test")
libraryDependencies += ("junit" % "junit" % "4.5" % "test")
// skip exhaustive tests
testOptions += Tests.Argument("-l", "slow")
// test of TxnExecutor.transformDefault must be run by itself
parallelExecution in Test := false
////////////////////
// publishing
pomExtra :=
<url>http://nbronson.github.com/scala-stm/</url>
<licenses>
<license>
<name>BSD</name>
<url>https://github.com/nbronson/scala-stm/blob/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:nbronson/scala-stm.git</connection>
<url>git@github.com:nbronson/scala-stm.git</url>
</scm>
<developers>
<developer>
<id>nbronson</id>
<name>Nathan Bronson</name>
<email>ngbronson@gmail.com</email>
</developer>
</developers>
publishMavenStyle := true
publishTo <<= (version) { v: String =>
val base = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at base + "content/repositories/snapshots/")
else
Some("releases" at base + "service/local/staging/deploy/maven2/")
}
// exclude scalatest from the Maven POM
pomPostProcess := { xi: scala.xml.Node =>
import scala.xml._
val badDeps = (xi \\ "dependency") filter {
x => (x \ "artifactId").text != "scala-library"
} toSet
def filt(root: Node): Node = root match {
case x: Elem => {
val ch = x.child filter { !badDeps(_) } map { filt(_) }
Elem(x.prefix, x.label, x.attributes, x.scope, ch: _*)
}
case x => x
}
filt(xi)
}
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

View File

@ -1,7 +0,0 @@
import sbt._, Keys._,java.util._
import a._
import c._
import d._
import g._,h._
scalaVersion := "2.11.4"

View File

@ -1,51 +0,0 @@
parallelExecution in Global := false
val commonSettings = Seq(
organization := "com.github.germanosin",
version := "1.0",
javacOptions in Compile ++= Seq("-source", "1.6", "-target", "1.6"),
scalaVersion := "2.11.1"
)
lazy val foldermessages = project.settings(commonSettings: _*)
.settings(
name := "play-foldermessages",
crossScalaVersions := Seq("2.10.4", "2.11.1"),
libraryDependencies += "com.typesafe.play" %% "play" % "2.3.2",
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/",
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org"
if (isSnapshot.value) Some("snapshots" at s"$nexus/content/repositories/snapshots")
else Some("releases" at s"$nexus/service/local/staging/deploy/maven2")
},
pomExtra := (
<url>http://github.com/germanosin/play-foldermessages</url>
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>git@github.com:germanosin/play-foldermessages.git</url>
<connection>scm:git:git@github.com:germanosin/play-foldermessages.git</connection>
</scm>
<developers>
<developer>
<id>germanosin</id>
<name>German Osin</name>
</developer>
</developers>
),
useGpg := true
)
lazy val sampleApp = Project("sample-app", file("sample-app"))
.settings(commonSettings: _*)
.enablePlugins(PlayScala)
.dependsOn(foldermessages)
lazy val playFolderMessages = project.in(file("."))
.settings(commonSettings: _*)
.aggregate(foldermessages,sampleApp)

View File

@ -1,74 +0,0 @@
import AssemblyKeys._
assemblySettings
/** Project */
name := "signal-collect-yarn"
version := "1.0-SNAPSHOT"
organization := "com.signalcollect"
scalaVersion := "2.11.1"
val hadoopVersion = "2.3.0"
net.virtualvoid.sbt.graph.Plugin.graphSettings
scalacOptions ++= Seq("-optimize", "-Yinline-warnings", "-feature", "-deprecation", "-Xelide-below", "INFO" )
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource
EclipseKeys.withSource := true
parallelExecution in Test := false
test in assembly := {}
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList("org", "apache", "hadoop", xs @ _*) => MergeStrategy.last
case PathList("org", "apache", "commons", "collections", xs @ _*) => MergeStrategy.last
case PathList("org", "objectweb", "asm", xs @ _*) => MergeStrategy.last
case PathList("com", "thoughtworks", xs @ _*) => MergeStrategy.last
case PathList("META-INF", "maven", xs @ _*) => MergeStrategy.last
case PathList("log4j.properties") => MergeStrategy.last
case x => old(x)
}
}
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
cp filter { entry =>
(entry.data.getName == "asm-3.2.jar" ||
entry.data.getName == "asm-3.1.jar"
)}
}
/** Dependencies */
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-async" % "0.9.1",
"org.scala-lang" % "scala-library" % "2.11.1" % "compile",
("org.apache.hadoop" % "hadoop-common" % hadoopVersion % "compile").
exclude("commons-beanutils", "commons-beanutils-core"),
"org.apache.hadoop" % "hadoop-yarn-common" % hadoopVersion % "compile",
("org.apache.hadoop" % "hadoop-yarn-client" % hadoopVersion % "compile").
exclude("hadoop-yarn-api", "org.apache.hadoop"),
"org.apache.hadoop" % "hadoop-yarn-server-resourcemanager" % hadoopVersion % "compile",
"org.apache.hadoop" % "hadoop-yarn-server-nodemanager" % hadoopVersion % "compile",
"org.apache.hadoop" % "minicluster" % "2.2.0" ,
"org.apache.hadoop" % "hadoop-hdfs" % hadoopVersion,
"com.github.romix.akka" %% "akka-kryo-serialization-custom" % "0.3.5" % "compile",
"com.amazonaws" % "aws-java-sdk" % "1.7.12" % "compile",
"com.jcraft" % "jsch" % "0.1.51" % "compile",
"org.apache.commons" % "commons-compress" % "1.5" % "compile",
"log4j" % "log4j" % "1.2.17" % "compile",
"com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
"com.typesafe.akka" % "akka-slf4j_2.11" % "2.3.4",
"junit" % "junit" % "4.8.2" % "test",
"org.specs2" %% "specs2" % "2.3.11" % "test",
"org.scalacheck" %% "scalacheck" % "1.11.3" % "test",
"org.scalatest" %% "scalatest" % "2.1.3" % "test",
"org.easymock" % "easymock" % "3.2" % "test",
"com.typesafe.akka" %% "akka-remote" % "2.3.4" force()
)
resolvers += "Ifi Public" at "https://maven.ifi.uzh.ch/maven2/content/groups/public/"

View File

@ -1,41 +0,0 @@
sbtPlugin := true
name := "sbt-docker"
organization := "se.marcuslonnberg"
organizationHomepage := Some(url("https://github.com/marcuslonnberg"))
version := "0.6.0-SNAPSHOT"
libraryDependencies += "org.scalatest" %% "scalatest" % "2.1.0" % "test"
licenses := Seq("MIT License" -> url("https://github.com/marcuslonnberg/sbt-docker/blob/master/LICENSE"))
homepage := Some(url("https://github.com/marcuslonnberg/sbt-docker"))
scmInfo := Some(ScmInfo(url("https://github.com/marcuslonnberg/sbt-docker"), "scm:git:git://github.com:marcuslonnberg/sbt-docker.git"))
scalacOptions := Seq("-deprecation", "-unchecked", "-feature")
publishMavenStyle := true
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
pomIncludeRepository := { _ => false}
pomExtra := (
<developers>
<developer>
<id>marcuslonnberg</id>
<name>Marcus Lönnberg</name>
<url>http://marcuslonnberg.se</url>
</developer>
</developers>
)

View File

@ -1,67 +0,0 @@
organization := "com.sksamuel.akka"
name := "akka-patterns"
version := "0.11.0"
scalaVersion := "2.11.2"
crossScalaVersions := Seq("2.11.2", "2.10.4")
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
javacOptions ++= Seq("-source", "1.6", "-target", "1.6")
publishTo <<= version {
(v: String) =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
publishMavenStyle := true
publishArtifact in Test := false
parallelExecution in Test := false
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.3"
libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % "2.3.3"
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.7"
libraryDependencies += "org.slf4j" % "log4j-over-slf4j" % "1.7.7" % "test"
libraryDependencies += "log4j" % "log4j" % "1.2.17" % "test"
libraryDependencies += "commons-io" % "commons-io" % "2.4"
libraryDependencies += "org.mockito" % "mockito-all" % "1.9.5" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.0" % "test"
pomExtra := (
<url>https://github.com/sksamuel/akka-patterns</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:sksamuel/akka-patterns.git</url>
<connection>scm:git@github.com:sksamuel/akka-patterns.git</connection>
</scm>
<developers>
<developer>
<id>sksamuel</id>
<name>sksamuel</name>
<url>http://github.com/akka-patterns</url>
</developer>
</developers>)

View File

@ -1,160 +0,0 @@
name <<= submitProjectName(pname => "progfun-"+ pname)
version := "1.0.0"
scalaVersion := "2.10.2"
scalacOptions ++= Seq("-deprecation", "-feature")
libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"
libraryDependencies += "junit" % "junit" % "4.10" % "test"
libraryDependencies += "org.scala-lang" % "scala-reflect" % "2.10.2"
// This setting defines the project to which a solution is submitted. When creating a
// handout, the 'createHandout' task will make sure that its value is correct.
submitProjectName := "suggestions"
libraryDependencies <++= (currentProject) { c =>
if (c.isEmpty || c == "quickcheck") Seq(
"org.scalacheck" %% "scalacheck" % "1.10.1"
)
else Seq.empty
}
libraryDependencies <++= (currentProject) { c =>
if (c.isEmpty || c == "nodescala" || c == "suggestions") Seq(
"com.netflix.rxjava" % "rxjava-scala" % "0.15.0",
"org.json4s" % "json4s-native_2.10" % "3.2.5",
"org.scala-lang" % "scala-swing" % "2.10.3",
"net.databinder.dispatch" % "dispatch-core_2.10" % "0.11.0",
"org.scala-lang" % "scala-reflect" % "2.10.3",
"org.slf4j" % "slf4j-api" % "1.7.5",
"org.slf4j" % "slf4j-simple" % "1.7.5",
"com.squareup.retrofit" % "retrofit" % "1.0.0",
"org.scala-lang.modules" %% "scala-async" % "0.9.0-M2"
)
else Seq.empty
}
libraryDependencies <++= (currentProject) { c =>
if (c.isEmpty || c == "actorbintree") Seq(
"com.typesafe.akka" %% "akka-actor" % "2.2.3",
"com.typesafe.akka" %% "akka-testkit" % "2.2.3"
)
else Seq.empty
}
// See documentation in ProgFunBuild.scala
projectDetailsMap := {
val currentCourseId = "reactive-001"
Map(
"example" -> ProjectDetails(
packageName = "example",
assignmentPartId = "fTzFogNl",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"recfun" -> ProjectDetails(
packageName = "recfun",
assignmentPartId = "3Rarn9Ki",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"funsets" -> ProjectDetails(
packageName = "funsets",
assignmentPartId = "fBXOL6Rd",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"objsets" -> ProjectDetails(
packageName = "objsets",
assignmentPartId = "05dMMEz7",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"patmat" -> ProjectDetails(
packageName = "patmat",
assignmentPartId = "4gPmpcif",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"forcomp" -> ProjectDetails(
packageName = "forcomp",
assignmentPartId = "fG2oZGIO",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"streams" -> ProjectDetails(
packageName = "streams",
assignmentPartId = "DWKgCFCi",
maxScore = 10d,
styleScoreRatio = 0.2,
courseId=currentCourseId),
"quickcheck" -> ProjectDetails(
packageName = "quickcheck",
assignmentPartId = "02Vi5q7m",
maxScore = 10d,
styleScoreRatio = 0.0,
courseId=currentCourseId),
"simulations" -> ProjectDetails(
packageName = "simulations",
assignmentPartId = "pA3TAeu1",
maxScore = 10d,
styleScoreRatio = 0.0,
courseId=currentCourseId),
"nodescala" -> ProjectDetails(
packageName = "nodescala",
assignmentPartId = "RvoTAbRy",
maxScore = 10d,
styleScoreRatio = 0.0,
courseId=currentCourseId),
"suggestions" -> ProjectDetails(
packageName = "suggestions",
assignmentPartId = "rLLdQLGN",
maxScore = 10d,
styleScoreRatio = 0.0,
courseId=currentCourseId),
"actorbintree" -> ProjectDetails(
packageName = "actorbintree",
assignmentPartId = "VxIlIKoW",
maxScore = 10d,
styleScoreRatio = 0.0,
courseId=currentCourseId)
)}
// Files that we hand out to the students
handoutFiles <<= (baseDirectory, projectDetailsMap, commonSourcePackages) map { (basedir, detailsMap, commonSrcs) =>
(projectName: String) => {
val details = detailsMap.getOrElse(projectName, sys.error("Unknown project name: "+ projectName))
val commonFiles = (PathFinder.empty /: commonSrcs)((files, pkg) =>
files +++ (basedir / "src" / "main" / "scala" / pkg ** "*.scala")
)
(basedir / "src" / "main" / "scala" / details.packageName ** "*.scala") +++
commonFiles +++
(basedir / "src" / "main" / "resources" / details.packageName ** "*") +++
(basedir / "src" / "test" / "scala" / details.packageName ** "*.scala") +++
(basedir / "build.sbt") +++
(basedir / "project" / "build.properties") +++
(basedir / "project" ** ("*.scala" || "*.sbt")) +++
(basedir / "project" / "scalastyle_config.xml") +++
(basedir / "project" / "scalastyle_config_reactive.xml") +++
(basedir / "lib_managed" ** "*.jar") +++
(basedir * (".classpath" || ".project")) +++
(basedir / ".settings" / "org.scala-ide.sdt.core.prefs")
}
}
// This setting allows to restrict the source files that are compiled and tested
// to one specific project. It should be either the empty string, in which case all
// projects are included, or one of the project names from the projectDetailsMap.
currentProject := ""
// Packages in src/main/scala that are used in every project. Included in every
// handout, submission.
commonSourcePackages += "common"
// Packages in src/test/scala that are used for grading projects. Always included
// compiling tests, grading a project.
gradingTestPackages += "grading"

View File

@ -1,55 +0,0 @@
name := "apidoc"
scalaVersion in ThisBuild := "2.11.1"
lazy val core = project
.in(file("core"))
.settings(commonSettings: _*)
.settings(
// play-json needs this to resolve correctly when not using Gilt's internal mirrors
resolvers += "Typesafe Maven Repository" at "http://repo.typesafe.com/typesafe/maven-releases/",
version := "1.0-SNAPSHOT",
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.3.0"
)
)
lazy val api = project
.in(file("api"))
.dependsOn(core)
.aggregate(core)
.enablePlugins(PlayScala)
.settings(commonSettings: _*)
.settings(
version := "1.0-SNAPSHOT",
libraryDependencies ++= Seq(
jdbc,
anorm,
"org.postgresql" % "postgresql" % "9.3-1101-jdbc4",
"org.mindrot" % "jbcrypt" % "0.3m"
)
)
lazy val www = project
.in(file("www"))
.dependsOn(core)
.aggregate(core)
.enablePlugins(PlayScala)
.settings(commonSettings: _*)
.settings(
version := "1.0-SNAPSHOT",
libraryDependencies ++= Seq(
ws
)
)
lazy val commonSettings: Seq[Setting[_]] = Seq(
name <<= name("apidoc-" + _),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.0" % "test"
),
scalacOptions += "-feature"
) ++ instrumentSettings ++ Seq(ScoverageKeys.highlighting := true)

View File

@ -1,40 +0,0 @@
organization := "com.typesafe"
name := "jse"
version := "1.0.1-SNAPSHOT"
scalaVersion := "2.10.4"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.2",
"com.typesafe.akka" %% "akka-contrib" % "2.3.2",
"io.apigee.trireme" % "trireme-core" % "0.8.0",
"io.apigee.trireme" % "trireme-node10src" % "0.8.0",
"io.spray" %% "spray-json" % "1.2.6",
"org.slf4j" % "slf4j-simple" % "1.7.7",
"org.specs2" %% "specs2" % "2.3.11" % "test",
"junit" % "junit" % "4.11" % "test",
"com.typesafe.akka" %% "akka-testkit" % "2.3.2" % "test"
)
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
"Typesafe Releases Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
publishTo := {
val typesafe = "http://private-repo.typesafe.com/typesafe/"
val (name, url) = if (isSnapshot.value)
("sbt-plugin-snapshots", typesafe + "maven-snapshots")
else
("sbt-plugin-releases", typesafe + "maven-releases")
Some(Resolver.url(name, new URL(url)))
}
lazy val root = project in file(".")
lazy val `js-engine-tester` = project.dependsOn(root)
// Somehow required to get a js engine in tests (https://github.com/sbt/sbt/issues/1214)
fork in Test := true

View File

@ -1,19 +0,0 @@
package sbt
package internal
package parser
import java.io.File
import sbt.internal.util.LineRange
import scala.annotation.tailrec
@deprecated("This class is be removed. Only for test backward compatibility", "1.0")
object EvaluateConfigurationsOriginal {
def splitExpressions(file: File, lines: Seq[String]): (Seq[(String, Int)], Seq[(String, LineRange)]) =
{
EvaluateConfigurations.splitExpressions(lines)
}
}

View File

@ -13,55 +13,6 @@ trait SplitExpression {
trait SplitExpressionsBehavior extends SplitExpression {
this: SpecificationLike =>
def oldExpressionsSplitter(implicit splitter: SplitExpressions.SplitExpression): Unit = {
"parse a simple setting" in {
val (imports, settingsAndDefs) = split("""version := "1.0"""")
settingsAndDefs.head._1 === """version := "1.0""""
imports.isEmpty should beTrue
settingsAndDefs.isEmpty should beFalse
}
"parse a config containing a single import" in {
val (imports, settingsAndDefs) = split("""import foo.Bar""")
imports.isEmpty should beFalse
settingsAndDefs.isEmpty should beTrue
}
"parse a config containing two imports and a setting" in {
val (imports, settingsAndDefs) = split(
"""import foo.Bar
import foo.Bar
version := "1.0"
""".stripMargin)
imports.size === 2
settingsAndDefs.size === 1
}
"parse a config containgn a def" in {
val (imports, settingsAndDefs) = split("""def foo(x: Int) = {
x + 1
}""")
imports.isEmpty should beTrue
settingsAndDefs.isEmpty should beFalse
}
"parse a config containgn a val" in {
val (imports, settingsAndDefs) = split("""val answer = 42""")
imports.isEmpty should beTrue
settingsAndDefs.isEmpty should beFalse
}
"parse a config containgn a lazy val" in {
val (imports, settingsAndDefs) = split("""lazy val root = (project in file(".")).enablePlugins­(PlayScala)""")
imports.isEmpty should beTrue
settingsAndDefs.isEmpty should beFalse
}
}
def newExpressionsSplitter(implicit splitter: SplitExpressions.SplitExpression): Unit = {
"parse a two settings without intervening blank line" in {

View File

@ -1,154 +0,0 @@
package sbt
package internal
package parser
import java.io.File
import org.specs2.mutable.Specification
import scala.annotation.tailrec
import scala.io.Source
import scala.tools.reflect.ToolBoxError
import sbt.internal.util.LineRange
class SplitExpressionsFilesTest extends AbstractSplitExpressionsFilesTest("/old-format/")
//class SplitExpressionsFilesFailedTest extends AbstractSplitExpressionsFilesTest("/fail-format/")
abstract class AbstractSplitExpressionsFilesTest(pathName: String) extends Specification {
case class SplitterComparison(oldSplitterResult: scala.util.Try[(Seq[(String, Int)], Seq[LineRange])], newSplitterResult: scala.util.Try[(Seq[(String, Int)], Seq[LineRange])])
val oldSplitter: SplitExpressions.SplitExpression = EvaluateConfigurationsOriginal.splitExpressions
val newSplitter: SplitExpressions.SplitExpression = EvaluateConfigurations.splitExpressions
final val REVERTED_LINES = true
final val START_COMMENT = "/*"
final val END_COMMENT = START_COMMENT.reverse
s"$getClass " should {
"split whole sbt files" in {
val rootPath = getClass.getClassLoader.getResource("").getPath + pathName
println(s"Reading files from: $rootPath")
val allFiles = new File(rootPath).listFiles.toList
val results = for {
path <- allFiles
lines = Source.fromFile(path).getLines().toList
comparison = SplitterComparison(splitLines(path, oldSplitter, lines), splitLines(path, newSplitter, lines))
} yield path -> comparison
printResults(results)
val validResults = results.collect {
case (path, SplitterComparison(scala.util.Success(oldRes), scala.util.Success(newRes))) if oldRes == newRes => path
}
validResults.length must be_==(results.length)
}
}
def removeCommentFromStatement(statement: String, lineRange: LineRange): Option[LineRange] = {
val lines = statement.lines.toList
val optionStatements = removeSlashAsterisk(lines, lineRange, !REVERTED_LINES) match {
case Some((st, lr)) =>
removeDoubleSlash(st, lr)
case _ => None
}
optionStatements.map(t => t._2)
}
@tailrec
private def removeSlashAsterisk(statements: Seq[String], lineRange: LineRange, reverted: Boolean): Option[(Seq[String], LineRange)] =
statements match {
case statement +: _ =>
val openSlashAsteriskIndex = statement.indexOf(START_COMMENT, 0)
if (openSlashAsteriskIndex == -1 || statement.substring(0, openSlashAsteriskIndex).trim.nonEmpty) {
Some((statements, lineRange))
} else {
val closeSlashAsteriskLine = statements.indexWhere(s => s.contains(END_COMMENT))
if (closeSlashAsteriskLine == -1) {
Some((statements, lineRange))
} else {
val newLineRange = if (reverted) {
lineRange.copy(end = lineRange.end - closeSlashAsteriskLine - 1)
} else {
lineRange.copy(start = lineRange.start + closeSlashAsteriskLine + 1)
}
removeSlashAsterisk(statements.drop(closeSlashAsteriskLine + 1), newLineRange, reverted)
}
}
case _ =>
None
}
/**
* Remove // and /* */
* @param statements - lines
* @param lineRange - LineRange
* @return (lines,lineRange) without comments
*/
def removeDoubleSlash(statements: Seq[String], lineRange: LineRange): Option[(Seq[String], LineRange)] = {
@tailrec
def removeDoubleSlashReversed(lines: Seq[String], lineRange: LineRange): Option[(Seq[String], LineRange)] =
lines match {
case statement +: _ =>
val doubleSlashIndex = statement.indexOf("//")
if (doubleSlashIndex == -1 || statement.substring(0, doubleSlashIndex).trim.nonEmpty) {
removeSlashAsterisk(lines, lineRange, REVERTED_LINES) match {
case some @ Some((s, ln)) if ln == lineRange =>
some
case Some((s, ln)) =>
removeDoubleSlashReversed(s, ln)
case _ => None
}
} else {
removeDoubleSlashReversed(lines.tail, lineRange.copy(end = lineRange.end - 1))
}
case _ =>
None
}
removeDoubleSlashReversed(statements.reverse, lineRange).map(t => (t._1.reverse, t._2))
}
def splitLines(file: File, splitter: SplitExpressions.SplitExpression, lines: List[String]): scala.util.Try[(Seq[(String, Int)], Seq[LineRange])] = {
try {
val (imports, settingsAndDefs) = splitter(file, lines)
//TODO: Return actual contents (after making both splitter...
//TODO: ...implementations return CharRanges instead of LineRanges)
val settingsAndDefWithoutComments = settingsAndDefs.flatMap(t => removeCommentFromStatement(t._1, t._2))
scala.util.Success((imports.map(imp => (imp._1.trim, imp._2)), settingsAndDefWithoutComments))
} catch {
case e: ToolBoxError =>
scala.util.Failure(e)
case e: Throwable =>
scala.util.Failure(e)
}
}
def printResults(results: List[(File, SplitterComparison)]) = {
for ((file, comparison) <- results) {
val fileName = file.getName
comparison match {
case SplitterComparison(scala.util.Failure(ex), _) =>
println(s"In file: $fileName, old splitter failed. ${ex.toString}")
case SplitterComparison(_, scala.util.Failure(ex)) =>
println(s"In file: $fileName, new splitter failed. ${ex.toString}")
ex.printStackTrace()
case SplitterComparison(scala.util.Success(resultOld), scala.util.Success(resultNew)) =>
if (resultOld != resultNew) {
println(
s"""In file: $fileName, results differ:
|resultOld:
|$resultOld
|resultNew:
|$resultNew""".stripMargin)
}
}
}
}
}

View File

@ -6,10 +6,6 @@ import org.specs2.mutable.Specification
class SplitExpressionsTest extends Specification with SplitExpressionsBehavior {
"EvaluateConfigurationsOriginal" should oldExpressionsSplitter(EvaluateConfigurationsOriginal.splitExpressions)
"EvaluateConfigurations" should oldExpressionsSplitter(EvaluateConfigurations.splitExpressions)
"EvaluateConfigurations" should newExpressionsSplitter(EvaluateConfigurations.splitExpressions)
}
}