Skip to content

Commit

Permalink
Merge branch '1.5.x'
Browse files Browse the repository at this point in the history
Configure mima previous version to 1.5.0 #279
scalafmt formatting #290
Simplify mima configuration #292
  • Loading branch information
marcospereira committed Dec 18, 2019
2 parents df09ed6 + 8e92e18 commit 5d1c4d6
Show file tree
Hide file tree
Showing 24 changed files with 12 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import scala.collection.JavaConverters
import scala.reflect.ClassTag

case class BaseScalaTemplate[T <: Appendable[T], F <: Format[T]](format: F) {

// The overloaded methods are here for speed. The compiled templates
// can take advantage of them for a 12% performance boost
def _display_(x: AnyVal): T = format.escape(x.toString)
Expand Down
2 changes: 0 additions & 2 deletions api/shared/src/main/scala/play/twirl/api/Content.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ trait Content {
* The default Content type to use for this content.
*/
def contentType: String

}

/**
Expand Down Expand Up @@ -67,5 +66,4 @@ abstract class BufferedContent[A <: BufferedContent[A]](
}

override def hashCode(): Int = this.getClass.hashCode() + body.hashCode()

}
6 changes: 0 additions & 6 deletions api/shared/src/main/scala/play/twirl/api/Formats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ object HtmlFormat extends Format[Html] {
* Create an HTML Fragment that holds other fragments.
*/
def fill(elements: immutable.Seq[Html]): Html = new Html(elements)

}

/**
Expand All @@ -141,7 +140,6 @@ object Txt {
def apply(text: String): Txt = {
new Txt(text)
}

}

/**
Expand All @@ -168,7 +166,6 @@ object TxtFormat extends Format[Txt] {
* Create an Txt Fragment that holds other fragments.
*/
def fill(elements: immutable.Seq[Txt]): Txt = new Txt(elements)

}

/**
Expand All @@ -195,7 +192,6 @@ object Xml {
def apply(text: String): Xml = {
new Xml(text)
}

}

/**
Expand All @@ -222,7 +218,6 @@ object XmlFormat extends Format[Xml] {
* Create an XML Fragment that holds other fragments.
*/
def fill(elements: immutable.Seq[Xml]): Xml = new Xml(elements)

}

/**
Expand Down Expand Up @@ -278,5 +273,4 @@ object JavaScriptFormat extends Format[JavaScript] {
* Create an JavaScript Fragment that holds other fragments.
*/
def fill(elements: immutable.Seq[JavaScript]): JavaScript = new JavaScript(elements)

}
6 changes: 0 additions & 6 deletions api/shared/src/main/scala/play/twirl/api/TemplateMagic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import scala.language.implicitConversions

