Add sbt-houserules, formatting

This commit is contained in:
Martin Duhem 2015-08-31 15:54:43 +02:00
parent 9a42d645e9
commit dc814a5154
13 changed files with 155 additions and 159 deletions

View File

@ -23,7 +23,7 @@ import sbt.librarymanagement._
final class DeliverConfiguration(val deliverIvyPattern: String, val status: String, val configurations: Option[Seq[Configuration]], val logging: UpdateLogging.Value)
final class PublishConfiguration(val ivyFile: Option[File], val resolverName: String, val artifacts: Map[Artifact, File], val checksums: Seq[String], val logging: UpdateLogging.Value,
val overwrite: Boolean) {
val overwrite: Boolean) {
def this(ivyFile: Option[File], resolverName: String, artifacts: Map[Artifact, File], checksums: Seq[String], logging: UpdateLogging.Value) =
this(ivyFile, resolverName, artifacts, checksums, logging, false)
}
@ -379,9 +379,9 @@ object IvyActions {
}
}
final class ResolveException(
val messages: Seq[String],
val failed: Seq[ModuleID],
val failedPaths: Map[ModuleID, Seq[ModuleID]]) extends RuntimeException(messages.mkString("\n")) {
val messages: Seq[String],
val failed: Seq[ModuleID],
val failedPaths: Map[ModuleID, Seq[ModuleID]]) extends RuntimeException(messages.mkString("\n")) {
def this(messages: Seq[String], failed: Seq[ModuleID]) =
this(messages, failed, Map(failed map { m => m -> Nil }: _*))
}

View File

@ -17,7 +17,7 @@ import sbt.util.Logger
import sbt.librarymanagement._
class NotInCache(val id: ModuleID, cause: Throwable)
extends RuntimeException(NotInCache(id, cause), cause) {
extends RuntimeException(NotInCache(id, cause), cause) {
def this(id: ModuleID) = this(id, null)
}
private object NotInCache {

View File

@ -372,8 +372,7 @@ class MakePom(val log: Logger) {
<exclusion>
<groupId>{ g }</groupId>
<artifactId>{ a }</artifactId>
</exclusion>
)
</exclusion>)
}
def makeRepositories(settings: IvySettings, includeAll: Boolean, filterRepositories: MavenRepository => Boolean) =

View File

