Browse files

If previous-artifact=None, just print a message rather than fail.

Fixes #5.
  • Loading branch information...
1 parent 61b90ad commit 22db058d5e27fdce6fc6464937dd5051935778cb @havocp committed Jun 5, 2012
View
2 sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/Keys.scala
@@ -7,7 +7,7 @@ object MimaKeys {
val failOnProblem = SettingKey[Boolean]("mima-fail-on-problem", "if true, fail the build on binary incompatibility detection.")
val previousArtifact = SettingKey[Option[ModuleID]]("mima-previous-artifact", "Previous released artifact used to test binary compatibility.")
- val previousClassfiles = TaskKey[File]("mima-previous-classfiles", "Directory or jar containing the previous class files used to test compatibility.")
+ val previousClassfiles = TaskKey[Option[File]]("mima-previous-classfiles", "Directory or jar containing the previous class files used to test compatibility.")
val currentClassfiles = TaskKey[File]("mima-current-classfiles", "Directory or jar containing the current class files used to test compatibility.")
// TODO - Create a task to make a MiMaLib, is that a good idea?
val findBinaryIssues = TaskKey[List[core.Problem]]("mima-find-binary-issues", "A list of all binary incompatibilities between two files.")
View
17 sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala
@@ -2,16 +2,24 @@ package com.typesafe.tools.mima
package plugin
import sbt._
-import sbt.Keys.{fullClasspath, streams, classDirectory, ivySbt}
+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
- ) map SbtMima.runMima,
+ 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) map SbtMima.reportErrors
)
/** Setup mima with default settings, applicable for most projects. */
@@ -20,8 +28,7 @@ object MimaPlugin extends Plugin {
previousArtifact := None,
currentClassfiles <<= classDirectory in Compile map identity,
previousClassfiles <<= (ivySbt, previousArtifact, streams) map { (i, optArt, s) =>
- val art = optArt getOrElse sys.error("No previous-artifact defined. Cannot check binary compatibility.")
- SbtMima.getPreviousArtifact(art, i, s)
+ optArt map { art => SbtMima.getPreviousArtifact(art, i, s) }
},
fullClasspath in findBinaryIssues <<= fullClasspath in Compile
) ++ mimaReportSettings

0 comments on commit 22db058

Please sign in to comment.