Skip to content

Commit 9ce93ea

Browse files
authored
Merge pull request #50 from SethTisue/sbt-1
move to sbt 1. don't support or publish for 0.13 anymore
2 parents 4230120 + 3a2e5e7 commit 9ce93ea

File tree

7 files changed

+68
-95
lines changed

7 files changed

+68
-95
lines changed

Diff for: .sbtrepos

-8
This file was deleted.

Diff for: .travis.yml

+7-22
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
language: scala
22

3-
# Needed for openjdk6
4-
dist: precise
5-
sudo: required
6-
addons:
7-
hosts:
8-
- localhost
9-
hostname: localhost.local
10-
113
jdk:
12-
- openjdk6
13-
14-
# cache stuff, hopefully shortening build times
15-
cache:
16-
directories:
17-
- $HOME/.ivy2
18-
- $HOME/.sbt/boot
19-
- $HOME/.sbt/launchers
4+
- oraclejdk8
205

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

299
before_cache:
3010
- find $HOME/.sbt -name "*.lock" | xargs rm
3111
- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
12+
cache:
13+
directories:
14+
- $HOME/.ivy2
15+
- $HOME/.sbt/boot
16+
- $HOME/.sbt/launchers
3217

3318
notifications:
3419
email:

Diff for: README.md

+35-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,44 @@
11
# Scala modules sbt plugin
22

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

6-
The major benefit of the plugin is to provide automated tag-based
7-
publishing. A release is made by pushing a tag to GitHub. Travis
8-
then stages artifacts on Sonatype. Pressing "Close" and "Release" in
9-
the Sonatype web UI will then send the artifacts to Maven Central.
5+
## What modules use it?
6+
7+
* [scala-async](https://github.com/scala/scala-async)
8+
* [scala-collection-compat](https://github.com/scala/scala-collection-compat)
9+
* [scala-java8-compat](https://github.com/scala/scala-java8-compat)
10+
* [scala-parallel-collections](https://github.com/scala/scala-parallel-collections)
11+
* [scala-parser-combinators](https://github.com/scala/scala-parser-combinators)
12+
* [scala-partest](https://github.com/scala/scala-partest)
13+
* [scala-swing](https://github.com/scala/scala-swing)
14+
* [scala-xml](https://github.com/scala/scala-xml)
15+
16+
## Why this plugin?
17+
18+
Having a shared plugin reduces duplication between the above
19+
repositories. Reducing duplication makes maintenance easier and
20+
helps ensure consistency.
21+
22+
A major feature of the plugin is automated tag-based publishing. A
23+
release is made by pushing a tag to GitHub. Travis-CI then stages
24+
artifacts on Sonatype. Pressing "Close" and "Release" in the Sonatype
25+
web UI will then send the artifacts to Maven Central.
26+
27+
## Branches and versions
28+
29+
The main development branch is 2.x; only sbt 1 is supported there.
30+
31+
sbt 0.13 support is on the legacy 1.x branch.
32+
33+
Scala modules are encouraged to move to sbt 1 on their primary
34+
development branches as soon as reasonably possible.
1035

1136
## Usage
1237

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

1540
```
16-
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14")
41+
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0")
1742
```
1843

1944
Then, in your `build.sbt` add:
@@ -22,7 +47,7 @@ Then, in your `build.sbt` add:
2247
import ScalaModulePlugin._
2348
2449
scalaModuleSettings // in a multi-project build, you might want to apply these settings only to the
25-
// main project (example: scala-parallel-collections)
50+
// main project (see e.g. scala-parallel-collections)
2651
2752
name := "<module name>"
2853
repoName := "<GitHub repo name>" // the repo under github.com/scala/, only required if different from name
@@ -35,13 +60,10 @@ scalaVersionsByJvm in ThisBuild := {
3560
val v211 = "2.11.12"
3661
val v212 = "2.12.8"
3762
val v213 = "2.13.0-M5"
38-
3963
// Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
4064
Map(
41-
6 -> List(v211 -> true),
42-
7 -> List(v211 -> false),
43-
8 -> List(v212 -> true, v213 -> true, v211 -> false),
44-
9 -> List(v212, v213, v211).map(_ -> false))
65+
8 -> List(v211 -> true, v212 -> true, v213 -> true),
66+
9 -> List(v211, v212, v213).map(_ -> false))
4567
}
4668
4769
mimaPreviousVersion := Some("1.0.0") // enables MiMa (`None` by default, which disables it)

Diff for: build.sbt

+6-26
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
1-
git.baseVersion := "1.0.0"
1+
enablePlugins(SbtPlugin)
22

3+
git.baseVersion := "2.0.0"
34
versionWithGit
45

5-
name := "sbt-scala-module"
6-
7-
organization := "org.scala-lang.modules"
8-
9-
sbtPlugin := true
10-
11-
// sbtVersion in Global := "0.13.1"
12-
13-
// scalaVersion in Global := "2.10.3"
14-
15-
// publishTo := Some(if (version.value.trim.endsWith("SNAPSHOT")) Classpaths.sbtPluginSnapshots else Classpaths.sbtPluginReleases)
16-
17-
publishMavenStyle := false
18-
19-
resolvers += Classpaths.sbtPluginReleases
20-
21-
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))
22-
23-
bintrayRepository := "sbt-plugins"
24-
25-
bintrayOrganization := None
26-
27-
// Version 0.9.1 requires Java 8 (on 6 we get NoClassDefFoundError: java/util/function/Predicate).
28-
// We still run our plugin builds for 2.11 on Java 6, so we cannot upgrade.
29-
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0")
6+
name := "sbt-scala-module"
7+
organization := "org.scala-lang.modules"
8+
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))
309

10+
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4")
3111
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")

Diff for: project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.18
1+
sbt.version=1.2.8

Diff for: project/plugins.sbt

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
// careful upgrading this; we can't move to a version that doesn't
2-
// work on Java 6
3-
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")
4-
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
52
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")

Diff for: src/main/scala/ScalaModulePlugin.scala

+18-21
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ package com.lightbend.tools.scalamoduleplugin
33
import com.typesafe.sbt.osgi.{OsgiKeys, SbtOsgi}
44
import com.typesafe.tools.mima.plugin.MimaKeys._
55
import com.typesafe.tools.mima.plugin.MimaPlugin
6+
67
import sbt.Keys._
7-
import sbt.{Def, _}
8+
import sbt._
9+
import sbt.internal.librarymanagement.IvySbt
10+
import sbt.librarymanagement.ivy.IvyDependencyResolution
11+
import sbt.librarymanagement.{ UnresolvedWarningConfiguration, UpdateConfiguration }
812

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

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

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

175171
// Internal task keys for the MiMa settings
@@ -185,10 +181,11 @@ object ScalaModulePlugin extends AutoPlugin {
185181
canRunMima := {
186182
val mimaVer = mimaPreviousVersion.value
187183
val s = streams.value
184+
val ivySbt = Keys.ivySbt.value
188185
if (mimaVer.isEmpty) {
189186
s.log.warn("MiMa will NOT run because no mimaPreviousVersion is provided.")
190187
false
191-
} else if (!artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer.get, ivySbt.value, s)) {
188+
} else if (!artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer.get, ivySbt, s)) {
192189
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).""")
193190
false
194191
} else {

0 commit comments

Comments
 (0)