Skip to content

move to sbt 1. don't support or publish for 0.13 anymore #50

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 4 commits into from
Feb 16, 2019
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
8 changes: 0 additions & 8 deletions .sbtrepos

This file was deleted.

29 changes: 7 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
language: scala

# Needed for openjdk6
dist: precise
sudo: required
addons:
hosts:
- localhost
hostname: localhost.local

jdk:
- openjdk6

# cache stuff, hopefully shortening build times
cache:
directories:
- $HOME/.ivy2
- $HOME/.sbt/boot
- $HOME/.sbt/launchers
- oraclejdk8

script:
# work around https://github.com/travis-ci/travis-ci/issues/9713
- if [[ $JAVA_HOME = *java-6* ]]; then jdk_switcher use openjdk6; fi
- java -version
# also, Maven Central and Bintray are unreachable over HTTPS
- if [[ $JAVA_HOME = *java-6* ]]; then SBTOPTS="-Dsbt.override.build.repos=true -Dsbt.repository.config=./.sbtrepos"; fi
- sbt $SBTOPTS test
- sbt test

before_cache:
- find $HOME/.sbt -name "*.lock" | xargs rm
- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
cache:
directories:
- $HOME/.ivy2
- $HOME/.sbt/boot
- $HOME/.sbt/launchers

notifications:
email:
Expand Down
48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
# Scala modules sbt plugin

This is an sbt plugin for building Scala modules (scala-xml,
scala-parser-combinators, and so on).
This is an sbt plugin for building Scala modules.

The major benefit of the plugin is to provide automated tag-based
publishing. A release is made by pushing a tag to GitHub. Travis
then stages artifacts on Sonatype. Pressing "Close" and "Release" in
the Sonatype web UI will then send the artifacts to Maven Central.
## What modules use it?

* [scala-async](https://github.com/scala/scala-async)
* [scala-collection-compat](https://github.com/scala/scala-collection-compat)
* [scala-java8-compat](https://github.com/scala/scala-java8-compat)
* [scala-parallel-collections](https://github.com/scala/scala-parallel-collections)
* [scala-parser-combinators](https://github.com/scala/scala-parser-combinators)
* [scala-partest](https://github.com/scala/scala-partest)
* [scala-swing](https://github.com/scala/scala-swing)
* [scala-xml](https://github.com/scala/scala-xml)

## 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.

## Branches and versions

The main development branch is 2.x; only sbt 1 is supported there.

sbt 0.13 support is on the legacy 1.x branch.

Scala modules are encouraged to move to sbt 1 on their primary
development branches as soon as reasonably possible.

## Usage

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

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

Then, in your `build.sbt` add:
Expand All @@ -22,7 +47,7 @@ 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 (example: scala-parallel-collections)
// 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
Expand All @@ -35,13 +60,10 @@ scalaVersionsByJvm in ThisBuild := {
val v211 = "2.11.12"
val v212 = "2.12.8"
val v213 = "2.13.0-M5"

// Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
Map(
6 -> List(v211 -> true),
7 -> List(v211 -> false),
8 -> List(v212 -> true, v213 -> true, v211 -> false),
9 -> List(v212, v213, v211).map(_ -> false))
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)
Expand Down
32 changes: 6 additions & 26 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
git.baseVersion := "1.0.0"
enablePlugins(SbtPlugin)

git.baseVersion := "2.0.0"
versionWithGit

name := "sbt-scala-module"

organization := "org.scala-lang.modules"

sbtPlugin := true

// sbtVersion in Global := "0.13.1"

// scalaVersion in Global := "2.10.3"

// publishTo := Some(if (version.value.trim.endsWith("SNAPSHOT")) Classpaths.sbtPluginSnapshots else Classpaths.sbtPluginReleases)

publishMavenStyle := false

resolvers += Classpaths.sbtPluginReleases

licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))

bintrayRepository := "sbt-plugins"

bintrayOrganization := None

// Version 0.9.1 requires Java 8 (on 6 we get NoClassDefFoundError: java/util/function/Predicate).
// We still run our plugin builds for 2.11 on Java 6, so we cannot upgrade.
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0")
name := "sbt-scala-module"
organization := "org.scala-lang.modules"
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.18
sbt.version=1.2.8
5 changes: 1 addition & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
// careful upgrading this; we can't move to a version that doesn't
// work on Java 6
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")
39 changes: 18 additions & 21 deletions src/main/scala/ScalaModulePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ package com.lightbend.tools.scalamoduleplugin
import com.typesafe.sbt.osgi.{OsgiKeys, SbtOsgi}
import com.typesafe.tools.mima.plugin.MimaKeys._
import com.typesafe.tools.mima.plugin.MimaPlugin

import sbt.Keys._
import sbt.{Def, _}
import sbt._
import sbt.internal.librarymanagement.IvySbt
import sbt.librarymanagement.ivy.IvyDependencyResolution
import sbt.librarymanagement.{ UnresolvedWarningConfiguration, UpdateConfiguration }

object ScalaModulePlugin extends AutoPlugin {
val repoName = settingKey[String]("The name of the repository under github.com/scala/.")
Expand Down Expand Up @@ -150,26 +154,18 @@ object ScalaModulePlugin extends AutoPlugin {

lazy val scalaModuleSettingsJVM: Seq[Setting[_]] = scalaModuleOsgiSettings

// adapted from https://github.com/typesafehub/migration-manager/blob/0.1.6/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala#L69
// adapted from https://github.com/lightbend/migration-manager/blob/0.3.0/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala#L112
private def artifactExists(organization: String, name: String, scalaBinaryVersion: String, version: String, ivy: IvySbt, s: TaskStreams): Boolean = {
val moduleId = new ModuleID(organization, s"${name}_$scalaBinaryVersion", version)
val moduleSettings = InlineConfiguration(
"dummy" % "test" % "version",
ModuleInfo("dummy-test-project-for-resolving"),
dependencies = Seq(moduleId))
val ivyModule = new ivy.Module(moduleSettings)
try {
IvyActions.update(
ivyModule,
new UpdateConfiguration(
retrieve = None,
missingOk = false,
logging = UpdateLogging.DownloadOnly),
s.log)
true
} catch {
case _: ResolveException => false
}
val moduleId = ModuleID(organization, s"${name}_$scalaBinaryVersion", version)
val depRes = IvyDependencyResolution(ivy.configuration)
val module = depRes.wrapDependencyInModule(moduleId)
val reportEither = depRes.update(
module,
UpdateConfiguration() withLogging UpdateLogging.DownloadOnly,
UnresolvedWarningConfiguration(),
s.log
)
reportEither.fold(_ => false, _ => true)
}

// Internal task keys for the MiMa settings
Expand All @@ -185,10 +181,11 @@ object ScalaModulePlugin extends AutoPlugin {
canRunMima := {
val mimaVer = mimaPreviousVersion.value
val s = streams.value
val ivySbt = Keys.ivySbt.value
if (mimaVer.isEmpty) {
s.log.warn("MiMa will NOT run because no mimaPreviousVersion is provided.")
false
} else if (!artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer.get, ivySbt.value, s)) {
} else if (!artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer.get, ivySbt, s)) {
s.log.warn(s"""MiMa will NOT run because the previous artifact "${organization.value}" % "${name.value}_${scalaBinaryVersion.value}" % "${mimaVer.get}" could not be resolved (note the binary Scala version).""")
false
} else {
Expand Down