Skip to content

Commit

Permalink
Rebrand + move to the Maven Central + cross-build with Scala 2.13 re…
Browse files Browse the repository at this point in the history
…lease
  • Loading branch information
plokhotnyuk committed Jun 7, 2019
1 parent ea396cb commit 5e24e78
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 87 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018 Sizmek, Inc.
Copyright 2019 Andriy Plokhotnyuk, and respective contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,18 @@ Currently, it doesn't support formatting string interpolator (`f""` literal), ho

## How to use

The library is published to JCenter, so please add a resolver for it in your `build.sbt` file or ensure that it is
already added:

```sbt
resolvers += Resolver.jcenterRepo
```

Add the library to a dependency list:

```sbt
libraryDependencies += "com.sizmek.fsi" %% "fsi-macros" % "0.5.0"
libraryDependencies += "com.github.plokhotnyuk.fsi" %% "fsi-macros" % "0.5.0"
```

Add import and replace prefix `s` by `fs` (or for a raw string interpolator `raw` by `fraw`):

```scala
import com.sizmek.fsi._
import com.github.plokhotnyuk.fsi._

val host = "sizmek.com"
val host = "company.com"
val path = "blog"
fs"http://$host/$path"
fraw"http://$host/$path"
Expand Down Expand Up @@ -80,20 +73,20 @@ the following code will be generated:
{
val fresh$macro$1: Int = f();
val fresh$macro$2: Double = g();
com.sizmek.fsi.`package`.stringBuilder().append('a').append(fresh$macro$1).append("bb").append(fresh$macro$2).toString();
com.github.plokhotnyuk.fsi.`package`.stringBuilder().append('a').append(fresh$macro$1).append("bb").append(fresh$macro$2).toString();
}: String
```

You can check this by adding a compiler option: `scalacOptions += "-Ymacro-debug-lite"`.

In this code ```com.sizmek.fsi.`package`.stringBuilder()``` stands for getting a preallocated instance of
In this code ```com.github.plokhotnyuk.fsi.`package`.stringBuilder()``` stands for getting a preallocated instance of
`java.lang.StringBuilder` from the thread-local pool.

By default a buffer capacity of all created `java.lang.StringBuilder` instances is 16384 characters (32Kb). If limit
is reached buffer size grows to ensure that whole string can fit in it. However next retrieval from the pool a new
`java.lang.StringBuilder` instance will be allocated with the default size of the buffer and returned to avoid
exhausting of Java heap. So if you want to work with longer strings without reallocations then set a greater value for
the following JVM system property: `com.sizmek.fsi.buffer.size`.
the following JVM system property: `com.github.plokhotnyuk.fsi.buffer.size`.

## How to contribute

Expand Down
63 changes: 30 additions & 33 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ def mimaSettings = mimaDefaultSettings ++ Seq(
)

lazy val commonSettings = Seq(
organization := "com.sizmek.fsi",
organizationHomepage := Some(url("https://sizmek.com")),
homepage := Some(url("https://github.com/Sizmek/fast-string-interpolator")),
organization := "com.github.plokhotnyuk.fsi",
organizationHomepage := Some(url("https://github.com/plokhotnyuk")),
homepage := Some(url("https://github.com/plokhotnyuk/fast-string-interpolator")),
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))),
startYear := Some(2018),
developers := List(
Developer(
id = "plokhotnyuk",
name = "Andriy Plokhotnyuk",
email = "andriy.plokhotnyuk@sizmek.com",
url = url("https://twitter.com/aplokhotnyuk")
email = "plokhotnyuk@gmail.com",
url = url("https://github.com/aplokhotnyuk")
),
Developer(
id = "AnderEnder",
name = "Andrii Radyk",
email = "andrii.radyk@sizmek.com",
email = "ander.ender@gmail.com",
url = url("https://github.com/AnderEnder")
),
),
scalaVersion := "2.12.8",
resolvers += Resolver.jcenterRepo,
resolvers += "Sonatype OSS Staging" at "https://oss.sonatype.org/content/repositories/staging",
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
Expand All @@ -66,20 +66,16 @@ lazy val commonSettings = Seq(

lazy val noPublishSettings = Seq(
skip in publish := true,
publishArtifact := false,
// Replace tasks to work around https://github.com/sbt/sbt-bintray/issues/93
bintrayRelease := ((): Unit),
bintrayEnsureBintrayPackageExists := ((): Unit),
bintrayEnsureLicenses := ((): Unit),
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging)
)

