Merge pull request #158 from dwijnand/scalafmt

Add back, re-configure & re-enable Scalafmt
This commit is contained in:
Dale Wijnand 2017-08-10 16:05:23 +01:00 committed by GitHub
commit 480a1a366d
16 changed files with 91 additions and 77 deletions

View File

@ -8,11 +8,3 @@ docstrings = JavaDoc
# This also seems more idiomatic to include whitespace in import x.{ yyy } # This also seems more idiomatic to include whitespace in import x.{ yyy }
spaces.inImportCurlyBraces = true spaces.inImportCurlyBraces = true
# This works around sequence wildcard (`_*`) turning into `_ *`
spaces.beforeSeqWildcard = true
# Vertical alignment only => for pattern matching
align.tokens.add = [
{ code = "=>", owner = "Case" }
]

View File

@ -6,9 +6,7 @@ scala:
- 2.12.3 - 2.12.3
script: script:
# drop scalafmt to dogfood latest 1.0.0-RC before there is an sbt 1.0 release of new-sbt-scalafmt - sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M ";++$TRAVIS_SCALA_VERSION;mimaReportBinaryIssues;scalafmt::test;test:scalafmt::test;sbt:scalafmt::test;test"
# - sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M ";++$TRAVIS_SCALA_VERSION;mimaReportBinaryIssues;test;scalafmt::test;test:scalafmt::test"
- sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M ";++$TRAVIS_SCALA_VERSION;mimaReportBinaryIssues;test"
cache: cache:
directories: directories:

View File