@ -4,11 +4,11 @@ import impl.{ GroupID, GroupArtifactID }
import sbt.librarymanagement._
final class SbtExclusionRule(
val organization: String,
val name: String,
val artifact: String,
val configurations: Seq[String],
val crossVersion: CrossVersion) {
val organization: String,
val name: String,
val artifact: String,
val configurations: Seq[String],
val crossVersion: CrossVersion) {
def copy(organization: String = this.organization,
name: String = this.name,

View File

@ -1,72 +1,73 @@
package sbt.internal.librarymanagement
package cross
object CrossVersionUtil
{
val trueString = "true"
val falseString = "false"
val fullString = "full"
val noneString = "none"
val disabledString = "disabled"
val binaryString = "binary"
val TransitionScalaVersion = "2.10"
val TransitionSbtVersion = "0.12"
object CrossVersionUtil {
val trueString = "true"
val falseString = "false"
val fullString = "full"
val noneString = "none"
val disabledString = "disabled"
val binaryString = "binary"
val TransitionScalaVersion = "2.10"
val TransitionSbtVersion = "0.12"
def isFull(s: String): Boolean = (s == trueString) || (s == fullString)
def isDisabled(s: String): Boolean = (s == falseString) || (s == noneString) || (s == disabledString)
def isBinary(s: String): Boolean = (s == binaryString)
def isFull(s: String): Boolean = (s == trueString) || (s == fullString)
def isDisabled(s: String): Boolean = (s == falseString) || (s == noneString) || (s == disabledString)
def isBinary(s: String): Boolean = (s == binaryString)
private[sbt] def isSbtApiCompatible(v: String): Boolean = sbtApiVersion(v).isDefined
/** Returns sbt binary interface x.y API compatible with the given version string v.
* RCs for x.y.0 are considered API compatible.
* Compatibile versions include 0.12.0-1 and 0.12.0-RC1 for Some(0, 12).
*/
private[sbt] def sbtApiVersion(v: String): Option[(Int, Int)] =
{
val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
val CandidateV = """(\d+)\.(\d+)\.(\d+)(-RC\d+)""".r
val NonReleaseV = """(\d+)\.(\d+)\.(\d+)([-\w+]*)""".r
v match {
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
case _ => None
}
}
private[sbt] def isScalaApiCompatible(v: String): Boolean = scalaApiVersion(v).isDefined
/** Returns Scala binary interface x.y API compatible with the given version string v.
* Compatibile versions include 2.10.0-1 and 2.10.1-M1 for Some(2, 10), but not 2.10.0-RC1.
*/
private[sbt] def scalaApiVersion(v: String): Option[(Int, Int)] =
{
val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
val BinCompatV = """(\d+)\.(\d+)\.(\d+)-bin(-.*)?""".r
val NonReleaseV = """(\d+)\.(\d+)\.(\d+)(-\w+)""".r
v match {
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
case BinCompatV(x, y, z, ht) => Some((x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
case _ => None
}
}
private[sbt] val PartialVersion = """(\d+)\.(\d+)(?:\..+)?""".r
private[sbt] def partialVersion(s: String): Option[(Int,Int)] =
s match {
case PartialVersion(major, minor) => Some((major.toInt, minor.toInt))
case _ => None
}
def binaryScalaVersion(full: String): String = binaryVersionWithApi(full, TransitionScalaVersion)(scalaApiVersion)
def binarySbtVersion(full: String): String = binaryVersionWithApi(full, TransitionSbtVersion)(sbtApiVersion)
private[sbt] def binaryVersion(full: String, cutoff: String): String = binaryVersionWithApi(full, cutoff)(scalaApiVersion)
private[this] def isNewer(major: Int, minor: Int, minMajor: Int, minMinor: Int): Boolean =
major > minMajor || (major == minMajor && minor >= minMinor)
private[this] def binaryVersionWithApi(full: String, cutoff: String)(apiVersion: String => Option[(Int,Int)]): String =
{
def sub(major: Int, minor: Int) = major + "." + minor
(apiVersion(full), partialVersion(cutoff)) match {
case (Some((major, minor)), None) => sub(major, minor)
case (Some((major, minor)), Some((minMajor, minMinor))) if isNewer(major, minor, minMajor, minMinor) => sub(major, minor)
case _ => full
}
}
private[sbt] def isSbtApiCompatible(v: String): Boolean = sbtApiVersion(v).isDefined
/**
* Returns sbt binary interface x.y API compatible with the given version string v.
* RCs for x.y.0 are considered API compatible.
* Compatibile versions include 0.12.0-1 and 0.12.0-RC1 for Some(0, 12).
*/
private[sbt] def sbtApiVersion(v: String): Option[(Int, Int)] =
{
val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
val CandidateV = """(\d+)\.(\d+)\.(\d+)(-RC\d+)""".r
val NonReleaseV = """(\d+)\.(\d+)\.(\d+)([-\w+]*)""".r
v match {
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
case _ => None
}
}
private[sbt] def isScalaApiCompatible(v: String): Boolean = scalaApiVersion(v).isDefined
/**
* Returns Scala binary interface x.y API compatible with the given version string v.
* Compatibile versions include 2.10.0-1 and 2.10.1-M1 for Some(2, 10), but not 2.10.0-RC1.
*/
private[sbt] def scalaApiVersion(v: String): Option[(Int, Int)] =
{
val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
val BinCompatV = """(\d+)\.(\d+)\.(\d+)-bin(-.*)?""".r
val NonReleaseV = """(\d+)\.(\d+)\.(\d+)(-\w+)""".r
v match {
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
case BinCompatV(x, y, z, ht) => Some((x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
case _ => None
}
}
private[sbt] val PartialVersion = """(\d+)\.(\d+)(?:\..+)?""".r
private[sbt] def partialVersion(s: String): Option[(Int, Int)] =
s match {
case PartialVersion(major, minor) => Some((major.toInt, minor.toInt))
case _ => None
}
def binaryScalaVersion(full: String): String = binaryVersionWithApi(full, TransitionScalaVersion)(scalaApiVersion)
def binarySbtVersion(full: String): String = binaryVersionWithApi(full, TransitionSbtVersion)(sbtApiVersion)
private[sbt] def binaryVersion(full: String, cutoff: String): String = binaryVersionWithApi(full, cutoff)(scalaApiVersion)
private[this] def isNewer(major: Int, minor: Int, minMajor: Int, minMinor: Int): Boolean =
major > minMajor || (major == minMajor && minor >= minMinor)
private[this] def binaryVersionWithApi(full: String, cutoff: String)(apiVersion: String => Option[(Int, Int)]): String =
{
def sub(major: Int, minor: Int) = major + "." + minor
(apiVersion(full), partialVersion(cutoff)) match {
case (Some((major, minor)), None) => sub(major, minor)
case (Some((major, minor)), Some((minMajor, minMinor))) if isNewer(major, minor, minMajor, minMinor) => sub(major, minor)
case _ => full
}
}
}

View File

@ -42,9 +42,9 @@ final class GroupID private[sbt] (private[sbt] val groupID: String) {
private[this] def deprecationMessage = """Use the cross method on the constructed ModuleID. For example: ("a" % "b" % "1").cross(...)"""
}
final class GroupArtifactID private[sbt] (
private[sbt] val groupID: String,
private[sbt] val artifactID: String,
private[sbt] val crossVersion: CrossVersion) {
private[sbt] val groupID: String,
private[sbt] val artifactID: String,
private[sbt] val crossVersion: CrossVersion) {
def %(revision: String): ModuleID =
{
nonEmpty(revision, "Revision")

View File

@ -19,11 +19,11 @@ import sbt.util.Logger
import sbt.librarymanagement._
private[sbt] case class SbtChainResolver(
name: String,
resolvers: Seq[DependencyResolver],
settings: IvySettings,
updateOptions: UpdateOptions,
log: Logger) extends ChainResolver {
name: String,
resolvers: Seq[DependencyResolver],
settings: IvySettings,
updateOptions: UpdateOptions,
log: Logger) extends ChainResolver {
override def equals(o: Any): Boolean = o match {
case o: SbtChainResolver =>
@ -139,8 +139,7 @@ private[sbt] case class SbtChainResolver(
else if (useLatest) temp map { x =>
(reparseModuleDescriptor(dd, data, resolver, x), resolver)
}
else temp map { x => (forcedRevision(x), resolver) }
)
else temp map { x => (forcedRevision(x), resolver) })
} catch {
case ex: Exception =>
Message.verbose("problem occurred while resolving " + dd + " with " + resolver

View File

@ -8,13 +8,13 @@ import sbt.internal.util.ShowLines
import sbt.internal.librarymanagement.{ IvySbt, InlineConfiguration, InlineConfigurationWithExcludes }
final class EvictionWarningOptions private[sbt] (
val configurations: Seq[Configuration],
val warnScalaVersionEviction: Boolean,
val warnDirectEvictions: Boolean,
val warnTransitiveEvictions: Boolean,
val infoAllEvictions: Boolean,
val showCallers: Boolean,
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean]) {
val configurations: Seq[Configuration],
val warnScalaVersionEviction: Boolean,
val warnDirectEvictions: Boolean,
val warnTransitiveEvictions: Boolean,
val infoAllEvictions: Boolean,
val showCallers: Boolean,
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean]) {
private[sbt] def configStrings = configurations map { _.name }
def withConfigurations(configurations: Seq[Configuration]): EvictionWarningOptions =
@ -80,12 +80,12 @@ object EvictionWarningOptions {
}
final class EvictionPair private[sbt] (
val organization: String,
val name: String,
val winner: Option[ModuleReport],
val evicteds: Seq[ModuleReport],
val includesDirect: Boolean,
val showCallers: Boolean) {
val organization: String,
val name: String,
val winner: Option[ModuleReport],
val evicteds: Seq[ModuleReport],
val includesDirect: Boolean,
val showCallers: Boolean) {
override def toString: String =
EvictionPair.evictionPairLines.showLines(this).mkString
override def equals(o: Any): Boolean = o match {
@ -121,11 +121,11 @@ object EvictionPair {
}
final class EvictionWarning private[sbt] (
val options: EvictionWarningOptions,
val scalaEvictions: Seq[EvictionPair],
val directEvictions: Seq[EvictionPair],
val transitiveEvictions: Seq[EvictionPair],
val allEvictions: Seq[EvictionPair]) {
val options: EvictionWarningOptions,
val scalaEvictions: Seq[EvictionPair],
val directEvictions: Seq[EvictionPair],
val transitiveEvictions: Seq[EvictionPair],
val allEvictions: Seq[EvictionPair]) {
def reportedEvictions: Seq[EvictionPair] = scalaEvictions ++ directEvictions ++ transitiveEvictions
private[sbt] def infoAllTheThings: List[String] = EvictionWarning.infoAllTheThings(this)
}

View File

@ -21,8 +21,7 @@ object ScalaArtifacts {
private[sbt] def toolDependencies(org: String, version: String): Seq[ModuleID] = Seq(
scalaToolDependency(org, ScalaArtifacts.CompilerID, version),
scalaToolDependency(org, ScalaArtifacts.LibraryID, version)
)
scalaToolDependency(org, ScalaArtifacts.LibraryID, version))
private[this] def scalaToolDependency(org: String, id: String, version: String): ModuleID =
ModuleID(org, id, version, Some(Configurations.ScalaTool.name + "->default,optional(default)"))
}

View File

@ -13,16 +13,16 @@ import sbt.util.Logger
* See also UpdateConfiguration in IvyActions.scala.
*/
final class UpdateOptions private[sbt] (
/** If set to CircularDependencyLevel.Error, halt the dependency resolution. */
val circularDependencyLevel: CircularDependencyLevel,
/** If set to true, check all resolvers for snapshots. */
val latestSnapshots: Boolean,
/** If set to true, use consolidated resolution. */
val consolidatedResolution: Boolean,
/** If set to true, use cached resolution. */
val cachedResolution: Boolean,
/** Extention point for an alternative resolver converter. */
val resolverConverter: UpdateOptions.ResolverConverter) {
/** If set to CircularDependencyLevel.Error, halt the dependency resolution. */
val circularDependencyLevel: CircularDependencyLevel,
/** If set to true, check all resolvers for snapshots. */
val latestSnapshots: Boolean,
/** If set to true, use consolidated resolution. */
val consolidatedResolution: Boolean,
/** If set to true, use cached resolution. */
val cachedResolution: Boolean,
/** Extention point for an alternative resolver converter. */
val resolverConverter: UpdateOptions.ResolverConverter) {
def withCircularDependencyLevel(circularDependencyLevel: CircularDependencyLevel): UpdateOptions =
copy(circularDependencyLevel = circularDependencyLevel)
def withLatestSnapshots(latestSnapshots: Boolean): UpdateOptions =

View File

@ -17,10 +17,10 @@ import sbt.internal.librarymanagement.{ DependencyFilter, ConfigurationFilter, M
* @param evicted a sequence of evicted modules
*/
final class ConfigurationReport(
val configuration: String,
val modules: Seq[ModuleReport],
val details: Seq[OrganizationArtifactReport],
@deprecated("Use details instead to get better eviction info.", "0.13.6") val evicted: Seq[ModuleID]) {
val configuration: String,
val modules: Seq[ModuleReport],
val details: Seq[OrganizationArtifactReport],
@deprecated("Use details instead to get better eviction info.", "0.13.6") val evicted: Seq[ModuleID]) {
def this(configuration: String, modules: Seq[ModuleReport], evicted: Seq[ModuleID]) =
this(configuration, modules, Nil, evicted)
@ -54,9 +54,9 @@ object ConfigurationReport {
* which can be used to calculate detailed evction warning etc.
*/
final class OrganizationArtifactReport private[sbt] (
val organization: String,
val name: String,
val modules: Seq[ModuleReport]) {
val organization: String,
val name: String,
val modules: Seq[ModuleReport]) {
override def toString: String = {
val details = modules map { _.detailReport }
s"\t$organization:$name\n${details.mkString}\n"
@ -77,24 +77,24 @@ object OrganizationArtifactReport {
* @param missingArtifacts the missing artifacts for this module.
*/
final class ModuleReport(
val module: ModuleID,
val artifacts: Seq[(Artifact, File)],
val missingArtifacts: Seq[Artifact],
val status: Option[String],
val publicationDate: Option[ju.Date],
val resolver: Option[String],
val artifactResolver: Option[String],
val evicted: Boolean,
val evictedData: Option[String],
val evictedReason: Option[String],
val problem: Option[String],
val homepage: Option[String],
val extraAttributes: Map[String, String],
val isDefault: Option[Boolean],
val branch: Option[String],
val configurations: Seq[String],
val licenses: Seq[(String, Option[String])],
val callers: Seq[Caller]) {
val module: ModuleID,
val artifacts: Seq[(Artifact, File)],
val missingArtifacts: Seq[Artifact],
val status: Option[String],
val publicationDate: Option[ju.Date],
val resolver: Option[String],
val artifactResolver: Option[String],
val evicted: Boolean,
val evictedData: Option[String],
val evictedReason: Option[String],
val problem: Option[String],
val homepage: Option[String],
val extraAttributes: Map[String, String],
val isDefault: Option[Boolean],
val branch: Option[String],
val configurations: Seq[String],
val licenses: Seq[(String, Option[String])],
val callers: Seq[Caller]) {
private[this] lazy val arts: Seq[String] = artifacts.map(_.toString) ++ missingArtifacts.map(art => "(MISSING) " + art)
override def toString: String = {
@ -164,13 +164,13 @@ object ModuleReport {
}
final class Caller(
val caller: ModuleID,
val callerConfigurations: Seq[String],
val callerExtraAttributes: Map[String, String],
val isForceDependency: Boolean,
val isChangingDependency: Boolean,
val isTransitiveDependency: Boolean,
val isDirectlyForceDependency: Boolean) {
val caller: ModuleID,
val callerConfigurations: Seq[String],
val callerExtraAttributes: Map[String, String],
val isForceDependency: Boolean,
val isChangingDependency: Boolean,
val isTransitiveDependency: Boolean,
val isDirectlyForceDependency: Boolean) {
override def toString: String =
s"$caller"
}
@ -248,16 +248,14 @@ object UpdateReport {
moduleReportMap { (configuration, modReport) =>
modReport.copy(
artifacts = modReport.artifacts filter { case (art, file) => f(configuration, modReport.module, art) },
missingArtifacts = modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) }
)
missingArtifacts = modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) })
}
def substitute(f: (String, ModuleID, Seq[(Artifact, File)]) => Seq[(Artifact, File)]): UpdateReport =
moduleReportMap { (configuration, modReport) =>
val newArtifacts = f(configuration, modReport.module, modReport.artifacts)
modReport.copy(
artifacts = f(configuration, modReport.module, modReport.artifacts),
missingArtifacts = Nil
)
missingArtifacts = Nil)
}
def toSeq: Seq[(String, ModuleID, Artifact, File)] =
@ -269,8 +267,7 @@ object UpdateReport {
def addMissing(f: ModuleID => Seq[Artifact]): UpdateReport =
moduleReportMap { (configuration, modReport) =>
modReport.copy(
missingArtifacts = (modReport.missingArtifacts ++ f(modReport.module)).distinct
)
missingArtifacts = (modReport.missingArtifacts ++ f(modReport.module)).distinct)
}
def moduleReportMap(f: (String, ModuleReport) => ModuleReport): UpdateReport =

View File

@ -1,9 +1,9 @@
package sbt.librarymanagement
final class VersionNumber private[sbt] (
val numbers: Seq[Long],
val tags: Seq[String],
val extras: Seq[String]) {
val numbers: Seq[Long],
val tags: Seq[String],
val extras: Seq[String]) {
def _1: Option[Long] = get(0)
def _2: Option[Long] = get(1)
def _3: Option[Long] = get(2)

1
project/house.sbt Normal file
View File

@ -0,0 +1 @@
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.1.0")