lazy val publishSettings = Seq(
bintrayOrganization := Some("sizmek"),
bintrayRepository := "sizmek-maven",
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),
sonatypeProfileName := "com.github.plokhotnyuk",
scmInfo := Some(
ScmInfo(
url("https://github.com/Sizmek/fast-string-interpolator"),
"scm:[email protected]:Sizmek/fast-string-interpolator.git"
url("https://github.com/plokhotnyuk/fast-string-interpolator"),
"scm:[email protected]:plokhotnyuk/fast-string-interpolator.git"
)
),
publishConfiguration := {
Expand All @@ -88,12 +84,7 @@ lazy val publishSettings = Seq(
publishConfiguration.value
},
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
// FIXME: remove setting of overwrite flag when the following issue will be fixed: https://github.com/sbt/sbt/issues/3725
publishConfiguration := publishConfiguration.value.withOverwrite(isSnapshot.value),
publishSignedConfiguration := publishSignedConfiguration.value.withOverwrite(isSnapshot.value),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(isSnapshot.value),
publishLocalSignedConfiguration := publishLocalSignedConfiguration.value.withOverwrite(isSnapshot.value)
pomIncludeRepository := { _ => false }
)

lazy val `fast-string-interpolator` = project.in(file("."))
Expand All @@ -106,11 +97,14 @@ lazy val `fsi-macros` = project
.settings(mimaSettings)
.settings(publishSettings)
.settings(
crossScalaVersions := Seq("2.13.0-RC2", "2.13.0-RC1", "2.12.8", "2.11.12"),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalatest" %% "scalatest" % (if (scalaVersion.value == "2.13.0-RC1") "3.0.8-RC3" else "3.0.8-RC5") % Test
)
crossScalaVersions := Seq("2.13.0", "2.12.8", "2.11.12"),
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value),
libraryDependencies ++=
(if (scalaVersion.value == "2.13.0") {
Seq("org.scalatest" % "scalatest_2.13.0-RC3" % "3.0.8-RC5" % Test)
} else {
Seq("org.scalatest" %% "scalatest" % "3.0.8-RC5" % Test)
})
)

lazy val `fsi-benchmark-core` = project
Expand All @@ -119,11 +113,14 @@ lazy val `fsi-benchmark-core` = project
.settings(commonSettings)
.settings(noPublishSettings)
.settings(
crossScalaVersions := Seq("2.13.0-RC2", "2.13.0-RC1", "2.12.8", "2.11.12"),
libraryDependencies ++= Seq(
"pl.project13.scala" % "sbt-jmh-extras" % "0.3.4",
"org.scalatest" %% "scalatest" % (if (scalaVersion.value == "2.13.0-RC1") "3.0.8-RC3" else "3.0.8-RC5") % Test
)
crossScalaVersions := Seq("2.13.0", "2.12.8", "2.11.12"),
libraryDependencies ++= Seq("pl.project13.scala" % "sbt-jmh-extras" % "0.3.4"),
libraryDependencies ++=
(if (scalaVersion.value == "2.13.0") {
Seq("org.scalatest" % "scalatest_2.13.0-RC3" % "3.0.8-RC5" % Test)
} else {
Seq("org.scalatest" %% "scalatest" % "3.0.8-RC5" % Test)
})
)

lazy val `fsi-benchmark` = project
Expand All @@ -137,6 +134,6 @@ lazy val `fsi-benchmark` = project
"com.dongxiguo" %% "fastring" % "1.0.0",
"com.outr" %% "perfolation" % "1.1.2",
"com.outr" %% "scribe-slf4j" % "2.7.7" % Test,
"org.scalatest" %% "scalatest" % (if (scalaVersion.value == "2.13.0-RC1") "3.0.8-RC3" else "3.0.8-RC5") % Test
"org.scalatest" %% "scalatest" % "3.0.8-RC5" % Test
)
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.sizmek.fsi.benchmark_core
package com.github.plokhotnyuk.fsi.benchmark_core

import java.util.concurrent.TimeUnit

import com.sizmek.fsi._
import com.github.plokhotnyuk.fsi._
import org.openjdk.jmh.annotations.{Benchmark, _}

import scala.language.postfixOps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.sizmek.fsi.benchmark_core
package com.github.plokhotnyuk.fsi.benchmark_core

import java.util.concurrent.TimeUnit

import com.sizmek.fsi._
import com.github.plokhotnyuk.fsi._
import org.openjdk.jmh.annotations.{Benchmark, _}

@State(Scope.Benchmark)
Expand Down Expand Up @@ -37,7 +37,7 @@ class SimpleConcatenationBenchmarkCore {
double = 10000d
char = 'x'
boolean = false
string = "Sizmek is the largest independent buy-side advertising platform"
string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
}

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sizmek.fsi.benchmark_core
package com.github.plokhotnyuk.fsi.benchmark_core

import org.scalatest.{Matchers, WordSpec}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sizmek.fsi.benchmark_core
package com.github.plokhotnyuk.fsi.benchmark_core

import org.scalatest.{Matchers, WordSpec}

