Code Monkey home page Code Monkey logo

sbt-scala-module's Introduction

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. A release is made by pushing a tag to GitHub. Travis-CI then stages artifacts on Sonatype. Pressing "Close" and "Release" in the Sonatype web UI will then send the artifacts to Maven Central.

Usage

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

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

Then, in your build.sbt add:

import ScalaModulePlugin._

scalaModuleSettings // in a multi-project build, you might want to apply these settings only to the
                    // main project (see e.g. scala-parallel-collections)

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"
version      := "<module version>"

// The plugin uses `scalaVersionsByJvm` to set `crossScalaVersions in ThisBuild` according to the JVM major version.
// The `scalaVersion in ThisBuild` is set to `crossScalaVersions.value.head`.
scalaVersionsByJvm in ThisBuild := {
  val v211 = "2.11.12"
  val v212 = "2.12.8"
  val v213 = "2.13.0-RC1"
  // Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
  Map(
    8 -> List(v211 -> true, v212 -> true, v213 -> true),
    9 -> List(v211, v212, v213).map(_ -> false))
}

mimaPreviousVersion := Some("1.0.0") // enables MiMa (`None` by default, which disables it)

OsgiKeys.exportPackage := Seq(s"<exported package>;version=${version.value}")

// Other settings

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
  • publishTo sonatype, credentials file expected in ~/.ivy2/.credentials
  • 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

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.

sbt-scala-module's People

Contributors

sethtisue avatar lrytz avatar adriaanm avatar retronym avatar scala-steward avatar dwijnand avatar jsuereth avatar gkossakowski avatar xuwei-k avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.