Skip to content

Commit

Permalink
Set up publishing to Entrepot
Browse files Browse the repository at this point in the history
  • Loading branch information
guilgaly committed Jan 21, 2019
1 parent 7918416 commit 359cc3f
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 71 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
80 changes: 12 additions & 68 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)
38 changes: 38 additions & 0 deletions project/Publish.scala
Original file line number Diff line number Diff line change
@@ -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")
)
)
}
69 changes: 69 additions & 0 deletions project/Settings.scala
Original file line number Diff line number Diff line change
@@ -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
}
}
}
1 change: 1 addition & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ThisBuild / version := "0.0.1-SNAPSHOT"

0 comments on commit 359cc3f

Please sign in to comment.