Compile-time expression evaluation for Scala
Add the library with a "provided" scope to your dependencies list:
libraryDependencies ++= Seq(
"com.github.plokhotnyuk.expression-evaluator" %% "expression-evaluator" % "0.1.3" % Provided // required only in compile-time
)Generate expression results for primitives, strings, BigInt, java.time.ZoneId, java.time.ZoneOffset, and arrays of
them:
import com.github.plokhotnyuk.expression_evaluator._
object Constants {
val x = eval(10 * 10 * 10)
val xs = eval((1 to 3).toArray)
}To see generated code for expression results
scalacOptions ++= Seq("-Xmacro-settings:print-expr-results")To compile, run tests, check coverage, and check binary compatibility for different Scala versions use a command:
sbt clean +coverage +test +coverageReport +mimaReportBinaryIssuesBEWARE: expression-evaluator is included into Scala Community Build for 2.11.x, 2.12.x, and 2.13.x versions of Scala.
Publish to the local Ivy repo:
sbt +publishLocalPublish to the local Maven repo:
sbt +publishM2For version numbering use Recommended Versioning Scheme that is used in the Scala ecosystem.
Double check binary and source compatibility (including behavior) and run release command (credentials required):
sbt release