Skip to content

Commit 9f028b3

Browse files
committed
New scala-module-plugin with sbt-ci-release / travisci / dynver / header
1 parent 86e4dc5 commit 9f028b3

13 files changed

+108
-255
lines changed

.travis.yml

+31-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
1-
dist: trusty
2-
31
language: scala
42

3+
scala:
4+
- 2.11.12
5+
- 2.12.10
6+
- 2.13.1
7+
58
env:
6-
global:
7-
# PGP_PASSPHRASE
8-
- secure: "MIHv2s6njtXubCzbP/eYXszuO/Y3FADYATZpDtOULZmQHcQ8z+sccQHidyq6hvoK9/I2hRUrc5RIelfA7D32tqP7aF3P9Dq1ZdiWqZYmFKUl6wzJMhgWwnT1RA9Nu67PcNLZGwOe7+55zZpWVNbeTKMe05TzUaaGUgApr9wvS0I="
9-
# SONA_USER
10-
- secure: "e3FEhT76+qpmeubxtthmubnuyf5faCZneB1lQE8zv89/NZrD+v6tM8hGWatfiyyswmcaUdukxW/Q3NVlesKiy+cJLgNJ8AImRckKPiPVUYpXcQoc0R1Nyl4DeDyorGE17SslW28frlRU9OutTnZQlOfg4uqCdZuuCdcPV0lnGAU="
11-
# SONA_PASS
12-
- secure: "BLhtiCjcjvwB0lUvfrMa9CSvWDcdGkadAVFFPyuXSU2OQw/RR9dZF3/ZLILf9jHL3pWj/Scp8jWRl40y6sUxihUOXhhxpDCF8UVgnXdDCQf/W7gerRC/+3Zpr3LugVeSEuBgECld6XZnYNst/xbL9GHzEc7kDm7MIfz8nY8Ic7s="
9+
- ADOPTOPENJDK=8
10+
- ADOPTOPENJDK=11
1311

14-
script: admin/build.sh
12+
before_install:
13+
# adding $HOME/.sdkman to cache would create an empty directory, which interferes with the initial installation
14+
- "[[ -d $HOME/.sdkman/bin ]] || rm -rf $HOME/.sdkman/"
15+
- curl -sL https://get.sdkman.io | bash
16+
- echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
17+
- source "$HOME/.sdkman/bin/sdkman-init.sh"
1518

16-
jdk:
17-
- oraclejdk8
18-
- openjdk11
19+
install:
20+
- sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | head -1)
21+
- unset JAVA_HOME
22+
- java -Xmx32m -version
23+
- git fetch --tags # get all tags for sbt-dynver
24+
25+
script: ./build.sh
1926

2027
notifications:
2128
email:
2229
2330
2431
32+
33+
before_cache:
34+
- rm -f $HOME/.ivy2/.sbt.ivy.lock
35+
- find $HOME/.ivy2/cache -name "ivydata-*.properties" | xargs rm
36+
- find $HOME/.sbt -name "*.lock" | xargs rm
37+
cache:
38+
directories:
39+
- $HOME/.ivy2/cache
40+
- $HOME/.sbt
41+
- $HOME/.cache/coursier
42+
- $HOME/.sdkman

admin/README.md

-72
This file was deleted.

admin/build.sh

-53
This file was deleted.

admin/encryptEnvVars.sh

-11
This file was deleted.

admin/genKeyPair.sh

-41
This file was deleted.

admin/gpg.sbt

-1
This file was deleted.

admin/publish-settings.sbt

-9
This file was deleted.

admin/pubring.asc

-18
This file was deleted.

admin/secring.asc.enc

-1.83 KB
Binary file not shown.

build.sbt

+8-35
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
1-
import ScalaModulePlugin._
2-
3-
scalaModuleSettings
4-
5-
name := "scala-swing"
6-
7-
version := "2.1.1"
8-
9-
scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature")
10-
11-
// Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
12-
scalaVersionsByJvm in ThisBuild := Map(
13-
8 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> true),
14-
9 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false),
15-
10 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false),
16-
11 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false),
17-
12 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false)
18-
)
19-
20-
scalaVersion in ThisBuild := "2.12.8"
21-
22-
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}")
23-
24-
mimaPreviousVersion := Some("2.1.0")
25-
26-
// set the prompt (for this build) to include the project id.
27-
shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " }
28-
291
lazy val swing = project.in(file("."))
2+
.settings(ScalaModulePlugin.scalaModuleSettings)
3+
.settings(ScalaModulePlugin.scalaModuleSettingsJVM)
304
.settings(
31-
libraryDependencies += {
32-
if (scalaVersion.value == "2.13.0") {
33-
"org.scalatest" % "scalatest_2.13.0-RC3" % "3.0.8-RC5" % Test
34-
} else {
35-
"org.scalatest" %% "scalatest" % "3.0.8-RC5" % Test
36-
}
37-
},
5+
name := "scala-swing",
6+
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}"),
7+
scalaModuleMimaPreviousVersion := Some("2.1.0"),
8+
// set the prompt (for this build) to include the project id.
9+
shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " },
10+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % Test,
3811
// Adds a `src/main/scala-2.13+` source directory for Scala 2.13 and newer
3912
// and a `src/main/scala-2.13-` source directory for Scala version older than 2.13
4013
unmanagedSourceDirectories in Compile += {

build.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Builds of tagged revisions are published to sonatype staging.
6+
7+
# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice.
8+
# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds.
9+
10+
# sbt-dynver sets the version number from the tag
11+
# sbt-travisci sets the Scala version from the travis job matrix
12+
13+
# When a new binary incompatible Scala version becomes available, a previously released version
14+
# can be released using that new Scala version by creating a new tag containing the Scala version
15+
# after a hash, e.g., v1.2.3#2.13.0-M3. In this situation, the first job of the travis job
16+
# matrix builds the release. All other jobs are stopped. Make sure that the first job uses
17+
# the desired JVM version.
18+
# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x
19+
20+
isReleaseJob() {
21+
if [[ "$ADOPTOPENJDK" == "8" ]]; then
22+
true
23+
else
24+
false
25+
fi
26+
}
27+
28+
# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases
29+
isTagScalaReleaseJob() {
30+
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then
31+
true
32+
else
33+
false
34+
fi
35+
}
36+
37+
verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
38+
tagPat="^v$verPat(#$verPat)?$"
39+
40+
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
41+
releaseTask="ci-release"
42+
tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
43+
if [[ "$tagScalaVer" == "" ]]; then
44+
if ! isReleaseJob; then
45+
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
46+
exit 0
47+
fi
48+
else
49+
if isTagScalaReleaseJob; then
50+
setTagScalaVersion='set every scalaVersion := "'$tagScalaVer'"'
51+
else
52+
echo "The releases for Scala $tagScalaVer are built by other jobs in the travis job matrix"
53+
exit 0
54+
fi
55+
fi
56+
fi
57+
58+
# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions
59+
export CI_RELEASE="publishSigned"
60+
export CI_SNAPSHOT_RELEASE="publish"
61+
62+
# default is sonatypeBundleRelease, which closes and releases the staging repo
63+
# see https://github.com/xerial/sbt-sonatype#commands
64+
# for now, until we're confident in the new release scripts, just close the staging repo.
65+
export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose"
66+
67+
sbt "$setTagScalaVersion" clean test publishLocal $releaseTask

project/build.properties

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

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0")
1+
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.1.2")

0 commit comments

Comments
 (0)