mirror of https://github.com/sbt/sbt.git
Merge pull request #2676 from eed3si9n/wip/scalariform
Check formatting with TravisCI
This commit is contained in:
commit
480a2f3040
|
|
@ -18,6 +18,7 @@ matrix:
|
|||
|
||||
env:
|
||||
matrix:
|
||||
- SBT_CMD=";test:compile;scalariformCheck"
|
||||
- SBT_CMD="mimaReportBinaryIssues"
|
||||
- SBT_CMD="safeUnitTests"
|
||||
- SBT_CMD="otherUnitTests"
|
||||
|
|
@ -47,6 +48,6 @@ notifications:
|
|||
script:
|
||||
- sbt -J-XX:ReservedCodeCacheSize=128m "$SBT_CMD"
|
||||
|
||||
# Tricks to avoid unnecessary cache updates
|
||||
- find $HOME/.sbt -name "*.lock" | xargs rm
|
||||
- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
|
||||
before_cache:
|
||||
- find $HOME/.ivy2 -name "ivydata-*.properties" -print -delete
|
||||
- find $HOME/.sbt -name "*.lock" -print -delete
|
||||
|
|
|
|||
|
|
@ -49,11 +49,36 @@ import Keys._
|
|||
|
||||
// incremental compiler
|
||||
import xsbt.api.Discovery
|
||||
import xsbti.compile.{ Compilers, CompileAnalysis, CompileOptions, CompileOrder,
|
||||
CompileResult, DefinesClass, IncOptionsUtil, Inputs, MiniSetup, PerClasspathEntryLookup,
|
||||
PreviousResult, Setup, TransactionalManagerType }
|
||||
import sbt.internal.inc.{ AnalyzingCompiler, Analysis, CompilerCache, FileValueCache,
|
||||
Locate, LoggerReporter, MixedAnalyzingCompiler, ScalaInstance, ClasspathOptionsUtil }
|
||||
import xsbti.compile.{
|
||||
Compilers,
|
||||
ClasspathOptions,
|
||||
CompileAnalysis,
|
||||
CompileOptions,
|
||||
CompileOrder,
|
||||
CompileResult,
|
||||
DefinesClass,
|
||||
IncOptions,
|
||||
IncOptionsUtil,
|
||||
Inputs,
|
||||
MiniSetup,
|
||||
PerClasspathEntryLookup,
|
||||
PreviousResult,
|
||||
Setup,
|
||||
TransactionalManagerType
|
||||
}
|
||||
import sbt.internal.inc.{
|
||||
AnalyzingCompiler,
|
||||
Analysis,
|
||||
ClassfileManager,
|
||||
CompilerCache,
|
||||
FileValueCache,
|
||||
IncrementalCompilerImpl,
|
||||
Locate,
|
||||
LoggerReporter,
|
||||
MixedAnalyzingCompiler,
|
||||
ScalaInstance,
|
||||
ClasspathOptionsUtil
|
||||
}
|
||||
|
||||
object Defaults extends BuildCommon {
|
||||
final val CacheDirectoryName = "cache"
|
||||
|
|
|
|||
|
|
@ -7,9 +7,23 @@ import java.io.File
|
|||
import java.net.URL
|
||||
import scala.concurrent.duration.{ FiniteDuration, Duration }
|
||||
import Def.ScopedKey
|
||||
import sbt.internal.inc.ScalaInstance
|
||||
import xsbti.compile.{ DefinesClass, ClasspathOptions, CompileAnalysis, CompileOptions, CompileOrder,
|
||||
Compilers, CompileResult, GlobalsCache, IncOptions, Inputs, PreviousResult, Setup }
|
||||
import sbt.internal.util.complete._
|
||||
import sbt.internal.inc.{ MixedAnalyzingCompiler, ScalaInstance }
|
||||
import std.TaskExtra._
|
||||
import xsbti.compile.{
|
||||
DefinesClass,
|
||||
ClasspathOptions,
|
||||
CompileAnalysis,
|
||||
CompileOptions,
|
||||
CompileOrder,
|
||||
Compilers,
|
||||
CompileResult,
|
||||
GlobalsCache,
|
||||
IncOptions,
|
||||
Inputs,
|
||||
PreviousResult,
|
||||
Setup
|
||||
}
|
||||
import scala.xml.{ Node => XNode, NodeSeq }
|
||||
import org.apache.ivy.core.module.{ descriptor, id }
|
||||
import descriptor.ModuleDescriptor, id.ModuleRevisionId
|
||||
|
|
|
|||
|
|
@ -3,9 +3,24 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.{ Act, Aggregation, BuildStructure, BuildUnit, CommandStrings, EvaluateConfigurations,
|
||||
Inspect, IvyConsole, Load, LoadedBuildUnit, Output, PluginsDebug, ProjectNavigation, Script, SessionSettings,
|
||||
SettingCompletions }
|
||||
import sbt.internal.{
|
||||
Act,
|
||||
Aggregation,
|
||||
BuildStructure,
|
||||
BuildUnit,
|
||||
CommandStrings,
|
||||
EvaluateConfigurations,
|
||||
Inspect,
|
||||
IvyConsole,
|
||||
Load,
|
||||
LoadedBuildUnit,
|
||||
Output,
|
||||
PluginsDebug,
|
||||
ProjectNavigation,
|
||||
Script,
|
||||
SessionSettings,
|
||||
SettingCompletions
|
||||
}
|
||||
import sbt.internal.util.{ AttributeKey, AttributeMap, complete, ConsoleOut, GlobalLogging, LineRange, MainLogging, SimpleReader, Types }
|
||||
import sbt.util.{ Level, Logger }
|
||||
|
||||
|
|
@ -465,12 +480,13 @@ object BuiltinCommands {
|
|||
def ignoreMsg = if (Project.isProjectLoaded(s)) "using previously loaded project" else "no project loaded"
|
||||
|
||||
result match {
|
||||
case "" => retry
|
||||
case _ if matches("retry") => retry
|
||||
case _ if matches(Quit) => s.exit(ok = false)
|
||||
case _ if matches("ignore") => s.log.warn(s"Ignoring load failure: $ignoreMsg.") ; s
|
||||
case _ if matches("last") => LastCommand :: loadProjectCommand(LoadFailed, loadArg) :: s
|
||||
case _ => println("Invalid response."); doLoadFailed(s, loadArg)
|
||||
case "" => retry
|
||||
case _ if matches("retry") => retry
|
||||
case _ if matches(Quit) => s.exit(ok = false)
|
||||
case _ if matches("ignore") =>
|
||||
s.log.warn(s"Ignoring load failure: $ignoreMsg."); s
|
||||
case _ if matches("last") => LastCommand :: loadProjectCommand(LoadFailed, loadArg) :: s
|
||||
case _ => println("Invalid response."); doLoadFailed(s, loadArg)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import com.typesafe.sbt.SbtScalariform.{ ScalariformKeys => sr, _ }
|
||||
import sbt.Keys._
|
||||
import com.typesafe.sbt.SbtScalariform._
|
||||
import ScalariformKeys.{ format => scalariformFormat, preferences => scalariformPreferences }
|
||||
|
||||
object Formatting {
|
||||
lazy val BuildConfig = config("build") extend Compile
|
||||
lazy val BuildSbtConfig = config("buildsbt") extend Compile
|
||||
|
||||
val scalariformCheck = taskKey[Unit]("Checks that the existing code is formatted, via git diff")
|
||||
|
||||
lazy val settings: Seq[Setting[_]] = Seq() ++ scalariformSettings ++ prefs
|
||||
lazy val prefs: Seq[Setting[_]] = {
|
||||
import scalariform.formatter.preferences._
|
||||
Seq(
|
||||
sr.preferences := sr.preferences.value.setPreference(AlignSingleLineCaseStatements, true)
|
||||
scalariformPreferences ~= (_.setPreference(AlignSingleLineCaseStatements, true))
|
||||
)
|
||||
}
|
||||
lazy val sbtFilesSettings: Seq[Setting[_]] = Seq() ++ scalariformSettings ++ prefs ++
|
||||
|
|
@ -19,12 +22,16 @@ object Formatting {
|
|||
Seq(
|
||||
scalaSource in BuildConfig := baseDirectory.value / "project",
|
||||
scalaSource in BuildSbtConfig := baseDirectory.value / "project",
|
||||
includeFilter in (BuildConfig, sr.format) := ("*.scala": FileFilter),
|
||||
includeFilter in (BuildSbtConfig, sr.format) := ("*.sbt": FileFilter),
|
||||
sr.format in Compile := {
|
||||
val x = (sr.format in BuildSbtConfig).value
|
||||
val y = (sr.format in BuildConfig).value
|
||||
(sr.format in Compile).value
|
||||
includeFilter in (BuildConfig, scalariformFormat) := ("*.scala": FileFilter),
|
||||
includeFilter in (BuildSbtConfig, scalariformFormat) := ("*.sbt": FileFilter),
|
||||
scalariformFormat in Compile := {
|
||||
val x = (scalariformFormat in BuildSbtConfig).value
|
||||
val y = (scalariformFormat in BuildConfig).value
|
||||
(scalariformFormat in Compile).value
|
||||
},
|
||||
scalariformCheck := {
|
||||
val diff = "git diff".!!
|
||||
if (diff.nonEmpty) sys.error("Working directory is dirty!\n" + diff)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue