shuwariafrica / sbt-shuwari   0.14.2

Apache License 2.0 GitHub

Collection of sbt plugins for uniform configuration of Shuwari Africa Ltd. sbt projects, as well as CI and Release related functionality.

Scala versions: 2.12
sbt plugins: 1.x

sbt-shuwari

A collection of sbt plugins designed to provide unified configuration and extended build functionality for Shuwari Africa Ltd. projects. It also includes CI/CD and release-related optimisations.

While optimised for internal use, these plugins can be used for other projects where their configurations are relevant. Report any issues via the issue tracker.

Maven Central Build Status Board Status


Table of Contents

  1. Introduction
  2. Usage
  3. Core Plugins
    • ShuwariCorePlugin
    • ShuwariHeaderPlugin
    • BuildModePlugin
    • ScalacOptionsPlugin
  4. Supplementary Plugins
    • ShuwariJsPlugin
  5. Licence

Introduction

sbt-shuwari is a suite of sbt plugins tailored to Shuwari Africa Ltd. projects. It offers:

  • Centralised default settings for organising sbt builds.
  • Advanced integration to manage build environments (Development, Integration, Release).
  • Plugins for adding standardised headers to source files.
  • Default configurations for scalac and Scala.js.

Usage

To include all core plugins in your build, add the following to plugins.sbt:

addSbtPlugin("africa.shuwari.sbt" % "sbt-shuwari" % "0.14.1")

Individual plugins can also be added selectively by specifying their dependencies. See the specific plugin details below.


Core Plugins

All core plugins are AutoPlugins, meaning they are enabled automatically if their dependencies are met.

ShuwariCorePlugin
addSbtPlugin("africa.shuwari.sbt" % "sbt-shuwari-core" % "0.14.1")

Features:

  • Automatically sets common settings such as organizationName, organizationHomepage, and versionScheme.
  • Includes developer information and other organisational settings for standardisation.
  • Ensures projects can be omitted from publishing if required.

Available Utilities & Settings

  • shuwariProject:
    • Adds organisational defaults like organizationName, organizationHomepage, and developers.
    • Default settings:
      organizationName := "Shuwari Africa Ltd."
      organizationHomepage := Some(url("https://shuwari.africa"))
      versionScheme := Some("semver-spec")
      developers := List(
        Developer(
          "shuwari-dev",
          "Shuwari Africa Ltd. Developer Team",
          "developers at shuwari dot africa",
          url("https://shuwari.africa")
        )
      )
  • notPublished:
    • Configures the project to skip all publishing tasks.
    • Default settings:
      publish / skip := true
      publish := {}
      publishLocal := {}
      publishArtifact := false
  • dependsOn:
    • Simplified utility to depend on external libraries.

Example usage:

lazy val myProject = project
  .shuwariProject
  .notPublished

ShuwariHeaderPlugin
addSbtPlugin("africa.shuwari.sbt" % "sbt-shuwari-header" % "0.14.1")

Features:

  • Automatically detects the licensing model used in your project.
  • Supports custom, Apache 2.0, or GPLv3-style licence headers.
  • Includes configurable copyright holders.

Available Configuration Keys

  • headerCopyrightHolder:

    • Defines the entity owning the copyright.
    • Default: None.
  • headerLicense:

    • The licence header included in source files.
    • Default: Automatically detects from the project configuration.
      • Defaults to an internal licence if no licence is specified.
      • Can be explicitly set to Apache 2.0 or GPLv3 headers.

Example:

lazy val project = (project in file("."))
  .settings(apacheLicensed)

BuildModePlugin
addSbtPlugin("africa.shuwari.sbt" % "sbt-shuwari-mode" % "0.14.1")

Features:

  • Dynamically resolves the buildMode from the BUILD_MODE environment variable.
  • Configures different behaviours for development, integration, and release builds.

Available Configuration Keys

  • buildMode:
    • Configures the current build mode.
    • Default: Automatically detects from BUILD_MODE, defaults to Development. Valid values:
      • "DEVELOPMENT"Mode.Development.
      • "INTEGRATION"Mode.Integration.
      • "RELEASE"Mode.Release.

Example:

ThisBuild / buildMode := Mode.Release

ScalacOptionsPlugin
addSbtPlugin("africa.shuwari.sbt" % "sbt-shuwari-scalac" % "0.14.1")

Features:

  • Seamlessly integrates with BuildModePlugin and TpolecatPlugin, enabling dynamic assignment of scalac options.

  • Adjusts configurations for stricter linting and compilation optimisations based on the active build mode.

  • tpolecatOptionsMode:

    • Dynamically maps TpolecatPlugin modes to the current build mode, as provided by sbt-shuwari-mode. This ensures tailored compiler flags for various scenarios:
      • VerboseMode corresponds to Mode.Development, promoting detailed feedback for debugging.
      • CiMode aligns with Mode.Integration, focusing on consistency and maintainability.
      • ReleaseMode associates with Mode.Release, ensuring production-ready builds.

    For more details, refer to the section on sbt-shuwari-mode.

Available Configuration Keys:

  • basePackages:

    • A list of base package names used to tune deeper optimisations across the project.
    • Default: List.empty.
  • tpolecatDevModeOptions, tpolecatCiModeOptions, tpolecatReleaseModeOptions:

    • These keys provide customisation points for scalac options unique to each build mode. Use them to override or extend default configurations.

Supplementary Plugins

ShuwariJsPlugin
addSbtPlugin("africa.shuwari.sbt" % "sbt-shuwari-js" % "0.14.1")

Available Configuration Keys

  • scalaJSLinkerConfig:
    • Configures the linker for Scala.js builds, automatically adjusting based on the current buildMode.

Linker Configurations Employed

  • Development Mode:
    Configured for faster builds and easier debugging. Uses ES modules for compatibility with modern JavaScript environments and applies the FewestModules strategy for minimal module splitting.

  • Release/Integration Mode:
    Optimised for production and integration builds. Uses the SmallestModules splitting strategy for reducing bundle sizes and enables Closure Compiler for advanced optimisations.

  • tpolecatExcludeOptions:

    • Excludes Scala.js-incompatible scalac options, such as:
      • explicitNulls
      • JVM-specific checks like checkMods.

Licence

Copyright © Shuwari Africa Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "Licence"). You may obtain a copy at:
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the Licence
is distributed on an"AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
See the Licence for details.