Skip to content

scala/sbt-scala-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scala modules sbt plugin

This is an sbt 1.x plugin for building Scala modules.

What modules use it?

Why this plugin?

Having a shared plugin reduces duplication between the above repositories. Reducing duplication makes maintenance easier and helps ensure consistency.

A major feature of the plugin is automated tag-based publishing using sbt-ci-release. A release is made by pushing a tag to GitHub.

The plugin also brings in

  • sbt-travisci to set the scalaVersion and crossScalaVersions
  • sbt-dynver to set the version based on the git history
  • sbt-header
  • sbt-osgi

Usage

Add the plugin to the project/plugins.sbt file:

addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.1.0") 

Then, in your build.sbt add:

// In a multi-project build, you might want to apply these settings only to the // main project (see e.g. scala-parallel-collections) ScalaModulePlugin.scalaModuleSettings // For JVM projects ScalaModulePlugin.scalaModuleSettingsJVM name := "<module name>" repoName := "<GitHub repo name>" // the repo under github.com/scala/, only required if different from name organization := "<org>" // only required if different from "org.scala-lang.modules" mimaPreviousVersion := Some("1.0.0") // enables MiMa (`None` by default, which disables it) OsgiKeys.exportPackage := Seq(s"<exported package>;version=${version.value}") // Other settings 

Scala versions are defined in .travis.yml.

Cross-building with Scala.js and Scala Native is possible, see scala-xml or scala-parser-combinators for example.

These additional settings are enabled by scalaModuleSettings:

  • scalacOptions in (Compile, compile) ++= Seq("-feature", "-deprecation", "-unchecked", "-Xlint")
  • A projectName.properties file is generated and packaged
  • fork in Test := true to work around some classpath clashes with scala-xml
  • POM and OSGi metadata

The following settings are also available:

  • enableOptimizer adds -opt-inline-from:<sources> or -opt:l:project or -optimize to scalacOptions in (Compile, compile), depending on the Scala version
  • disablePublishing is useful for multi-project builds for projects that should not be published

Set up tag-based publishing

The instructions here are a sumamry of the readme in https://github.com/olafurpg/sbt-ci-release

  • Create a fresh GPG key: gpg --gen-key

  • Get the key LONG_ID from the output and set LONG_ID=6E8ED79B03AD527F1B281169D28FC818985732D9

    pub rsa2048 2018-06-10 [SC] [expires: 2020-06-09] $LONG_ID 
  • Copy the public key to a key server

  • Open the Settings panel on your project's travis, define four secret env vars

    • PGP_PASSPHRASE the passphrase you chose above
    • PGP_SECRET the secret key in base64
      • macOS: gpg --armor --export-secret-keys $LONG_ID | base64
      • ubuntu: gpg --armor --export-secret-keys $LONG_ID | base64 -w0
    • SONATYPE_PASSWORD: need that one
    • SONATYPE_USERNAME: that one too

Cutting a new release (of this plugin)

Release notes

Tag the release and add release notes to https://github.com/scala/sbt-scala-module/releases

Publishing via Bintray

  • Sign in to Bintray (https://bintray.com/login) or create an "Open Source" account (https://bintray.com/signup/oss)

  • Check if you have a repository named sbt-plugins. If not, create it (Name: sbt-plugins, Type: Generic).

  • Make sure the current HEAD is a tagged revision. In sbt, version (set by sbt-git) should be according to a tag.

    > version [info] 2.3.4 
  • Run publish in sbt. If you don't have a ~/.bintray/.credentials file, the sbt-bintray plugin will ask you for your username and API key. The API key can be obtained under "Edit Profile" (https://bintray.com/profile/edit). The sbt-bintray plugin saves credentials to ~/.bintray/.credentials for future use.

  • If you haven't done so before, add your package for this plugin (https://bintray.com/YOUR_USERNAME/sbt-plugins/sbt-scala-module) to the community sbt repository (https://bintray.com/sbt/sbt-plugin-releases). Otherwise you're done, the release is available.

    • Check if you added your package by searching for "sbt-scala-module" in the repository.
    • If you cannot find your package, click "Include My Package"
    • Search for your plugin (sbt-scala-module)
    • Click "Send" to send the request

The above instructions are a short version of https://www.scala-sbt.org/1.x/docs/Bintray-For-Plugins.html.

About

sbt plugin for scala modules.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 14

Languages