aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: ab33606d4fd0296922169bde1f0c48febc098695 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
[![Build Status](https://travis-ci.org/drivergroup/sbt-settings.svg?branch=master)](https://travis-ci.org/drivergroup/sbt-settings)
[![Scaladex](https://index.scala-lang.org/drivergroup/sbt-settings/latest.svg)](https://index.scala-lang.org/drivergroup/sbt-settings)

# Common sbt settings

Provides common settings for Scala projects, as they are typically
configured at Driver.

sbt-settings is a suite of [sbt
autoplugins](https://www.scala-sbt.org/1.0/docs/Plugins.html) that
provide common settings for the scala compiler, testing, linting,
formatting, release process, packaging and publication.

## Getting started

Adding the following snippet to `project/plugins.sbt` will make the
plugins available:

```scala
addSbtPlugin("xyz.driver" % "sbt-settings" % "<latest_tag>")
```

The next section exlains what plugins are available and which ones are
activated out-of-the-box.

## Plugins

### Summary

| Name                     | Enabled                                |
|--------------------------|----------------------------------------|
| Linting                  | automatic                              |
| Versioning               | automatic                              |
| IntegrationTestPackaging | automatic, if ServicePlugin is enabled |
| Library                  | manual                                 |
| Service                  | manual                                 |

### Linting

*[source](src/main/scala/xyz.driver.sbt/Linting.scala)*

- Includes configuration for scalafmt and scalastyle, modifies the
  `test` task to check for formatting and styling.
- Sets strict compiler flags and treats warnings as errors (with the
  exception of deprecations).

This plugin can get in the way of developer productivity. If that is
the case, it can simply be disabled.

### Versioning

*[source](src/main/scala/xyz.driver.sbt/Versioning.scala)*

Sets the project organization and reads version information from
git. It also enables overriding the version by setting a `VERSION`
environment variable (which may be useful to do from CI).

### Integration Test Packaging

*[source](src/main/scala/xyz.driver.sbt/IntegrationTestPackaging.scala)*

Augments the packaging configuration of ServicePlugin, to include
integration tests in deployed applications images.

### Library Plugin

*[source](src/main/scala/xyz.driver.sbt/Library.scala)*

Common settings for libraries. It only sets the default publish
target to Driver's artifactory.

### Service Plugin

*[source](src/main/scala/xyz.driver.sbt/Service.scala)*

Packages an application as a docker image and provides a way to
include internal TLS certificates.

It also includes some utility commands such as `start` and `stop`
(based on [sbt-revolver](https://github.com/spray/sbt-revolver), to
enable rapid local development cycles of applications.

## Canonical Use Case
sbt-settings provides many plugins, which may be used in various
ways. Typically however, a project is either a Library or a Service,
and as such, it will enable one of those plugins explicitly. The other
plugins will provide general settings for common conventions and are
always enabled.

The following provides a typical example for configuring a project as
a service called "myservice":

```scala
lazy val myservice = project
  .in(file("."))
  .enablePlugin(ServicePlugin)
  .disablePlugins(IntegrationTestPackaging) // we don't need integration tests
  .disablePlugins(LintPlugin) // I don't need style check during development!
  .settings( /* custom settings */)
```

## Developing this Plugin
This project is set up to auto-deploy on push. If an annotated tag in
the form `v<digit>.*` is pushed, a new version of this project will be
built and published to Maven Central.