Skip to content

Use sbt as build tool #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .m2/maven-version-rules.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .m2/travis-ci-toolchains.xml

This file was deleted.

29 changes: 7 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
language: scala
os: linux
jdk:
- openjdk8

cache:
directories:
- "$HOME/.m2"
- $HOME/.sbt/
- $HOME/.ivy2/cache
- $HOME/.cache/coursier

install:
- which java
- mvn install -DskipTests=true -DskipITs=true -Dmaven.javadoc.skip=true -B -V --toolchains .m2/travis-ci-toolchains.xml

jobs:
include:
- stage: test
scala:
- 2.11.12
script: mvn test -pl scala/scala_2.11 -B --toolchains .m2/travis-ci-toolchains.xml
jdk: openjdk8
- stage: test
scala:
- 2.12.11
script: mvn test -pl scala/scala_2.12,examples -B --toolchains .m2/travis-ci-toolchains.xml
jdk: openjdk8
- stage: test
scala:
- 2.13.2
script: mvn test -pl scala/scala_2.13,examples -B --toolchains .m2/travis-ci-toolchains.xml
jdk: openjdk8
script:
- sbt +compile +test

branches:
only:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/master/CH

### Changed

- [Build] Use sbt for building the project

### Deprecated

### Removed
Expand Down
34 changes: 7 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
SHELL := /usr/bin/env bash

default:
mvn clean install
sbt clean +publishLocal
.PHONY: default

VERSION = $(shell mvn help:evaluate -Dexpression=project.version -q -DforceStdout 2> /dev/null)
VERSION = $(shell sbt "print cucumberScala/version" | tail -n 1)
NEW_VERSION = $(subst -SNAPSHOT,,$(VERSION))
CURRENT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)

clean:
mvn clean release:clean
sbt clean
.PHONY: clean

version:
Expand All @@ -18,24 +18,6 @@ version:
@echo ""
.PHONY: version

