Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Split up fullCrossBuilt modules and singleCrossBuilt modules, rem…
Browse files Browse the repository at this point in the history
…oving

`CrossVersion.full` from some modules that didn't need it, and splitting
their publishing in CI so the modules that only are cross-built on major
versions no longer get redundantly published for each of the (many) minor
versions of Scala
  • Loading branch information
lihaoyi committed May 23, 2017
1 parent ccbc690 commit e84e1c3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
10 changes: 1 addition & 9 deletions amm/repl/src/main/scala/ammonite/repl/ApiImpls.scala
Expand Up @@ -88,15 +88,7 @@ class ReplApiImpl(val interp: Interpreter,
defaultWidth = width,
colorLiteral = colors().literal(),
colorApplyPrefix = colors().prefix(),
additionalHandlers = {
case x: ammonite.ops.LsSeq => PPrints.lsSeqRepr(x)
case x: ammonite.ops.Path => PPrints.pathRepr(x)
case x: ammonite.ops.RelPath => PPrints.relPathRepr(x)
case x: ammonite.ops.CommandResult => PPrints.commandResultRepr(x)
case t: History => pprint.Tree.Lazy(ctx => Iterator(t.mkString("\n")))
case t: GrepResult => pprint.Tree.Lazy(ctx => Iterator(GrepResult.grepResultRepr(t, ctx)))
case t: scala.xml.Elem => pprint.Tree.Lazy(_ => Iterator(t.toString))
}
additionalHandlers = PPrints.replPPrintHandlers
)
)

Expand Down
12 changes: 11 additions & 1 deletion amm/repl/src/main/scala/ammonite/repl/PPrints.scala
@@ -1,10 +1,20 @@
package ammonite.repl

import ammonite.ops.{CommandResult, LsSeq}
import ammonite.runtime.History
import ammonite.runtime.tools.GrepResult
import pprint.Renderer

