Skip to content

Commit 68ee623

Browse files
authored
Merge pull request #114 from SethTisue/modernize-build-a-little
standardize build.sbt and build.sh
2 parents d83558a + bd5764c commit 68ee623

File tree

2 files changed

+29
-43
lines changed

2 files changed

+29
-43
lines changed

build.sbt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
2-
3-
// With CrossType.Pure, the root project also picks up the sources in `src`
4-
Compile/sources := Nil
5-
Test/sources := Nil
1+
lazy val root = project.in(file("."))
2+
.aggregate(collectionContrib.jvm, collectionContrib.js)
3+
.settings(
4+
publish / skip := true,
5+
// With CrossType.Pure, the root project also picks up the sources in `src`
6+
Compile / unmanagedSourceDirectories := Nil,
7+
Test / unmanagedSourceDirectories := Nil,
8+
)
69

710
lazy val collectionContrib = crossProject(JVMPlatform, JSPlatform)
8-
.withoutSuffixFor(JVMPlatform)
911
.crossType(CrossType.Pure)
1012
.in(file("."))
1113
.settings(ScalaModulePlugin.scalaModuleSettings)
@@ -16,12 +18,10 @@ lazy val collectionContrib = crossProject(JVMPlatform, JSPlatform)
1618
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s", "-a"),
1719
parallelExecution in Test := false, // why?
1820
libraryDependencies ++= Seq(
19-
"junit" % "junit" % "4.13.1" % Test,
21+
"junit" % "junit" % "4.13.1" % Test,
2022
"com.novocode" % "junit-interface" % "0.11" % Test,
21-
"org.openjdk.jol" % "jol-core" % "0.14" % Test
23+
"org.openjdk.jol" % "jol-core" % "0.14" % Test
2224
),
23-
// https://github.com/sbt/sbt/issues/5043
24-
useCoursier := false
2525
)
2626
.jvmSettings(
2727
scalaModuleMimaPreviousVersion := Some("0.1.0")
@@ -31,3 +31,6 @@ lazy val collectionContrib = crossProject(JVMPlatform, JSPlatform)
3131
// Scala.js cannot run forked tests
3232
fork in Test := false
3333
)
34+
35+
lazy val collectionContribJVM = collectionContrib.jvm
36+
lazy val collectionContribJS = collectionContrib.js

build.sh

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ set -e
1010
# sbt-dynver sets the version number from the tag
1111
# sbt-travisci sets the Scala version from the travis job matrix
1212

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.
13+
# To back-publish an existing release for a new Scala / Scala.js / Scala Native version:
14+
# - check out the tag for the version that needs to be published
15+
# - change `.travis.yml` to adjust the version numbers and trim down the build matrix as necessary
16+
# - commit the changes and tag this new revision with an arbitrary suffix after a hash, e.g.,
17+
# `v1.2.3#dotty-0.27` (the suffix is ignored, the version will be `1.2.3`)
1618

17-
# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x
19+
# We release on JDK 8 (for Scala 2.x and Dotty 0.x)
1820
isReleaseJob() {
1921
if [[ "$ADOPTOPENJDK" == "8" ]]; then
2022
true
@@ -23,49 +25,30 @@ isReleaseJob() {
2325
fi
2426
}
2527

26-
# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases
27-
isTagScalaReleaseJob() {
28-
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then
29-
true
30-
else
31-
false
32-
fi
33-
}
34-
35-
if [[ "$SCALAJS_VERSION" != "" ]]; then
36-
projectPrefix="collectionContribJS"
28+
if [[ "$SCALAJS_VERSION" == "" ]]; then
29+
projectPrefix="collectionContribJVM/"
3730
else
38-
projectPrefix="collectionContrib"
31+
projectPrefix="collectionContribJS/"
3932
fi
4033

4134
verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
42-
tagPat="^v$verPat(#$verPat)?$"
35+
tagPat="^v$verPat(#.*)?$"
4336

4437
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
4538
releaseTask="ci-release"
46-
tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
47-
if [[ "$tagScalaVer" == "" ]]; then
48-
if ! isReleaseJob; then
49-
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
50-
exit 0
51-
fi
52-
else
53-
if isTagScalaReleaseJob; then
54-
setTagScalaVersion='set every scalaVersion := "'$tagScalaVer'"'
55-
else
56-
echo "The releases for Scala $tagScalaVer are built by other jobs in the travis job matrix"
57-
exit 0
58-
fi
39+
if ! isReleaseJob; then
40+
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
41+
exit 0
5942
fi
6043
fi
6144

6245
# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions
63-
export CI_RELEASE="$projectPrefix/publishSigned"
64-
export CI_SNAPSHOT_RELEASE="$projectPrefix/publish"
46+
export CI_RELEASE="${projectPrefix}publishSigned"
47+
export CI_SNAPSHOT_RELEASE="${projectPrefix}publish"
6548

6649
# default is sonatypeBundleRelease, which closes and releases the staging repo
6750
# see https://github.com/xerial/sbt-sonatype#commands
6851
# for now, until we're confident in the new release scripts, just close the staging repo.
6952
export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose"
7053

71-
sbt "$setTagScalaVersion" clean $projectPrefix/test $projectPrefix/publishLocal $releaseTask
54+
sbt clean ${projectPrefix}test ${projectPrefix}publishLocal $releaseTask

0 commit comments

Comments
 (0)