@deprecated("Use TwirlDefaultImports instead", "1.2.0")
object TemplateMagic {

// --- UTILS

def defining[T](t: T)(handler: T => Any) = {
Expand Down Expand Up @@ -47,28 +46,23 @@ object TemplateMagic {
// --- DATE

class RichDate(date: java.util.Date) {

def format(pattern: String) = {
new java.text.SimpleDateFormat(pattern).format(date)
}

}

implicit def richDate(date: java.util.Date) = new RichDate(date)

// --- STRING

class RichString(string: String) {

def when(predicate: => Boolean) = {
predicate match {
case true => string
case false => ""
}
}

}

implicit def richString(string: String) = new RichString(string)

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@ object TwirlHelperImports {

/** Allows inline formatting of java.util.Date */
implicit class TwirlRichDate(date: java.util.Date) {

def format(pattern: String): String = {
new java.text.SimpleDateFormat(pattern).format(date)
}

}

/** Adds a when method to Strings to control when they are rendered. */
implicit class TwirlRichString(string: String) {

def when(predicate: => Boolean): String = {
predicate match {
case true => string
case false => ""
}
}

}

}
3 changes: 0 additions & 3 deletions api/shared/src/main/scala/play/twirl/api/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package object api {
* Three interpolators are available: `html`, `xml` and `js`.
*/
implicit class StringInterpolation(val sc: StringContext) extends AnyVal {

def html(args: Any*): Html = interpolate(args, HtmlFormat)

def xml(args: Any*): Xml = interpolate(args, XmlFormat)
Expand All @@ -43,7 +42,5 @@ package object api {
}
new BaseScalaTemplate[A, Format[A]](format)._display_(array)
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package play.twirl.api.utils

object StringEscapeUtils {

def escapeEcmaScript(input: String): String = {
val s = new StringBuilder()
val len = input.length
Expand Down Expand Up @@ -57,5 +56,4 @@ object StringEscapeUtils {

s.toString()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.scalatest.wordspec.AnyWordSpec
class BufferedContentSpec extends AnyWordSpec with Matchers {

"equality checking" should {

"return false for BufferedContents with the same body but different implementations" in {
Html("hello") must not be Xml("hello")
Html("hello") must not be Txt("hello")
Expand Down Expand Up @@ -54,7 +53,5 @@ class BufferedContentSpec extends AnyWordSpec with Matchers {
Txt("hello") mustEqual Txt("hello")
Xml("hello") mustEqual Xml("hello")
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ class FormatSpec extends AnyWordSpec with Matchers {
JavaScriptFormat.escape("""foo ' bar " baz \""").body must be("""foo \' bar \" baz \\""")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ class StringInterpolationSpec extends AnyWordSpec with Matchers {
html"${javaList}".body mustBe "ab"
}
}

}
37 changes: 12 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import sbtcrossproject.crossProject
import org.scalajs.jsenv.nodejs.NodeJSEnv

// Binary compatibility is this version
val previousVersion: Option[String] = None
val previousVersion: Option[String] = Some("1.5.0")

val ScalaTestVersion = "3.1.0"

def binaryCompatibilitySettings(org: String, moduleName: String, scalaBinVersion: String): Set[ModuleID] = {
if (scalaBinVersion.equals(scala213)) Set.empty
else
previousVersion match {
case None => Set.empty
case Some(pv) => Set(org % s"${moduleName}_${scalaBinVersion}" % pv)
}
}
val mimaSettings = Seq(
mimaPreviousArtifacts := previousVersion.map(organization.value %% name.value % _).toSet
)

val javacParameters = Seq(
"-source",
Expand Down Expand Up @@ -88,17 +83,13 @@ lazy val api = crossProject(JVMPlatform, JSPlatform)
.in(file("api"))
.enablePlugins(PlayLibrary, Playdoc)
.configs(Docs)
.settings(commonSettings)
.settings(
commonSettings,
mimaSettings,
name := "twirl-api",
jsEnv := nodeJs,
libraryDependencies ++= scalaXml.value,
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalaTestVersion % "test",
mimaPreviousArtifacts := binaryCompatibilitySettings(
organization.value,
moduleName.value,
scalaBinaryVersion.value
),
)

lazy val apiJvm = api.jvm
Expand All @@ -107,39 +98,35 @@ lazy val apiJs = api.js
lazy val parser = project
.in(file("parser"))
.enablePlugins(PlayLibrary)
.settings(commonSettings)
.settings(
commonSettings,
mimaSettings,
name := "twirl-parser",
libraryDependencies ++= scalaParserCombinators(scalaVersion.value),
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalaTestVersion % "test",
mimaPreviousArtifacts := binaryCompatibilitySettings(organization.value, moduleName.value, scalaBinaryVersion.value)
)

lazy val compiler = project
.in(file("compiler"))
.enablePlugins(PlayLibrary)
.dependsOn(apiJvm, parser % "compile;test->test")
.settings(commonSettings)
.settings(
commonSettings,
mimaSettings,
name := "twirl-compiler",
libraryDependencies += scalaCompiler(scalaVersion.value),
libraryDependencies ++= scalaParserCombinators(scalaVersion.value),
fork in run := true,
mimaPreviousArtifacts := binaryCompatibilitySettings(
organization.value,
moduleName.value,
scalaBinaryVersion.value
),
)

lazy val plugin = project
.in(file("sbt-twirl"))
.enablePlugins(PlaySbtPlugin, SbtPlugin)
.dependsOn(compiler)
.settings(javaCompilerSettings)
.settings(headerSettings)
.settings(
javaCompilerSettings,
headerSettings,
name := "sbt-twirl",
organization := "com.typesafe.sbt",
scalaVersion := scala212,
Expand Down
Loading

0 comments on commit 5d1c4d6

Please sign in to comment.