Skip to content

Commit

Permalink
Scalariform the sbt plugin to make formatting consistent
Browse files Browse the repository at this point in the history
Otherwise can't edit in Eclipse without creating bogus diff
  • Loading branch information
havocp committed Jun 5, 2012
1 parent 07d9aba commit 73e2cbb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ package com.typesafe.tools.mima
package plugin

import sbt._
import sbt.Keys.{fullClasspath, streams, classDirectory, ivySbt, name}
import sbt.Keys.{ fullClasspath, streams, classDirectory, ivySbt, name }

/** Sbt plugin for using MiMa. */
object MimaPlugin extends Plugin {
import MimaKeys._
/** Just configures MiMa to compare previous/current classfiles.*/
def mimaReportSettings: Seq[Setting[_]] = Seq(
findBinaryIssues <<= (previousClassfiles, currentClassfiles,
fullClasspath in findBinaryIssues, streams, name
) map { (prevOption, curr, cp, s, name) =>
prevOption match {
case Some(prev) =>
SbtMima.runMima(prev, curr, cp, s)
case None =>
s.log.info(name + ": previous-artifact not set, not analyzing binary compatibility")
Nil
}
},
reportBinaryIssues <<= (findBinaryIssues, failOnProblem, streams, name) map SbtMima.reportErrors
)
fullClasspath in findBinaryIssues, streams, name) map { (prevOption, curr, cp, s, name) =>
prevOption match {
case Some(prev) =>
SbtMima.runMima(prev, curr, cp, s)
case None =>
s.log.info(name + ": previous-artifact not set, not analyzing binary compatibility")
Nil
}
},
reportBinaryIssues <<= (findBinaryIssues, failOnProblem, streams, name) map SbtMima.reportErrors)
/** Setup mima with default settings, applicable for most projects. */
def mimaDefaultSettings: Seq[Setting[_]] = Seq(
failOnProblem := true,
Expand All @@ -30,6 +28,5 @@ object MimaPlugin extends Plugin {
previousClassfiles <<= (ivySbt, previousArtifact, streams) map { (i, optArt, s) =>
optArt map { art => SbtMima.getPreviousArtifact(art, i, s) }
},
fullClasspath in findBinaryIssues <<= fullClasspath in Compile
) ++ mimaReportSettings
fullClasspath in findBinaryIssues <<= fullClasspath in Compile) ++ mimaReportSettings
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,34 @@ object SbtMima {
makeMima(cp, s).collectProblems(prev.getAbsolutePath, curr.getAbsolutePath)

/** Reports binary compatibility errors.
* @param failOnProblem if true, fails the build on binary compatibility errors.
* @param failOnProblem if true, fails the build on binary compatibility errors.
*/
def reportErrors(errors: List[core.Problem], failOnProblem: Boolean, s: TaskStreams, projectName: String): Unit = {
// TODO - Line wrapping an other magikz
def prettyPrint(p: core.Problem): String = " * " + p.description
s.log.info(projectName + ": found " + errors.size + " potential binary incompatibilities")
errors map prettyPrint foreach { p =>
if(failOnProblem) s.log.error(p)
else s.log.warn(p)
if (failOnProblem) s.log.error(p)
else s.log.warn(p)
}
if(failOnProblem && !errors.isEmpty) sys.error(projectName + ": Binary compatibility check failed!")
if (failOnProblem && !errors.isEmpty) sys.error(projectName + ": Binary compatibility check failed!")
}
/** Resolves an artifact representing the previous abstract binary interface
* for testing.
* for testing.
*/
def getPreviousArtifact(m: ModuleID, ivy: IvySbt, s: TaskStreams): File = {
val moduleSettings = InlineConfiguration(
"dummy" % "test" % "version",
ModuleInfo("dummy-test-project-for-resolving"),
dependencies = Seq(m)
)
dependencies = Seq(m))
val module = new ivy.Module(moduleSettings)
val report = IvyActions.update(
module,
new UpdateConfiguration(
retrieve = None,
missingOk = false,
logging = UpdateLogging.DownloadOnly),
s.log
)
retrieve = None,
missingOk = false,
logging = UpdateLogging.DownloadOnly),
s.log)
val optFile = (for {
config <- report.configurations
module <- config.modules
Expand Down

0 comments on commit 73e2cbb

Please sign in to comment.