mirror of https://github.com/sbt/sbt.git
Merge pull request #158 from dwijnand/scalafmt
Add back, re-configure & re-enable Scalafmt
This commit is contained in:
commit
480a1a366d
|
|
@ -8,11 +8,3 @@ docstrings = JavaDoc
|
|||
|
||||
# This also seems more idiomatic to include whitespace in import x.{ yyy }
|
||||
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" }
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ scala:
|
|||
- 2.12.3
|
||||
|
||||
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;test;scalafmt::test;test:scalafmt::test"
|
||||
- sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M ";++$TRAVIS_SCALA_VERSION;mimaReportBinaryIssues;test"
|
||||
- sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M ";++$TRAVIS_SCALA_VERSION;mimaReportBinaryIssues;scalafmt::test;test:scalafmt::test;sbt:scalafmt::test;test"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
|
|||
51
build.sbt
51
build.sbt
|
|
@ -18,7 +18,8 @@ def commonSettings: Seq[Setting[_]] = Seq(
|
|||
scalacOptions := {
|
||||
val old = scalacOptions.value
|
||||
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 _ => old ++ List("-Ywarn-unused", "-Ywarn-unused-import", "-YdisableFlatCpCaching")
|
||||
}
|
||||
|
|
@ -39,13 +40,13 @@ lazy val lmRoot = (project in file("."))
|
|||
Seq(
|
||||
homepage := Some(url("https://github.com/sbt/librarymanagement")),
|
||||
description := "Library management module for sbt",
|
||||
scmInfo := Some(ScmInfo(
|
||||
url("https://github.com/sbt/librarymanagement"), "git@github.com:sbt/librarymanagement.git"
|
||||
)),
|
||||
scmInfo := {
|
||||
val slug = "sbt/librarymanagement"
|
||||
Some(ScmInfo(url(s"https://github.com/$slug"), s"git@github.com:$slug.git"))
|
||||
},
|
||||
bintrayPackage := "librarymanagement",
|
||||
// scalafmtOnCompile := true,
|
||||
// scalafmtVersion 1.0.0-RC3 has regression
|
||||
// scalafmtVersion := "0.6.8",
|
||||
scalafmtOnCompile := true,
|
||||
scalafmtVersion := "1.1.0",
|
||||
git.baseVersion := baseVersion,
|
||||
version := {
|
||||
val v = version.value
|
||||
|
|
@ -67,21 +68,28 @@ lazy val lmCore = (project in file("core"))
|
|||
.settings(
|
||||
commonSettings,
|
||||
name := "librarymanagement-core",
|
||||
libraryDependencies ++= Seq(jsch,
|
||||
scalaReflect.value,
|
||||
scalaCompiler.value,
|
||||
launcherInterface,
|
||||
gigahorseOkhttp,
|
||||
okhttpUrlconnection,
|
||||
sjsonnewScalaJson.value % Optional,
|
||||
scalaTest,
|
||||
scalaCheck),
|
||||
libraryDependencies ++= Seq(
|
||||
jsch,
|
||||
scalaReflect.value,
|
||||
scalaCompiler.value,
|
||||
launcherInterface,
|
||||
gigahorseOkhttp,
|
||||
okhttpUrlconnection,
|
||||
sjsonnewScalaJson.value % Optional,
|
||||
scalaTest,
|
||||
scalaCheck
|
||||
),
|
||||
libraryDependencies ++= scalaXml.value,
|
||||
resourceGenerators in Compile += Def.task(
|
||||
Util.generateVersionFile(
|
||||
version.value, resourceManaged.value, streams.value, (compile in Compile).value
|
||||
resourceGenerators in Compile += Def
|
||||
.task(
|
||||
Util.generateVersionFile(
|
||||
version.value,
|
||||
resourceManaged.value,
|
||||
streams.value,
|
||||
(compile in Compile).value
|
||||
)
|
||||
)
|
||||
).taskValue,
|
||||
.taskValue,
|
||||
managedSourceDirectories in Compile +=
|
||||
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",
|
||||
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ object CrossVersionUtil {
|
|||
Some(sbtApiVersion(x.toLong, y.toLong))
|
||||
case NonReleaseV_n(x, y, z, _) if x.toLong > 0 && (y.toLong > 0 || z.toLong > 0) =>
|
||||
Some(sbtApiVersion(x.toLong, y.toLong))
|
||||
case _ => None
|
||||
case _ => None
|
||||
}
|
||||
|
||||
private def sbtApiVersion(x: Long, y: Long) = {
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ object EvictionWarningOptions {
|
|||
defaultGuess
|
||||
)
|
||||
|
||||
lazy val defaultGuess
|
||||
: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||
lazy val defaultGuess: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||
guessSecondSegment orElse guessSemVer orElse guessFalse
|
||||
lazy val guessSecondSegment
|
||||
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ abstract class InclExclRuleFunctions {
|
|||
apply(organization.organization)
|
||||
implicit def stringToExclusionRule(organization: String): InclExclRule = apply(organization)
|
||||
|
||||
implicit def organizationArtifactNameToExclusionRule(
|
||||
oa: OrganizationArtifactName): InclExclRule =
|
||||
implicit def organizationArtifactNameToExclusionRule(oa: OrganizationArtifactName): InclExclRule =
|
||||
InclExclRule(oa.organization, oa.name, "*", Vector.empty, oa.crossVersion)
|
||||
|
||||
implicit def moduleIDToExclusionRule(moduleID: ModuleID): InclExclRule = {
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ final class MakePomConfiguration private (val file: Option[File],
|
|||
def withProcess(process: XNode => XNode): MakePomConfiguration = {
|
||||
copy(process = process)
|
||||
}
|
||||
def withFilterRepositories(
|
||||
filterRepositories: MavenRepository => Boolean): MakePomConfiguration = {
|
||||
def withFilterRepositories(filterRepositories: MavenRepository => Boolean): MakePomConfiguration = {
|
||||
copy(filterRepositories = filterRepositories)
|
||||
}
|
||||
def withAllRepositories(allRepositories: Boolean): MakePomConfiguration = {
|
||||
|
|
|
|||
|
|
@ -145,8 +145,7 @@ object VersionNumber {
|
|||
case (v1, v2)
|
||||
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 {
|
||||
case (x1 @ _, y1 @ _, 0, ts1, x2 @ _, y2 @ _, 0, ts2)
|
||||
if ts1.nonEmpty || ts2.nonEmpty =>
|
||||
case (x1 @ _, y1 @ _, 0, ts1, x2 @ _, y2 @ _, 0, ts2) if ts1.nonEmpty || ts2.nonEmpty =>
|
||||
// A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers
|
||||
equalsIgnoreExtra(v1, v2)
|
||||
case (x1, y1, _, _, x2, y2, _, _) =>
|
||||
|
|
|
|||
|
|
@ -9,11 +9,7 @@ import java.util.Collections
|
|||
import org.apache.ivy.core.module.descriptor.DependencyDescriptor
|
||||
import org.apache.ivy.core.resolve.ResolveData
|
||||
import org.apache.ivy.core.settings.IvySettings
|
||||
import org.apache.ivy.plugins.repository.{
|
||||
RepositoryCopyProgressListener,
|
||||
Resource,
|
||||
TransferEvent
|
||||
}
|
||||
import org.apache.ivy.plugins.repository.{ RepositoryCopyProgressListener, Resource, TransferEvent }
|
||||
import org.apache.ivy.plugins.resolver.{
|
||||
BasicResolver,
|
||||
DependencyResolver,
|
||||
|
|
@ -402,7 +398,8 @@ private[sbt] object ConvertResolver {
|
|||
case e: java.io.IOException if e.getMessage.contains("destination already exists") =>
|
||||
val overwriteWarning =
|
||||
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
|
||||
Message.warn(overwriteWarning)
|
||||
super.put(source, destination, true)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
private[sbt] object AltLibraryManagementCodec extends IvyLibraryManagementCodec {
|
||||
import sbt.io.Hash
|
||||
type InlineIvyHL = (Option[IvyPaths], Vector[Resolver], Vector[Resolver], Vector[
|
||||
ModuleConfiguration], Vector[String], Boolean)
|
||||
type InlineIvyHL = (
|
||||
Option[IvyPaths],
|
||||
Vector[Resolver],
|
||||
Vector[Resolver],
|
||||
Vector[ModuleConfiguration],
|
||||
Vector[String],
|
||||
Boolean
|
||||
)
|
||||
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])
|
||||
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
|
||||
override implicit lazy val InlineIvyConfigurationFormat: JsonFormat[InlineIvyConfiguration] = {
|
||||
override implicit lazy val InlineIvyConfigurationFormat
|
||||
: JsonFormat[InlineIvyConfiguration] = {
|
||||
def hlToInlineIvy(i: InlineIvyHL): InlineIvyConfiguration = {
|
||||
val (paths, resolvers, otherResolvers, moduleConfigurations, checksums, managedChecksums) = i
|
||||
val (
|
||||
paths,
|
||||
resolvers,
|
||||
otherResolvers,
|
||||
moduleConfigurations,
|
||||
checksums,
|
||||
managedChecksums
|
||||
) = i
|
||||
InlineIvyConfiguration()
|
||||
.withPaths(paths)
|
||||
.withResolvers(resolvers)
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ import core.module.descriptor.{
|
|||
ExcludeRule,
|
||||
IncludeRule
|
||||
}
|
||||
import core.module.descriptor.{
|
||||
OverrideDependencyDescriptorMediator,
|
||||
DependencyArtifactDescriptor
|
||||
}
|
||||
import core.module.descriptor.{ OverrideDependencyDescriptorMediator, DependencyArtifactDescriptor }
|
||||
import core.IvyPatternHelper
|
||||
import org.apache.ivy.util.{ Message, MessageLogger }
|
||||
import org.apache.ivy.plugins.latest.{ ArtifactInfo => IvyArtifactInfo }
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ class GigahorseUrlHandler extends AbstractURLHandler {
|
|||
def getURLInfo(url0: URL, timeout: Int): URLInfo = {
|
||||
// Install the ErrorMessageAuthenticator
|
||||
if ("http" == url0.getProtocol() || "https" == url0.getProtocol()) {
|
||||
IvyAuthenticator.install()
|
||||
ErrorMessageAuthenticator.install()
|
||||
IvyAuthenticator.install()
|
||||
ErrorMessageAuthenticator.install()
|
||||
}
|
||||
|
||||
val url = normalizeToURL(url0)
|
||||
|
|
@ -72,8 +72,8 @@ class GigahorseUrlHandler extends AbstractURLHandler {
|
|||
def openStream(url0: URL): InputStream = {
|
||||
// Install the ErrorMessageAuthenticator
|
||||
if ("http" == url0.getProtocol() || "https" == url0.getProtocol()) {
|
||||
IvyAuthenticator.install()
|
||||
ErrorMessageAuthenticator.install()
|
||||
IvyAuthenticator.install()
|
||||
ErrorMessageAuthenticator.install()
|
||||
}
|
||||
|
||||
val url = normalizeToURL(url0)
|
||||
|
|
@ -104,8 +104,8 @@ class GigahorseUrlHandler extends AbstractURLHandler {
|
|||
def download(src0: URL, dest: File, l: CopyProgressListener): Unit = {
|
||||
// Install the ErrorMessageAuthenticator
|
||||
if ("http" == src0.getProtocol() || "https" == src0.getProtocol()) {
|
||||
IvyAuthenticator.install()
|
||||
ErrorMessageAuthenticator.install()
|
||||
IvyAuthenticator.install()
|
||||
ErrorMessageAuthenticator.install()
|
||||
}
|
||||
|
||||
val src = normalizeToURL(src0)
|
||||
|
|
@ -143,9 +143,8 @@ class GigahorseUrlHandler extends AbstractURLHandler {
|
|||
}
|
||||
|
||||
def upload(source: File, dest0: URL, l: CopyProgressListener): Unit = {
|
||||
if( ("http" != dest0.getProtocol()) && ("https" != dest0.getProtocol())) {
|
||||
throw new UnsupportedOperationException(
|
||||
"URL repository only support HTTP PUT at the moment")
|
||||
if (("http" != dest0.getProtocol()) && ("https" != dest0.getProtocol())) {
|
||||
throw new UnsupportedOperationException("URL repository only support HTTP PUT at the moment")
|
||||
}
|
||||
|
||||
IvyAuthenticator.install()
|
||||
|
|
@ -203,7 +202,8 @@ object GigahorseUrlHandler {
|
|||
|
||||
private[sbt] def urlFactory = {
|
||||
val client0 = http.underlying[OkHttpClient]
|
||||
val client = client0.newBuilder()
|
||||
val client = client0
|
||||
.newBuilder()
|
||||
.authenticator(new JavaNetAuthenticator)
|
||||
.build
|
||||
new OkUrlFactory(client)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ class VersionNumberSpec extends UnitSpec {
|
|||
}
|
||||
it should "cascade" in generateCorrectCascadingNumbers(
|
||||
"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 {
|
||||
beParsedAs("non.space.!?string", Seq(), Seq(), Seq("non.space.!?string"))
|
||||
|
|
|
|||
|
|
@ -47,8 +47,12 @@ object Dependencies {
|
|||
val scalaXml = scala211Module("scala-xml", "1.0.5")
|
||||
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.1" % Test
|
||||
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4" % Test
|
||||
val sjsonnew = Def.setting { "com.eed3si9n" %% "sjson-new-core" % contrabandSjsonNewVersion.value }
|
||||
val sjsonnewScalaJson = Def.setting { "com.eed3si9n" %% "sjson-new-scalajson" % contrabandSjsonNewVersion.value }
|
||||
val sjsonnew = Def.setting {
|
||||
"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 okhttpUrlconnection = "com.squareup.okhttp3" % "okhttp-urlconnection" % "3.7.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ object Util {
|
|||
val timestamp = formatter.format(new Date)
|
||||
val content = versionLine(version) + "\ntimestamp=" + timestamp
|
||||
val f = dir / "xsbt.version.properties"
|
||||
if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f,
|
||||
version)) {
|
||||
if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version)) {
|
||||
s.log.info("Writing version information to " + f + " :\n" + content)
|
||||
IO.write(f, content)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.3")
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0")
|
||||
|
||||
// addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.3")
|
||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.17")
|
||||
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.10")
|
||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.17")
|
||||
|
||||
scalacOptions += "-language:postfixOps"
|
||||
|
|
|
|||
Loading…
Reference in New Issue