Skip to content

Commit d08c6e2

Browse files
authored
Merge pull request #60 from lrytz/scalaVersionsByJvm
Upgrade scala-module-plugin, use scalaVersionsByJvm
2 parents e56c042 + d4f46f5 commit d08c6e2

File tree

6 files changed

+64
-43
lines changed

6 files changed

+64
-43
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: scala
22

33
env:
44
global:
5-
- PUBLISH_JDK=openjdk6
65
# PGP_PASSPHRASE
76
- secure: "MIHv2s6njtXubCzbP/eYXszuO/Y3FADYATZpDtOULZmQHcQ8z+sccQHidyq6hvoK9/I2hRUrc5RIelfA7D32tqP7aF3P9Dq1ZdiWqZYmFKUl6wzJMhgWwnT1RA9Nu67PcNLZGwOe7+55zZpWVNbeTKMe05TzUaaGUgApr9wvS0I="
87
# SONA_USER

admin/README.md

+32-21
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,40 @@ To configure tag driven releases from Travis CI.
1717
Edit `.travis.yml` as prompted.
1818
1. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
1919
and edit that script to use the tasks required for this project.
20-
1. Edit `.travis.yml` to select which JDK will be used for publishing.
20+
1. Edit `build.sbt`'s `scalaVersionsByJvm` to select Scala and JVM version combinations that
21+
will be used for publishing.
2122

22-
It is important to add comments in .travis.yml to identify the name
23+
It is important to add comments in `.travis.yml` to identify the name
2324
of each environment variable encoded in a `:secure` section.
2425

25-
After all of these steps, your .travis.yml should contain config of the
26-
form:
27-
28-
language: scala
29-
env:
30-
global:
31-
- PUBLISH_JDK=oraclejdk8
32-
# PGP_PASSPHRASE
33-
- secure: "XXXXXX"
34-
# SONA_USER
35-
- secure: "XXXXXX"
36-
# SONA_PASS
37-
- secure: "XXXXXX"
38-
script: admin/build.sh
26+
After these steps, your `.travis.yml` should contain config of the form:
27+
28+
```
29+
language: scala
30+
31+
env:
32+
global:
33+
# PGP_PASSPHRASE
34+
- secure: "XXXXXX"
35+
# SONA_USER
36+
- secure: "XXXXXX"
37+
# SONA_PASS
38+
- secure: "XXXXXX"
39+
40+
script: admin/build.sh
41+
42+
jdk:
43+
- openjdk6
44+
- oraclejdk8
45+
46+
notifications:
47+
email:
48+
49+
```
3950

4051
If Sonatype credentials change in the future, step 3 can be repeated
4152
without generating a new key.
4253

43-
Be sure to use SBT 0.13.7 or higher to avoid [#1430](https://github.com/sbt/sbt/issues/1430)!
44-
4554
### Testing
4655

4756
1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`).
@@ -52,9 +61,11 @@ Be sure to use SBT 0.13.7 or higher to avoid [#1430](https://github.com/sbt/sbt/
5261

5362
1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub
5463
web interface.
55-
1. The release will be published using all Scala versions in `build.sbt`'s `crossScalaVersions`.
56-
If you need to release it against a different Scala version, include it in the tag
57-
name after a `#` (e.g., `v0.1.1#2.13.0-M1`).
64+
1. The release will be published using the Scala and JVM version combinations specified
65+
in `scalaVersionsByJvm` in `build.sbt`.
66+
- If you need to release against a different Scala version, include the Scala version
67+
and the JVM version to use in the tag name, separated by `#`s (e.g., `v0.1.1#2.13.0-M1#8`).
68+
Note that the JVM version needs to be listed in `.travis.yml` for the build to run.
5869
1. Travis CI will schedule a build for this release. Review the build logs.
5970
1. Log into https://oss.sonatype.org/ and identify the staging repository.
6071
1. Sanity check its contents.

admin/build.sh

+18-8
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,31 @@ set -e
1212
# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`.
1313

1414
# When a new, binary incompatible Scala version becomes available, a previously released version
15-
# can be released using that new Scala version by creating a new tag containing the Scala version
16-
# after a hash, e.g., v1.2.3#2.13.0-M1.
15+
# can be released using that new Scala version by creating a new tag containing the Scala and the
16+
# JVM version after hashes, e.g., v1.2.3#2.13.0-M1#8. The JVM version needs to be listed in
17+
# `.travis.yml`, otherwise the required build doesn't run.
1718

1819
verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
19-
tagPat="^v$verPat(#$verPat)?$"
20+
tagPat="^v$verPat(#$verPat#[0-9]+)?$"
2021

21-
if [ "$TRAVIS_JDK_VERSION" == "$PUBLISH_JDK" ] && [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
22-
echo "Going to release from tag $TRAVIS_TAG!"
22+
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
23+
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
2324

2425
tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//)
2526
publishVersion='set every version := "'$tagVer'"'
2627
27-
scalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
28-
if [ "$scalaVer" != "" ]; then
29-
publishScalaVersion='set every crossScalaVersions := Seq("'$scalaVer'")'
28+
scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
29+
if [ "$scalaAndJvmVer" != "" ]; then
30+
scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//)
31+
jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//)
32+
if [ "$jvmVer" != "$currentJvmVer" ]; then
33+
echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer."
34+
exit 0
35+
fi
36+
publishScalaVersion='set every scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))'
37+
echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer."
38+
else
39+
echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt."
3040
fi
3141
3242
extraTarget="+publish-signed"

build.sbt

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import com.typesafe.tools.mima.plugin.{MimaPlugin, MimaKeys}
2-
31
scalaModuleSettings
42

5-
name := "scala-swing"
6-
7-
version := "1.0.3-SNAPSHOT"
8-
9-
scalaVersion := crossScalaVersions.value.head
3+
name := "scala-swing"
4+
version := "1.0.3-SNAPSHOT"
105

11-
crossScalaVersions := Seq("2.11.6", "2.12.0-M1", "2.10.5")
6+
scalaVersionsByJvm := {
7+
val vs = List("2.11.11", "2.10.6")
128

13-
// important!! must come here (why?)
14-
scalaModuleOsgiSettings
9+
// Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
10+
Map(
11+
6 -> vs.map(_ -> true),
12+
7 -> vs.map(_ -> false),
13+
8 -> vs.map(_ -> false)
14+
)
15+
}
1516

16-
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}")
17+
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}")
1718

1819
mimaPreviousVersion := Some("1.0.1")

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.8
1+
sbt.version=0.13.15

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.3")
1+
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.6")

0 commit comments

Comments
 (0)