update-compatibility:
MSG_VERSION=$$(mvn help:evaluate -Dexpression=messages.version -q -DforceStdout 2> /dev/null) && \
git clone --branch messages/v$$MSG_VERSION [email protected]:cucumber/cucumber.git target/cucumber
rm -rf compatibility/src/test/resources/*
cp -r target/cucumber/compatibility-kit/javascript/features compatibility/src/test/resources
rm -rf target/cucumber
.PHONY: update-compatibility

update-dependency-versions:
mvn versions:force-releases
mvn versions:update-properties -DallowMajorUpdates=false -Dmaven.version.rules="file://`pwd`/.m2/maven-version-rules.xml"
.PHONY: update-dependency-versions

update-major-dependency-versions:
mvn versions:force-releases
mvn versions:update-properties -DallowMajorUpdates=true -Dmaven.version.rules="file://`pwd`/.m2/maven-version-rules.xml"
.PHONY: update-major-dependency-versions

update-installdoc:
cat docs/install.md | ./scripts/update-install-doc.sh $(NEW_VERSION) > docs/install.md.tmp
mv docs/install.md.tmp docs/install.md
Expand All @@ -53,15 +35,12 @@ update-changelog:

.release-in-docker: default update-changelog update-installdoc .commit-and-push-changelog-and-docs
[ -f '/home/cukebot/import-gpg-key.sh' ] && /home/cukebot/import-gpg-key.sh
mvn --batch-mode release:clean release:prepare -DautoVersionSubmodules=true -Darguments="-DskipTests=true -DskipITs=true -Darchetype.test.skip=true"
git checkout "v$(NEW_VERSION)"
mvn deploy -P-examples -P-compatibility -Psign-source-javadoc -DskipTests=true -DskipITs=true -Darchetype.test.skip=true
git checkout $(CURRENT_BRANCH)
git fetch
sbt release cross with-defaults
.PHONY: release-in-docker

release:
[ -d '../secrets' ] || git clone keybase://team/cucumberbdd/secrets ../secrets
git -C ../secrets reset HEAD --hard
git -C ../secrets pull
../secrets/update_permissions
docker pull cucumber/cucumber-build:latest
Expand All @@ -70,7 +49,8 @@ release:
--volume "${shell pwd}/../secrets/import-gpg-key.sh":/home/cukebot/import-gpg-key.sh \
--volume "${shell pwd}/../secrets/codesigning.key":/home/cukebot/codesigning.key \
--volume "${shell pwd}/../secrets/.ssh":/home/cukebot/.ssh \
--volume "${HOME}/.m2"/repository:/home/cukebot/.m2/repository \
--volume "${HOME}/.ivy2":/home/cukebot/.ivy2 \
--volume "${HOME}/.cache/coursier":/home/cukebot/.cache/coursier \
--volume "${HOME}/.gitconfig":/home/cukebot/.gitconfig \
--env-file ../secrets/secrets.list \
--user 1000 \
Expand Down
10 changes: 4 additions & 6 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ Is the build passing?

```
git checkout main
sbt clean +test
```

Also check if you can upgrade any dependencies:

```
make update-dependency-versions
```
- check RenovateBot open Merge Requests on Github

## Decide what the next version should be ##

Expand All @@ -37,10 +35,10 @@ Display future version by running:
make version
```

Check if branch name and version are as expected. To change version run:
Check if branch name and version are as expected. To change version, update the _version.sbt_ file:

```
mvn versions:set -DnewVersion=X.Y.Z-SNAPSHOT
version in ThisBuild := "6.8.3-SNAPSHOT"
```

## Secrets ##
Expand Down
135 changes: 135 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@

import ReleaseTransformations._
import xerial.sbt.Sonatype.sonatypeSettings

// Metadata

ThisBuild / organization := "io.cucumber"
ThisBuild / organizationName := "Cucumber"
ThisBuild / organizationHomepage := Some(url("https://github.com/cucumber"))
ThisBuild / scmInfo := Some(ScmInfo(url("https://github.com/cucumber/cucumber-jvm-scala"), "scm:[email protected]:cucumber/cucumber-jvm-scala.git"))
ThisBuild / developers := List(
Developer("cucumber", "Cucumber Developers", "[email protected]", url("https://github.com/cucumber"))
)
ThisBuild / licenses := Seq(
"MIT License" -> url("http://www.opensource.org/licenses/mit-license")
)
ThisBuild / description := "Cucumber for Scala"
ThisBuild / homepage := Some(url("https://github.com/cucumber/cucumber-jvm-scala"))

// Scala versions

val scala211 = "2.11.12"
val scala212 = "2.12.12"
val scala213 = "2.13.3"

scalaVersion := scala213

// Library versions

val cucumberVersion = "6.8.2"
val jacksonVersion = "2.11.3"
val mockitoScalaVersion = "1.16.3"
val junitVersion = "4.13.1"

// Projects and settings

lazy val commonSettings = Seq(
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test,
scalacOptions += "-target:jvm-1.8",
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => ScalacOptions.scalacOptions211
case Some((2, 12)) => ScalacOptions.scalacOptions212
case Some((2, 13)) => ScalacOptions.scalacOptions213
case _ => Seq()
}
},
)

lazy val root = (project in file("."))
.settings(commonSettings)
.settings(
publishArtifact := false
)
.aggregate(
cucumberScala.projectRefs ++
examples.projectRefs: _*
)

// Main project
lazy val cucumberScala = (projectMatrix in file("cucumber-scala"))
.settings(commonSettings)
.settings(
name := "cucumber-scala",
libraryDependencies ++= Seq(
"io.cucumber" % "cucumber-core" % cucumberVersion,

// Users have to provide it (for JacksonDefaultDataTableTransformer)
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Provided,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion % Provided,

"junit" % "junit" % junitVersion % Test,
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
"org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n <= 12 => List("org.scala-lang.modules" %% "scala-collection-compat" % "2.2.0")
case _ => Nil
}
},
unmanagedSourceDirectories in Compile ++= {
val sourceDir = (sourceDirectory in Compile).value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n <= 11 => Seq(sourceDir / "scala-2.11")
case _ => Seq()
}
},
// Generate I18n traits
Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "io/cucumber/scala" / "I18n.scala"
IO.write(file, I18nGenerator.i18n)
Seq(file)
}.taskValue
)
.jvmPlatform(scalaVersions = Seq(scala213, scala212, scala211))

// Examples project
lazy val examples = (projectMatrix in file("examples"))
.settings(commonSettings)
.settings(
name := "scala-examples",
libraryDependencies ++= Seq(
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
"junit" % "junit" % junitVersion % Test
),
publishArtifact := false
)
.dependsOn(cucumberScala % Test)
.jvmPlatform(scalaVersions = Seq(scala213, scala212))

// Release & Publish

Global / publishMavenStyle := true
Global / publishTo := sonatypePublishToBundle.value

// https://github.com/sbt/sbt-pgp/issues/173
Global / PgpKeys.gpgCommand := (baseDirectory.value / "gpg.sh").getAbsolutePath

// https://github.com/xerial/sbt-sonatype#using-with-sbt-release-plugin
ThisBuild / releaseCrossBuild := true
ThisBuild / releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.cucumber.scala

import io.cucumber.scala.Aliases.{DefaultDataTableCellTransformerBody, DefaultDataTableEntryTransformerBody, DefaultParameterTransformerBody}
import Aliases.{DefaultDataTableCellTransformerBody, DefaultDataTableEntryTransformerBody, DefaultParameterTransformerBody}

case class ScalaDefaultParameterTransformerDetails(body: DefaultParameterTransformerBody)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.cucumber.scala

import io.cucumber.scala.Aliases.DocStringDefinitionBody
import Aliases.DocStringDefinitionBody

import scala.reflect.ClassTag

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.cucumber.scala

import io.cucumber.scala.Aliases._
import Aliases._

import scala.reflect.ClassTag

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.cucumber.scala

import io.cucumber.scala.HookType.{AFTER, AFTER_STEP, BEFORE, BEFORE_STEP}
import HookType.{AFTER, AFTER_STEP, BEFORE, BEFORE_STEP}

class ScalaDslRegistry {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.cucumber.scala

import io.cucumber.scala.Aliases.HookDefinitionBody
import Aliases.HookDefinitionBody

case class ScalaHookDetails(tagExpression: String, order: Int, body: HookDefinitionBody)
Loading