Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First steps to shading sbt-scalafmt #1218

Merged
merged 5 commits into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ env:
CI_PUBLISH: true
- CI_TEST: ci-fast
CI_SCALA_VERSION: 2.12.2
- CI_TEST: ci-sbt-scalafmt
CI_SCALA_VERSION: 2.12.2
- CI_TEST: mima

cache:
Expand Down
116 changes: 51 additions & 65 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ lazy val core = crossProject
.settings(
moduleName := "scalafmt-core",
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
),
allSettings,
buildInfoSettings,
fork.in(run).in(Test) := true,
Expand Down Expand Up @@ -72,66 +73,57 @@ lazy val cli = project
)
.dependsOn(coreJVM)

def isOnly(scalaV: String) = Seq(
scalaVersion := scalaV,
crossScalaVersions := Seq(scalaV)
)

lazy val `scalafmt-cli-sbt` = project
.configs(IntegrationTest)
lazy val big = project
.in(file("scalafmt-big"))
.settings(
allSettings,
Defaults.itSettings,
mimaPreviousArtifacts := Set.empty,
moduleName := "sbt-cli-scalafmt",
isOnly(scala212),
sbtPlugin := true,
sbtVersion in Global := "1.0.0",
test.in(IntegrationTest) := RunSbtCommand(
Seq(
s"plz $scala212 publishLocal",
"""set sbtVersion in Global := "0.13.16" """,
"such scalafmt-sbt-tests/scripted",
"""set sbtVersion in Global := "1.0.0" """
).mkString("; ", "; ", "")
)(state.value)
moduleName := "scalafmt-big",
crossScalaVersions := List(scala212),
mimaReportBinaryIssues := {},
shadeSettings
)
.dependsOn(cli)

lazy val `scalafmt-sbt` = project
.settings(
allSettings,
mimaPreviousArtifacts := Set.empty,
moduleName := "sbt-scalafmt",
isOnly(scala212),
sbtPlugin := true,
sbtVersion in Global := "1.0.0"
)
.dependsOn(coreJVM)
def isOnly(scalaV: String) = Seq(
scalaVersion := scalaV,
crossScalaVersions := Seq(scalaV)
)

lazy val `scalafmt-sbt-tests` = project
.settings(
allSettings,
noPublish,
isOnly(scala210),
sbtPlugin := true,
ScriptedPlugin.scriptedSettings,
sbtVersion := "0.13.15",
scriptedSbt := "0.13.15",
scriptedLaunchOpts := Seq(
"-Dplugin.version=" + version.value,
"-Dscalafmt.scripted=true",
// .jvmopts is ignored, simulate here
"-XX:MaxPermSize=256m",
"-Xmx2g",
"-Xss2m"
) ++ {
// pass along custom boot properties if specified
val bootProps = "sbt.boot.properties"
sys.props.get(bootProps).map(x => s"-D$bootProps=$x").toList
},
scriptedBufferLog := false
)
lazy val shadeSettings: List[Setting[_]] = List(
assemblyOption.in(assembly) ~= { _.copy(includeScala = false) },
assemblyShadeRules.in(assembly) := Seq(
ShadeRule
.rename(
"scala.meta.**" -> "org.scalafmt.shaded.meta.@1",
"fastparse.**" -> "org.scalafmt.shaded.fastparse.@1"
)
.inAll,
ShadeRule
.zap(
"scalapb.**",
"com.trueaccord.**"
)
.inAll
),
artifact.in(Compile, packageBin) := artifact.in(Compile, assembly).value,
pomPostProcess := { (node: scala.xml.Node) =>
new scala.xml.transform.RuleTransformer(
new scala.xml.transform.RewriteRule {
override def transform(node: scala.xml.Node): scala.xml.NodeSeq =
node match {
case e: scala.xml.Elem
if e.label == "dependency" &&
e.child.exists { child =>
child.label == "artifactId" &&
child.text.startsWith("scalafmt")
} =>
scala.xml.Comment(s"shaded scalafmt-cli dependency.")
case _ => node
}
}
).transform(node).head
}
) ++ addArtifact(artifact.in(Compile, packageBin), assembly).settings

lazy val intellij = project
.in(file("scalafmt-intellij"))
Expand Down Expand Up @@ -205,7 +197,8 @@ lazy val readme = scalatex
projectId = "readme",
wd = file(""),
url = "https://github.com/scalameta/scalafmt/tree/master",
source = "Readme")
source = "Readme"
)
.settings(
git.remoteRepo := "git@github.com:scalameta/scalafmt.git",
siteSourceDirectory := target.value / "scalatex",
Expand Down Expand Up @@ -286,7 +279,8 @@ lazy val publishSettings = Seq(
),
mimaBinaryIssueFilters ++= Mima.ignoredABIProblems,
licenses := Seq(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
homepage := Some(url("https://github.com/scalameta/scalafmt")),
autoAPIMappings := true,
apiURL := Some(url("https://olafurpg.github.io/scalafmt/docs/")),
Expand Down Expand Up @@ -356,14 +350,6 @@ def ciCommands = Seq(
"test" ::
Nil
),
CiCommand("ci-slow")(
"tests/test:runMain org.scalafmt.ScalafmtProps" ::
Nil
),
Command.command("ci-sbt-scalafmt") { s =>
"scalafmt-cli-sbt/it:test" ::
s
},
Command.command("ci-publish") { s =>
s"very publish" :: s
}
Expand Down
1 change: 1 addition & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object Dependencies {
val scalatestV = "3.2.0-SNAP10"
val scalacheckV = "1.13.5"
val coursier = "1.0.0-RC12"
val sbtV = "1.1.6"

val scalapb = Def.setting {
ExclusionRule(
Expand Down
2 changes: 0 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
addSbtPlugin("com.dancingrobot84" % "sbt-idea-plugin" % "0.4.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.18")

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ class TermDisplay(
}

override def completedTask(url: String, success: Boolean): Unit =
updateThread.removeEntry(url, success, s"Downloaded $url\n")(x => x)
updateThread.removeEntry(url, success, s"$url\n")(x => x)

override def checkingUpdates(
url: String,
currentTimeOpt: Option[Long]): Unit =
updateThread.newEntry(
url,
CheckUpdateInfo(currentTimeOpt, None, isDone = false),
s"Checking $url\n"
s"$url\n"
)

}
23 changes: 0 additions & 23 deletions scalafmt-sbt-tests/src/sbt-test/scalafmt-sbt/sbt-cli/.gitignore

This file was deleted.

This file was deleted.

66 changes: 0 additions & 66 deletions scalafmt-sbt-tests/src/sbt-test/scalafmt-sbt/sbt-cli/build.sbt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions scalafmt-sbt-tests/src/sbt-test/scalafmt-sbt/sbt-cli/test

This file was deleted.

This file was deleted.

Loading