object PPrints{

val replPPrintHandlers: PartialFunction[Any, pprint.Tree] = {
case x: ammonite.ops.LsSeq => PPrints.lsSeqRepr(x)
case x: ammonite.ops.Path => PPrints.pathRepr(x)
case x: ammonite.ops.RelPath => PPrints.relPathRepr(x)
case x: ammonite.ops.CommandResult => PPrints.commandResultRepr(x)
case t: History => pprint.Tree.Lazy(ctx => Iterator(t.mkString("\n")))
case t: GrepResult => pprint.Tree.Lazy(ctx => Iterator(GrepResult.grepResultRepr(t, ctx)))
case t: scala.xml.Elem => pprint.Tree.Lazy(_ => Iterator(t.toString))
}
def lsSeqRepr(t: LsSeq) = pprint.Tree.Lazy { ctx =>
val renderer = new Renderer(
ctx.width, ctx.applyPrefixColor, ctx.literalColor, ctx.indentStep
Expand Down
@@ -1,13 +1,15 @@
package ammonite.shell
package ammonite.unit

import ammonite.ops._
import utest._
import PPrints._

object PPrintTests extends TestSuite{
def check(lhs: String, rhs: String) = {
assert(lhs == rhs)
}
val pprinter = pprint.PPrinter.BlackWhite.copy(additionalHandlers = Configure.pprintHandlers)
val pprinter = pprint.PPrinter.BlackWhite.copy(
additionalHandlers = ammonite.repl.PPrints.replPPrintHandlers
)
val tests = TestSuite{

'paths{
Expand Down
21 changes: 17 additions & 4 deletions build.sbt
Expand Up @@ -153,8 +153,6 @@ lazy val ammUtil = project
.settings(
macroSettings,
sharedSettings,
crossVersion := CrossVersion.full,

name := "ammonite-util",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % "0.4.4",
Expand All @@ -169,7 +167,6 @@ lazy val ammRuntime = project
.settings(
macroSettings,
sharedSettings,
crossVersion := CrossVersion.full,

name := "ammonite-runtime",
libraryDependencies ++= Seq(
Expand Down Expand Up @@ -226,6 +223,7 @@ lazy val shell = project
.settings(
sharedSettings,
macroSettings,
crossVersion := CrossVersion.full,
name := "ammonite-shell",
(test in Test) := (test in Test).dependsOn(packageBin in Compile).value,
(run in Test) := (run in Test).dependsOn(packageBin in Compile).evaluated,
Expand Down Expand Up @@ -308,7 +306,22 @@ lazy val readme = ScalatexReadme(
(unmanagedSources in Compile) += baseDirectory.value/".."/"project"/"Constants.scala"
)

// Only modules down-stream of `ammInterp` need to be fully cross-built against
// minor versions, since `interp` depends on compiler internals. The modules
// upstream of `ammInterp` can be cross-built normally only against major versions
// of Scala
lazy val singleCrossBuilt = project
.in(file("target/singleCrossBuilt"))
.aggregate(ops, terminal, ammUtil, ammRuntime)
.settings(dontPublishSettings)

lazy val fullCrossBuilt = project
.in(file("target/fullCrossBuilt"))
.aggregate(shell, amm, sshd, ammInterp, ammRepl)
.settings(dontPublishSettings)


lazy val published = project
.in(file("target/published"))
.aggregate(ops, shell, terminal, amm, sshd, ammUtil, ammRuntime, ammInterp, ammRepl)
.aggregate(fullCrossBuilt, singleCrossBuilt)
.settings(dontPublishSettings)
20 changes: 14 additions & 6 deletions ci/build.sc
Expand Up @@ -14,7 +14,7 @@ val allVersions = Seq(
"2.12.0", "2.12.1", "2.12.2"
)

val latestVersions = Set("2.10.6", "2.11.11", "2.12.2")
val latestMajorVersions = Set("2.10.6", "2.11.11", "2.12.2")

val buildVersion =
if (sys.env("TRAVIS_TAG") == "") s"COMMIT-${getGitHash()}"
Expand Down Expand Up @@ -69,8 +69,12 @@ def publishSigned() = {
write(cwd/"pubring.asc", sys.env("SONATYPE_PGP_PUB_KEY_CONTENTS").replace("\\n", "\n"))


for (version <- latestMajorVersions) {
%sbt("++" + version, "singleCrossBuilt/publishSigned")
}

for (version <- allVersions) {
%sbt("++" + version, "published/publishSigned")
%sbt("++" + version, "fullCrossBuilt/publishSigned")
}
%sbt("sonatypeReleaseAll")
}
Expand Down Expand Up @@ -152,7 +156,7 @@ def publishExecutable(ammoniteVersion: String,
.asString
}

for (version <- latestVersions) {
for (version <- latestMajorVersions) {
println("MASTER COMMIT: Publishing Executable for Scala " + version)
//Prepare executable
%sbt("++" + version, "amm/test:assembly")
Expand All @@ -179,7 +183,7 @@ def executable() = {
)
}else{
println("MISC COMMIT: generating executable but not publishing")
for (version <- latestVersions) {
for (version <- latestMajorVersions) {
%sbt("++" + version, "published/test:compile")
%sbt("++" + version, "integration/test:compile")
%sbt("++" + version, "amm/test:assembly")
Expand Down Expand Up @@ -210,9 +214,13 @@ def artifacts() = {
publishSigned()
}else{
println("MISC COMMIT: Compiling all Scala code across versions for verification")
for (version <- latestMajorVersions) {
%sbt("++" + version, "singleCrossBuilt/package")
%sbt("++" + version, "singleCrossBuilt/packageSrc")
}
for (version <- allVersions) {
%sbt("++" + version, "published/package")
%sbt("++" + version, "published/packageSrc")
%sbt("++" + version, "fullCrossBuilt/package")
%sbt("++" + version, "fullCrossBuilt/packageSrc")
}
}

Expand Down

0 comments on commit e84e1c3

Please sign in to comment.