@ -18,7 +18,8 @@ def commonSettings: Seq[Setting[_]] = Seq(
scalacOptions := { scalacOptions := {
val old = scalacOptions.value val old = scalacOptions.value
scalaVersion.value match { scalaVersion.value match {
case sv if sv.startsWith("2.10") => old diff List("-Xfuture", "-Ywarn-unused", "-Ywarn-unused-import") case sv if sv.startsWith("2.10") =>
old diff List("-Xfuture", "-Ywarn-unused", "-Ywarn-unused-import")
case sv if sv.startsWith("2.11") => old ++ List("-Ywarn-unused", "-Ywarn-unused-import") case sv if sv.startsWith("2.11") => old ++ List("-Ywarn-unused", "-Ywarn-unused-import")
case _ => old ++ List("-Ywarn-unused", "-Ywarn-unused-import", "-YdisableFlatCpCaching") case _ => old ++ List("-Ywarn-unused", "-Ywarn-unused-import", "-YdisableFlatCpCaching")
} }
@ -39,13 +40,13 @@ lazy val lmRoot = (project in file("."))
Seq( Seq(
homepage := Some(url("https://github.com/sbt/librarymanagement")), homepage := Some(url("https://github.com/sbt/librarymanagement")),
description := "Library management module for sbt", description := "Library management module for sbt",
scmInfo := Some(ScmInfo( scmInfo := {
url("https://github.com/sbt/librarymanagement"), "git@github.com:sbt/librarymanagement.git" val slug = "sbt/librarymanagement"
)), Some(ScmInfo(url(s"https://github.com/$slug"), s"git@github.com:$slug.git"))
},
bintrayPackage := "librarymanagement", bintrayPackage := "librarymanagement",
// scalafmtOnCompile := true, scalafmtOnCompile := true,
// scalafmtVersion 1.0.0-RC3 has regression scalafmtVersion := "1.1.0",
// scalafmtVersion := "0.6.8",
git.baseVersion := baseVersion, git.baseVersion := baseVersion,
version := { version := {
val v = version.value val v = version.value
@ -67,7 +68,8 @@ lazy val lmCore = (project in file("core"))
.settings( .settings(
commonSettings, commonSettings,
name := "librarymanagement-core", name := "librarymanagement-core",
libraryDependencies ++= Seq(jsch, libraryDependencies ++= Seq(
jsch,
scalaReflect.value, scalaReflect.value,
scalaCompiler.value, scalaCompiler.value,
launcherInterface, launcherInterface,
@ -75,13 +77,19 @@ lazy val lmCore = (project in file("core"))
okhttpUrlconnection, okhttpUrlconnection,
sjsonnewScalaJson.value % Optional, sjsonnewScalaJson.value % Optional,
scalaTest, scalaTest,
scalaCheck), scalaCheck
),
libraryDependencies ++= scalaXml.value, libraryDependencies ++= scalaXml.value,
resourceGenerators in Compile += Def.task( resourceGenerators in Compile += Def
.task(
Util.generateVersionFile( Util.generateVersionFile(
version.value, resourceManaged.value, streams.value, (compile in Compile).value version.value,
resourceManaged.value,
streams.value,
(compile in Compile).value
) )
).taskValue, )
.taskValue,
managedSourceDirectories in Compile += managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala", baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
@ -108,7 +116,8 @@ lazy val lmIvy = (project in file("ivy"))
baseDirectory.value / "src" / "main" / "contraband-scala", baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats, contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats,
scalacOptions in (Compile, console) --= Vector("-Ywarn-unused-import", "-Ywarn-unused", "-Xlint"), scalacOptions in (Compile, console) --=
Vector("-Ywarn-unused-import", "-Ywarn-unused", "-Xlint"),
mimaSettings, mimaSettings,
) )

View File

@ -83,8 +83,7 @@ object EvictionWarningOptions {
defaultGuess defaultGuess
) )
lazy val defaultGuess lazy val defaultGuess: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
guessSecondSegment orElse guessSemVer orElse guessFalse guessSecondSegment orElse guessSemVer orElse guessFalse
lazy val guessSecondSegment lazy val guessSecondSegment
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = { : PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {

View File

@ -17,8 +17,7 @@ abstract class InclExclRuleFunctions {
apply(organization.organization) apply(organization.organization)
implicit def stringToExclusionRule(organization: String): InclExclRule = apply(organization) implicit def stringToExclusionRule(organization: String): InclExclRule = apply(organization)
implicit def organizationArtifactNameToExclusionRule( implicit def organizationArtifactNameToExclusionRule(oa: OrganizationArtifactName): InclExclRule =
oa: OrganizationArtifactName): InclExclRule =
InclExclRule(oa.organization, oa.name, "*", Vector.empty, oa.crossVersion) InclExclRule(oa.organization, oa.name, "*", Vector.empty, oa.crossVersion)
implicit def moduleIDToExclusionRule(moduleID: ModuleID): InclExclRule = { implicit def moduleIDToExclusionRule(moduleID: ModuleID): InclExclRule = {

View File

@ -77,8 +77,7 @@ final class MakePomConfiguration private (val file: Option[File],
def withProcess(process: XNode => XNode): MakePomConfiguration = { def withProcess(process: XNode => XNode): MakePomConfiguration = {
copy(process = process) copy(process = process)
} }
def withFilterRepositories( def withFilterRepositories(filterRepositories: MavenRepository => Boolean): MakePomConfiguration = {
filterRepositories: MavenRepository => Boolean): MakePomConfiguration = {
copy(filterRepositories = filterRepositories) copy(filterRepositories = filterRepositories)
} }
def withAllRepositories(allRepositories: Boolean): MakePomConfiguration = { def withAllRepositories(allRepositories: Boolean): MakePomConfiguration = {

View File

@ -145,8 +145,7 @@ object VersionNumber {
case (v1, v2) case (v1, v2)
if (v1.size >= 3) && (v2.size >= 3) => // A normal version number MUST take the form X.Y.Z if (v1.size >= 3) && (v2.size >= 3) => // A normal version number MUST take the form X.Y.Z
(v1._1.get, v1._2.get, v1._3.get, v1.tags, v2._1.get, v2._2.get, v2._3.get, v2.tags) match { (v1._1.get, v1._2.get, v1._3.get, v1.tags, v2._1.get, v2._2.get, v2._3.get, v2.tags) match {
case (x1 @ _, y1 @ _, 0, ts1, x2 @ _, y2 @ _, 0, ts2) case (x1 @ _, y1 @ _, 0, ts1, x2 @ _, y2 @ _, 0, ts2) if ts1.nonEmpty || ts2.nonEmpty =>
if ts1.nonEmpty || ts2.nonEmpty =>
// A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers // A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers
equalsIgnoreExtra(v1, v2) equalsIgnoreExtra(v1, v2)
case (x1, y1, _, _, x2, y2, _, _) => case (x1, y1, _, _, x2, y2, _, _) =>

View File

@ -9,11 +9,7 @@ import java.util.Collections
import org.apache.ivy.core.module.descriptor.DependencyDescriptor import org.apache.ivy.core.module.descriptor.DependencyDescriptor
import org.apache.ivy.core.resolve.ResolveData import org.apache.ivy.core.resolve.ResolveData
import org.apache.ivy.core.settings.IvySettings import org.apache.ivy.core.settings.IvySettings
import org.apache.ivy.plugins.repository.{ import org.apache.ivy.plugins.repository.{ RepositoryCopyProgressListener, Resource, TransferEvent }
RepositoryCopyProgressListener,
Resource,
TransferEvent
}
import org.apache.ivy.plugins.resolver.{ import org.apache.ivy.plugins.resolver.{
BasicResolver, BasicResolver,
DependencyResolver, DependencyResolver,
@ -402,7 +398,8 @@ private[sbt] object ConvertResolver {
case e: java.io.IOException if e.getMessage.contains("destination already exists") => case e: java.io.IOException if e.getMessage.contains("destination already exists") =>
val overwriteWarning = val overwriteWarning =
if (destination contains "-SNAPSHOT") s"Attempting to overwrite $destination" if (destination contains "-SNAPSHOT") s"Attempting to overwrite $destination"
else "Attempting to overwrite $destination (non-SNAPSHOT)\n\tYou need to remove it from the cache manually to take effect." else
"Attempting to overwrite $destination (non-SNAPSHOT)\n\tYou need to remove it from the cache manually to take effect."
import org.apache.ivy.util.Message import org.apache.ivy.util.Message
Message.warn(overwriteWarning) Message.warn(overwriteWarning)
super.put(source, destination, true) super.put(source, destination, true)

View File

@ -344,21 +344,43 @@ final class IvySbt(val configuration: IvyConfiguration) { self =>
// Todo: We just need writing side of this codec. We can clean up the reads. // Todo: We just need writing side of this codec. We can clean up the reads.
private[sbt] object AltLibraryManagementCodec extends IvyLibraryManagementCodec { private[sbt] object AltLibraryManagementCodec extends IvyLibraryManagementCodec {
import sbt.io.Hash import sbt.io.Hash
type InlineIvyHL = (Option[IvyPaths], Vector[Resolver], Vector[Resolver], Vector[ type InlineIvyHL = (
ModuleConfiguration], Vector[String], Boolean) Option[IvyPaths],
Vector[Resolver],
Vector[Resolver],
Vector[ModuleConfiguration],
Vector[String],
Boolean
)
def inlineIvyToHL(i: InlineIvyConfiguration): InlineIvyHL = def inlineIvyToHL(i: InlineIvyConfiguration): InlineIvyHL =
(i.paths, i.resolvers, i.otherResolvers, i.moduleConfigurations, (
i.checksums, i.managedChecksums) i.paths,
i.resolvers,
i.otherResolvers,
i.moduleConfigurations,
i.checksums,
i.managedChecksums
)
type ExternalIvyHL = (Option[PlainFileInfo], Array[Byte]) type ExternalIvyHL = (Option[PlainFileInfo], Array[Byte])
def externalIvyToHL(e: ExternalIvyConfiguration): ExternalIvyHL = def externalIvyToHL(e: ExternalIvyConfiguration): ExternalIvyHL =
(e.baseDirectory.map(FileInfo.exists.apply), (
e.uri.map(Hash.contentsIfLocal).getOrElse(Array.empty)) e.baseDirectory.map(FileInfo.exists.apply),
e.uri.map(Hash.contentsIfLocal).getOrElse(Array.empty)
)
// Redefine to use a subset of properties, that are serialisable // Redefine to use a subset of properties, that are serialisable
override implicit lazy val InlineIvyConfigurationFormat: JsonFormat[InlineIvyConfiguration] = { override implicit lazy val InlineIvyConfigurationFormat
: JsonFormat[InlineIvyConfiguration] = {
def hlToInlineIvy(i: InlineIvyHL): InlineIvyConfiguration = { def hlToInlineIvy(i: InlineIvyHL): InlineIvyConfiguration = {
val (paths, resolvers, otherResolvers, moduleConfigurations, checksums, managedChecksums) = i val (
paths,
resolvers,
otherResolvers,
moduleConfigurations,
checksums,
managedChecksums
) = i
InlineIvyConfiguration() InlineIvyConfiguration()
.withPaths(paths) .withPaths(paths)
.withResolvers(resolvers) .withResolvers(resolvers)

View File

@ -21,10 +21,7 @@ import core.module.descriptor.{
ExcludeRule, ExcludeRule,
IncludeRule IncludeRule
} }
import core.module.descriptor.{ import core.module.descriptor.{ OverrideDependencyDescriptorMediator, DependencyArtifactDescriptor }
OverrideDependencyDescriptorMediator,
DependencyArtifactDescriptor
}
import core.IvyPatternHelper import core.IvyPatternHelper
import org.apache.ivy.util.{ Message, MessageLogger } import org.apache.ivy.util.{ Message, MessageLogger }
import org.apache.ivy.plugins.latest.{ ArtifactInfo => IvyArtifactInfo } import org.apache.ivy.plugins.latest.{ ArtifactInfo => IvyArtifactInfo }

View File

@ -144,8 +144,7 @@ class GigahorseUrlHandler extends AbstractURLHandler {
def upload(source: File, dest0: URL, l: CopyProgressListener): Unit = { def upload(source: File, dest0: URL, l: CopyProgressListener): Unit = {
if (("http" != dest0.getProtocol()) && ("https" != dest0.getProtocol())) { if (("http" != dest0.getProtocol()) && ("https" != dest0.getProtocol())) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException("URL repository only support HTTP PUT at the moment")
"URL repository only support HTTP PUT at the moment")
} }
IvyAuthenticator.install() IvyAuthenticator.install()
@ -203,7 +202,8 @@ object GigahorseUrlHandler {
private[sbt] def urlFactory = { private[sbt] def urlFactory = {
val client0 = http.underlying[OkHttpClient] val client0 = http.underlying[OkHttpClient]
val client = client0.newBuilder() val client = client0
.newBuilder()
.authenticator(new JavaNetAuthenticator) .authenticator(new JavaNetAuthenticator)
.build .build
new OkUrlFactory(client) new OkUrlFactory(client)

View File

@ -97,7 +97,8 @@ class VersionNumberSpec extends UnitSpec {
} }
it should "cascade" in generateCorrectCascadingNumbers( it should "cascade" in generateCorrectCascadingNumbers(
"1.0.0-alpha+001+002", "1.0.0-alpha+001+002",
Seq("1.0.0-alpha+001+002", "1.0.0", "1.0")) Seq("1.0.0-alpha+001+002", "1.0.0", "1.0")
)
"non.space.!?string" should "be parsed" in { "non.space.!?string" should "be parsed" in {
beParsedAs("non.space.!?string", Seq(), Seq(), Seq("non.space.!?string")) beParsedAs("non.space.!?string", Seq(), Seq(), Seq("non.space.!?string"))

View File

@ -47,8 +47,12 @@ object Dependencies {
val scalaXml = scala211Module("scala-xml", "1.0.5") val scalaXml = scala211Module("scala-xml", "1.0.5")
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.1" % Test val scalaTest = "org.scalatest" %% "scalatest" % "3.0.1" % Test
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4" % Test val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4" % Test
val sjsonnew = Def.setting { "com.eed3si9n" %% "sjson-new-core" % contrabandSjsonNewVersion.value } val sjsonnew = Def.setting {
val sjsonnewScalaJson = Def.setting { "com.eed3si9n" %% "sjson-new-scalajson" % contrabandSjsonNewVersion.value } "com.eed3si9n" %% "sjson-new-core" % contrabandSjsonNewVersion.value
}
val sjsonnewScalaJson = Def.setting {
"com.eed3si9n" %% "sjson-new-scalajson" % contrabandSjsonNewVersion.value
}
val gigahorseOkhttp = "com.eed3si9n" %% "gigahorse-okhttp" % "0.3.0" val gigahorseOkhttp = "com.eed3si9n" %% "gigahorse-okhttp" % "0.3.0"
val okhttpUrlconnection = "com.squareup.okhttp3" % "okhttp-urlconnection" % "3.7.0" val okhttpUrlconnection = "com.squareup.okhttp3" % "okhttp-urlconnection" % "3.7.0"

View File

@ -26,8 +26,7 @@ object Util {
val timestamp = formatter.format(new Date) val timestamp = formatter.format(new Date)
val content = versionLine(version) + "\ntimestamp=" + timestamp val content = versionLine(version) + "\ntimestamp=" + timestamp
val f = dir / "xsbt.version.properties" val f = dir / "xsbt.version.properties"
if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version)) {
version)) {
s.log.info("Writing version information to " + f + " :\n" + content) s.log.info("Writing version information to " + f + " :\n" + content)
IO.write(f, content) IO.write(f, content)
} }

View File

@ -1,7 +1,6 @@
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.3") addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.3")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.10")
// addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.3")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.17") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.17")
scalacOptions += "-language:postfixOps" scalacOptions += "-language:postfixOps"