diff --git a/README.md b/README.md index 0955bd0..454c1d7 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,29 @@ A Query Monad implementation for Anorm. The project is using [SBT](http://www.scala-sbt.org/), so to build it from sources the following command can be used. - sbt publishLocal +```shell +sbt +publishLocal +``` -[![CircleCI](https://travis-ci.org/zengularity/query-monad.svg?style=svg)](https://travis-ci.org/zengularity/query-monad) -[![Zen Entrepot](http://zen-entrepot.nestincloud.io/entrepot/shields/releases/com/zengularity/query-monad_2.12.svg)](https://zen-entrepot.nestincloud.io/entrepot/pom/releases/com/zengularity/query-monad_2.12) +[![Build Status](https://travis-ci.org/zengularity/query-monad.svg?branch=master)](https://travis-ci.org/zengularity/query-monad) +[![Zen Entrepot](http://zen-entrepot.nestincloud.io/entrepot/shields/snapshots/com/zengularity/query-monad-core_2.12.svg)](https://zen-entrepot.nestincloud.io/entrepot/pom/snapshots/com/zengularity/query-monad-core_2.12) +[![Zen Entrepot](http://zen-entrepot.nestincloud.io/entrepot/shields/releases/com/zengularity/query-monad-core_2.12.svg)](https://zen-entrepot.nestincloud.io/entrepot/pom/releases/com/zengularity/query-monad-core_2.12) ## Contributing Please take a look at the [Contribution guide](.github/CONTRIBUTING.md) + +## Publishing + +To publish a snapshot or a release on [Zengularity Entrepot](https://github.com/zengularity/entrepot): + +- set the environment variable `REPO_PATH`; +- run the SBT command `+publish`. + +For example: +```shell +export REPO_PATH=/path/to/entrepot/snapshots/ +sbt +publish +``` + +Then in Entrepot, the changes must be commited and pushed. diff --git a/build.sbt b/build.sbt index 398fb2a..4a8802c 100644 --- a/build.sbt +++ b/build.sbt @@ -1,68 +1,8 @@ -name := "query-monad-code" - -version := "1.0-SNAPSHOT" +ThisBuild / organization := "com.zengularity" ThisBuild / scalaVersion := "2.12.7" ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.7") -def scalacOptionsVersion(scalaVersion: String) = { - val defaultOptions = Seq( - "-deprecation", // Emit warning and location for usages of deprecated APIs. - "-encoding", - "utf-8", // Specify character encoding used by source files. - "-explaintypes", // Explain type errors in more detail. - "-feature", // Emit warning and location for usages of features that should be imported explicitly. - "-unchecked", // Enable additional warnings where generated code depends on assumptions. - "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. - "-Xfatal-warnings", // Fail the compilation if there are any warnings. - "-Xlint", - "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. - "-Ypartial-unification", // Enable partial unification in type constructor inference - "-Ywarn-dead-code", // Warn when dead code is identified. - "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. - "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. - "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. - "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. - "-Ywarn-numeric-widen", // Warn when numerics are widened. - "-Ywarn-unused", // Warn if unused. - "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. - ) - val v211Options = Seq( - "-Xsource:2.12" // See https://github.com/scala/scala/releases/tag/v2.11.11 - ) - val v212Options = Seq( - "-Ywarn-extra-implicit" // Warn when more than one implicit parameter section is defined. - ) - - CrossVersion.partialVersion(scalaVersion) match { - case Some((2L, 11L)) => defaultOptions ++ v211Options - case _ => defaultOptions ++ v212Options - } -} - -// Common values -def commonSettings = Seq( - organization := "com.zengularity", - crossPaths := false, - scalacOptions ++= scalacOptionsVersion(scalaVersion.value), - scalacOptions in (Compile, console) ~= (_.filterNot( - Set( - "-Ywarn-unused:imports", - "-Xfatal-warnings" - ) - )), - scalacOptions in (Test, compile) ~= (_.filterNot( - Set( - "-Ywarn-unused:imports", - "-Xfatal-warnings", - "-Yrangepos" - ) - )), - resolvers ++= Seq[Resolver]( - Resolver.sonatypeRepo("releases") - ) -) - // Scalafmt ThisBuild / scalafmtOnCompile := true @@ -73,12 +13,14 @@ wartremoverErrors ++= Warts.unsafe // Projects definitions // +val nameRoot = "query-monad" + // Core + Modules lazy val core = (project in file("core")) .settings( - commonSettings ++ Seq( - name := "query-core", + Settings.commonLibSettings ++ Seq( + name := s"$nameRoot-core", libraryDependencies ++= Seq( Dependencies.acolyte % Test, Dependencies.anorm % Test, @@ -89,9 +31,9 @@ lazy val core = (project in file("core")) ) lazy val playSqlModule = (project in file("modules/play-sql")) - .settings(commonSettings) + .settings(Settings.commonLibSettings) .settings( - name := "query-play-sql", + name := s"$nameRoot-play-sql", libraryDependencies ++= Seq( jdbc, evolutions % Test, @@ -111,7 +53,8 @@ lazy val playSqlModule = (project in file("modules/play-sql")) lazy val sampleAppExample = (project in file("examples/sample-app")) .enablePlugins(PlayScala) .settings( - commonSettings ++ Seq( + Settings.commonExamplesSettings ++ Seq( + name := s"$nameRoot-example-sample-app", name := "sample-app-example", libraryDependencies ++= Seq( Dependencies.anorm, @@ -123,9 +66,9 @@ lazy val sampleAppExample = (project in file("examples/sample-app")) lazy val todoAppExample = (project in file("examples/todo-app")) .enablePlugins(PlayScala) - .settings(commonSettings) + .settings(Settings.commonExamplesSettings) .settings( - name := "todo-app-example", + name := s"$nameRoot-example-todo-app", libraryDependencies ++= Seq( evolutions, Dependencies.anorm, @@ -143,3 +86,4 @@ lazy val todoAppExample = (project in file("examples/todo-app")) lazy val root: Project = project .in(file(".")) .aggregate(core, playSqlModule, sampleAppExample, todoAppExample) + .settings(Publish.skipSettings) diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 0000000..b6a94f7 --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,38 @@ +import java.io.File + +import sbt.Keys._ +import sbt._ + +object Publish { + + def skipSettings: Seq[Def.Setting[_]] = + Seq( + publish / skip := true + ) + + def settings: Seq[Def.Setting[_]] = + Seq( + publishTo := { + import Resolver.mavenStylePatterns + + sys.env + .get("REPO_PATH") + .map(path => Resolver.file("repo", new File(path))) + }, + licenses := Seq( + "MIT License" -> url( + "https://github.com/zengularity/query-monad/blob/master/LICENSE" + ) + ), + pomIncludeRepository := { _ => + false + }, + autoAPIMappings := true, + homepage := Some(url("https://github.com/zengularity/query-monad")), // TODO + apiURL := Some(url("https://github.com/zengularity/query-monad")), // TODO + scmInfo := Some( + ScmInfo(url("https://github.com/zengularity/query-monad"), + "git@github.com:zengularity/query-monad.git") + ) + ) +} diff --git a/project/Settings.scala b/project/Settings.scala new file mode 100644 index 0000000..60981a0 --- /dev/null +++ b/project/Settings.scala @@ -0,0 +1,69 @@ +import sbt.Keys._ +import sbt.{Def, _} + +object Settings { + + def commonLibSettings: Seq[Def.Setting[_]] = + commonSettings ++ Publish.settings + + def commonExamplesSettings: Seq[Def.Setting[_]] = + commonSettings ++ Publish.skipSettings + + private def commonSettings = + Seq( + organization := "com.zengularity", + crossPaths := false, + scalacOptions ++= scalacOptionsVersion(scalaVersion.value), + scalacOptions in (Compile, console) ~= (_.filterNot( + Set( + "-Ywarn-unused:imports", + "-Xfatal-warnings" + ) + )), + scalacOptions in (Test, compile) ~= (_.filterNot( + Set( + "-Ywarn-unused:imports", + "-Xfatal-warnings", + "-Yrangepos" + ) + )), + resolvers ++= Seq[Resolver]( + Resolver.sonatypeRepo("releases") + ) + ) + + private def scalacOptionsVersion(scalaVersion: String) = { + val defaultOptions = Seq( + "-deprecation", // Emit warning and location for usages of deprecated APIs. + "-encoding", + "utf-8", // Specify character encoding used by source files. + "-explaintypes", // Explain type errors in more detail. + "-feature", // Emit warning and location for usages of features that should be imported explicitly. + "-unchecked", // Enable additional warnings where generated code depends on assumptions. + "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. + "-Xfatal-warnings", // Fail the compilation if there are any warnings. + "-Xlint", + "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. + "-Ypartial-unification", // Enable partial unification in type constructor inference + "-Ywarn-dead-code", // Warn when dead code is identified. + "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. + "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. + "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. + "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. + "-Ywarn-numeric-widen", // Warn when numerics are widened. + "-Ywarn-unused", // Warn if unused. + "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. + ) + val v2_11_Options = Seq( + "-Xsource:2.12" // See https://github.com/scala/scala/releases/tag/v2.11.11 + ) + val v2_12_Options = Seq( + "-Ywarn-extra-implicit" // Warn when more than one implicit parameter section is defined. + ) + + CrossVersion.partialVersion(scalaVersion) match { + case Some((2L, 11L)) => defaultOptions ++ v2_11_Options + case _ => defaultOptions ++ v2_12_Options + } + } +} diff --git a/version.sbt b/version.sbt new file mode 100644 index 0000000..a3a28d6 --- /dev/null +++ b/version.sbt @@ -0,0 +1 @@ +ThisBuild / version := "0.0.1-SNAPSHOT"