class SimpleConcatenationBenchmarkCoreSpec extends WordSpec with Matchers {
private val benchmark = new SimpleConcatenationBenchmarkCore
private val expected =
"10000xxx10000xxx10000.0xxx10000.0xxxxxxxfalsexxxSizmek is the largest independent buy-side advertising platform"
"10000xxx10000xxx10000.0xxx10000.0xxxxxxxfalsexxxLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."

"SimpleConcatenationBenchmarkCode" should {
"build the same string value" in {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sizmek.fsi.benchmark
package com.github.plokhotnyuk.fsi.benchmark

import com.dongxiguo.fastring.Fastring.Implicits._
import com.sizmek.fsi.benchmark_core.NestedConcatenationBenchmarkCore
import com.github.plokhotnyuk.fsi.benchmark_core.NestedConcatenationBenchmarkCore
import org.openjdk.jmh.annotations.Benchmark
import perfolation._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sizmek.fsi.benchmark
package com.github.plokhotnyuk.fsi.benchmark

import com.dongxiguo.fastring.Fastring.Implicits._
import com.sizmek.fsi.benchmark_core.SimpleConcatenationBenchmarkCore
import com.github.plokhotnyuk.fsi.benchmark_core.SimpleConcatenationBenchmarkCore
import org.openjdk.jmh.annotations.Benchmark
import perfolation._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sizmek.fsi.benchmark
package com.github.plokhotnyuk.fsi.benchmark

import org.scalatest.{Matchers, WordSpec}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sizmek.fsi.benchmark
package com.github.plokhotnyuk.fsi.benchmark

import org.scalatest.{Matchers, WordSpec}

class SimpleConcatenationBenchmarkSpec extends WordSpec with Matchers {
private val benchmark = new SimpleConcatenationBenchmark
private val expected =
"10000xxx10000xxx10000.0xxx10000.0xxxxxxxfalsexxxSizmek is the largest independent buy-side advertising platform"
"10000xxx10000xxx10000.0xxx10000.0xxxxxxxfalsexxxLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."

"SimpleConcatenationBenchmark" should {
"build the same string value" in {
Expand Down
14 changes: 0 additions & 14 deletions fsi-benchmark/src/test/scala/specs/Issue8Spec.scala

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sizmek
package com.github.plokhotnyuk

import scala.StringContext._
import scala.language.experimental.macros
Expand All @@ -13,15 +13,15 @@ package object fsi {
*
* Here's an example of usage:
* {{{
* val host = "sizmek.com"
* val host = "company.com"
* val path = "blog"
* println(fs"http://$host/$path")
* println(fraw"http://$host/$path")
* }}}
* It will print 2 strings:
* {{{
* http://sizmek.com/blog
* http://sizmek.com/blog
* http://company.com/blog
* http://company.com/blog
* }}}
*
* Let we have defined functions: `def f(): Int` and `def g(): Double`, then in compile-time
Expand All @@ -30,7 +30,7 @@ package object fsi {
* {
* val fresh$macro$1: Int = f();
* val fresh$macro$2: Double = g();
* com.sizmek.fsi.`package`.stringBuilder().append('a').append(fresh$macro$1).append("bb").append(fresh$macro$2).toString()
* com.github.plokhotnyuk.fsi.`package`.stringBuilder().append('a').append(fresh$macro$1).append("bb").append(fresh$macro$2).toString()
* }: String
* }}}
*/
Expand Down Expand Up @@ -98,7 +98,7 @@ package object fsi {
}.unzip

val stringBuilderWithAppends = constants.zipAll(values, "", null)
.foldLeft(q"com.sizmek.fsi.stringBuilder()") { case (sb, (s, v)) =>
.foldLeft(q"com.github.plokhotnyuk.fsi.stringBuilder()") { case (sb, (s, v)) =>
val len = s.length
if (len == 0) {
if (v == null) sb
Expand Down Expand Up @@ -130,5 +130,5 @@ package object fsi {
}
}

private[this] final val size = Try(sys.props.getOrElse("com.sizmek.fsi.buffer.size", "").toInt).getOrElse(16384)
private[this] final val size = Try(sys.props.getOrElse("com.github.plokhotnyuk.fsi.buffer.size", "").toInt).getOrElse(16384)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sizmek.specs.fsi
package com.github.plokhotnyuk.specs.fsi

import com.sizmek.fsi._
import com.github.plokhotnyuk.fsi._
import org.scalatest.exceptions.TestFailedException
import org.scalatest.{Matchers, WordSpec}

Expand Down
6 changes: 4 additions & 2 deletions release.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ lazy val updateVersionInReadme: ReleaseStep = { st: State =>
val readme = "README.md"
val oldContent = IO.read(file(readme))
val newContent = oldContent.replaceAll('"' + oldVersion + '"', '"' + newVersion + '"')
.replaceAll('-' + oldVersion + '-', '-' + newVersion + '-')
IO.write(file(readme), newContent)
s"git add $readme" !! st.log
st
Expand All @@ -25,8 +26,9 @@ releaseProcess := Seq[ReleaseStep](
updateVersionInReadme,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publish"),
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)
)

0 comments on commit 5e24e78

Please sign in to comment.