Skip to content

Commit

Permalink
Merge pull request #2 from electronicarts/tehzhed-publish-maven
Browse files Browse the repository at this point in the history
Configure publish settings
  • Loading branch information
Daniele Riccardelli authored Sep 28, 2020
2 parents d19edc4 + 2e4907b commit b208172
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 28 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kara

### Automated generation of [Finagle](https://twitter.github.io/finagle/) HTTP/JSON services and [Swagger UI](https://swagger.io/tools/swagger-ui/) from [Thrift](https://thrift.apache.org/) service definitions.
### Generate [Finagle](https://twitter.github.io/finagle/) HTTP/JSON services and [Swagger UI](https://swagger.io/tools/swagger-ui/) from [Thrift](https://thrift.apache.org/) service definitions.

------

Expand All @@ -15,7 +15,7 @@ And since a HTTP/JSON API is exposed, you don't necessarily have to deal with th

## Usage

- Add **kara** as a plugin to the sbt project adding a line containing `addSbtPlugin("com.ea" % "kara" % "0.1.0")` in `project/plugins.sbt`.
- Add **kara** as a plugin to the sbt project adding a line containing `addSbtPlugin("com.ea.kara" % "kara" % "0.1.0")` in `project/plugins.sbt`.
- In your project settings in `build.sbt`:
- configure `karaServices = Seq("fully_qualified_service_1", "fully_qualified_service_2, ...)` to indicate the Thrift services Kara should generate Finagle services and Swagger UI for. Services should be listed in `<JAVA_NAMESPACE>.<SERVICE_NAME>` format.
- enable the the plugin with `.enablePlugins(Kara)` on the project that lists the Thrift sources and on which `ScroogeSBT` is enabled.
Expand All @@ -27,7 +27,7 @@ On compilation (`sbt compile`), a Finagle HTTP service named `Http<SERVICE_NAME>
#### project/plugins.sbt

```scala
addSbtPlugin("com.ea" % "kara" % "0.1.0")
addSbtPlugin("com.ea.kara" % "kara" % "0.1.0")
```

#### build.sbt
Expand All @@ -38,7 +38,7 @@ addSbtPlugin("com.ea" % "kara" % "0.1.0")
lazy val thrift = project.in(file("thrift"))
.settings(
// ...
karaServices := Seq("path.to.Service1", "path.to.Service2")
karaServices := Seq("path.to.ExampleService1", "path.to.ExampleService2")
).enablePlugins(Kara)

// ...
Expand All @@ -62,7 +62,7 @@ Http.server.serve(":8080", karaSvc)

## Swagger UI

`kara` v.`0.1.0` employs Swagger UI v`.3.31.1`.
`kara` v.`0.1.0` employs Swagger UI v.`3.31.1`.

## Testing

Expand Down
37 changes: 29 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,47 @@ envVars ++= Map("CI_PROJECT_DIR" -> sys.env.getOrElse("CI_PROJECT_DIR", "."))

lazy val sbtOps = sys.env.get("SBT_OPTS").map(_.split(" ")).getOrElse(Array.empty)

lazy val publishSettings = Seq(
homepage := Some(url("https://github.com/electronicarts/kara")),
organization := "com.ea.kara",
licenses := Seq("The 3-Clause BSD License" -> url("http://opensource.org/licenses/BSD-3-Clause")),
publishMavenStyle := true,
publishTo := sonatypePublishToBundle.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/electronicarts/kara"),
"scm:git:[email protected]:electornicarts/kara.git"
)
),
pomExtra :=
<developers>
<developer>
<name>Electronic Arts Inc.</name>
<url>https://ea.com</url>
</developer>
</developers>
)

lazy val root = (project in file("."))
.enablePlugins(ScriptedPlugin)
.settings(
publishSettings,
addSbtPlugin("com.twitter" % "scrooge-sbt-plugin" % finagleVersion),
libraryDependencies ++= Seq(
"commons-io" % "commons-io" % "2.7",
"org.scalatra.scalate" %% "scalate-core" % "1.9.6",
"com.twitter" %% "finagle-http" % finagleVersion % Test,
"io.circe" %% "circe-yaml" % "0.13.0",
"com.github.pathikrit" %% "better-files" % "3.9.1",
"io.swagger.parser.v3" % "swagger-parser" % "2.0.21" % Test,
"org.scalatest" %% "scalatest" % "3.2.1" % Test
"commons-io" % "commons-io" % "2.7",
"org.scalatra.scalate" %% "scalate-core" % "1.9.6",
"com.twitter" %% "finagle-http" % finagleVersion % Test,
"io.circe" %% "circe-yaml" % "0.13.0",
"com.github.pathikrit" %% "better-files" % "3.9.1",
"io.swagger.parser.v3" % "swagger-parser" % "2.0.21" % Test,
"org.scalatest" %% "scalatest" % "3.2.1" % Test
),
scriptedLaunchOpts ++= Seq(
"-Xmx1024M",
"-Dplugin.version=" + version.value
) ++ sbtOps,
scriptedBufferLog := false,
name := "kara",
organization := "com.ea",
sbtPlugin := true,
scalaVersion := "2.12.12"
)
Expand Down
10 changes: 5 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# kara
### Automated generation of [Finagle](https://twitter.github.io/finagle/) HTTP/JSON services and [Swagger UI](https://swagger.io/tools/swagger-ui/) from [Thrift](https://thrift.apache.org/) service definitions.
### Generate [Finagle](https://twitter.github.io/finagle/) HTTP/JSON services and [Swagger UI](https://swagger.io/tools/swagger-ui/) from [Thrift](https://thrift.apache.org/) service definitions.

------

Expand All @@ -13,7 +13,7 @@ And since a HTTP/JSON API is exposed, you don't necessarily have to deal with th
**NOTE**: while extremely useful during development, **kara** is not intended for production use.

## Usage
- Add **kara** as a plugin to the sbt project adding a line containing `addSbtPlugin("com.ea" % "kara" % "@VERSION@")` in `project/plugins.sbt`.
- Add **kara** as a plugin to the sbt project adding a line containing `addSbtPlugin("com.ea.kara" % "kara" % "@VERSION@")` in `project/plugins.sbt`.
- In your project settings in `build.sbt`:
- configure `karaServices = Seq("fully_qualified_service_1", "fully_qualified_service_2, ...)` to indicate the Thrift services Kara should generate Finagle services and Swagger UI for. Services should be listed in `<JAVA_NAMESPACE>.<SERVICE_NAME>` format.
- enable the the plugin with `.enablePlugins(Kara)` on the project that lists the Thrift sources and on which `ScroogeSBT` is enabled.
Expand All @@ -24,7 +24,7 @@ On compilation (`sbt compile`), a Finagle HTTP service named `Http<SERVICE_NAME>

#### project/plugins.sbt
```scala
addSbtPlugin("com.ea" % "kara" % "@VERSION@")
addSbtPlugin("com.ea.kara" % "kara" % "@VERSION@")
```

#### build.sbt
Expand All @@ -34,7 +34,7 @@ addSbtPlugin("com.ea" % "kara" % "@VERSION@")
lazy val thrift = project.in(file("thrift"))
.settings(
// ...
karaServices := Seq("path.to.Service1", "path.to.Service2")
karaServices := Seq("path.to.ExampleService1", "path.to.ExampleService2")
).enablePlugins(Kara)

// ...
Expand All @@ -56,7 +56,7 @@ Http.server.serve(":8080", karaSvc)
[Scripted tests](./src/sbt-test/kara/) are a great way to see **kara** in action.

## Swagger UI
`kara` v.`@VERSION@` employs Swagger UI v`.3.31.1`.
`kara` v.`@VERSION@` employs Swagger UI v.`3.31.1`.

## Testing
**kara** features two modes of testing:
Expand Down
2 changes: 1 addition & 1 deletion project/metals.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DO NOT EDIT! This file is auto-generated.
// This file enables sbt-bloop to create bloop config files.

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.3")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.4-13-408f4d80")
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.3.6")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.4")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
2 changes: 1 addition & 1 deletion src/sbt-test/kara/declaration_order/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.ea" % "kara" % x)
case Some(x) => addSbtPlugin("com.ea.kara" % "kara" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
}
2 changes: 1 addition & 1 deletion src/sbt-test/kara/dirty/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.ea" % "kara" % x)
case Some(x) => addSbtPlugin("com.ea.kara" % "kara" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
}
2 changes: 1 addition & 1 deletion src/sbt-test/kara/e2e/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.ea" % "kara" % x)
case Some(x) => addSbtPlugin("com.ea.kara" % "kara" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
}
2 changes: 1 addition & 1 deletion src/sbt-test/kara/imports/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.ea" % "kara" % x)
case Some(x) => addSbtPlugin("com.ea.kara" % "kara" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
}
7 changes: 2 additions & 5 deletions version.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
* Copyright (C) 2020 Electronic Arts Inc. All rights reserved.
*/

// Make 'version' a SNAPSHOT only when publishing on a developer machine,
// or when it's forced in CI via 'kara.isSnapshot' flag.
def buildSuffix: String = {
val isSnapshotForced = sys.props.get("kara.isSnapshot").exists(_.toBoolean)
val isNotCI = Option(java.lang.System.getenv("BUILD_NUMBER")).isEmpty
if (isSnapshotForced || isNotCI) "-SNAPSHOT" else ""
val isSnapshot = sys.props.get("kara.isSnapshot").exists(_.toBoolean)
if (isSnapshot) "-SNAPSHOT" else ""
}

version in ThisBuild := "0.1.0" + buildSuffix

0 comments on commit b208172

Please sign in to comment.