Skip to content

Commit 92adfb6

Browse files
authored
Merge pull request #71 from cquiroz/pure-java-binaries
Only java packages on export
2 parents 3a57442 + 44fd13e commit 92adfb6

File tree

8 files changed

+46
-25
lines changed

8 files changed

+46
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Both Scala 2.11 and Scala 2.12 (2.12.0-M7 and later) are supported.
1515

1616
To get started with SBT, add one (or both) of these dependencies:
1717

18-
- `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M12"` (for Scala)
19-
- `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M12` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
18+
- `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M13"` (for Scala)
19+
- `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M13` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
2020

2121
#### Documentation
2222

build.sbt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import sbt._
33
import sbt.io.Using
44

55
val scalaVer = "2.12.4"
6-
val crossScalaVer = Seq(scalaVer, "2.10.7", "2.11.12")
76
val tzdbVersion = "2018c"
87
val scalaJavaTimeVer = "2.0.0-M13"
9-
val scalaJavaTimeVersion = s"$scalaJavaTimeVer-SNAPSHOT"
10-
val scalaTZDBVersion = s"${scalaJavaTimeVer}_$tzdbVersion-SNAPSHOT"
8+
val scalaJavaTimeVersion = s"$scalaJavaTimeVer"
9+
val scalaTZDBVersion = s"${scalaJavaTimeVer}_$tzdbVersion"
1110

1211
lazy val downloadFromZip: TaskKey[Unit] =
1312
taskKey[Unit]("Download the tzdb tarball and extract it")
@@ -21,12 +20,18 @@ lazy val commonSettings = Seq(
2120
licenses := Seq("BSD 3-Clause License" -> url("https://opensource.org/licenses/BSD-3-Clause")),
2221

2322
scalaVersion := scalaVer,
24-
crossScalaVersions := crossScalaVer,
23+
crossScalaVersions := {
24+
if (scalaJSVersion.startsWith("0.6")) {
25+
Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M2")
26+
} else {
27+
Seq("2.11.12", "2.12.4", "2.13.0-M2")
28+
}
29+
},
2530
autoAPIMappings := true,
2631

2732
libraryDependencies ++= {
2833
CrossVersion.partialVersion(scalaVersion.value) match {
29-
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
34+
case Some((2, scalaMajor)) if scalaMajor >= 11 && scalaMajor <= 12 =>
3035
compilerPlugin("org.scalameta" % "semanticdb-scalac" % "2.1.2" cross CrossVersion.full) :: Nil
3136
case _ =>
3237
Nil
@@ -37,15 +42,23 @@ lazy val commonSettings = Seq(
3742
"-feature",
3843
"-encoding", "UTF-8",
3944
),
45+
// Don't include threeten on the binaries
46+
mappings in (Compile, packageBin) := (mappings in (Compile, packageBin)).value.filter { case (f, s) => !s.contains("semanticdb") && !s.contains("threeten") },
4047
scalacOptions := {
4148
CrossVersion.partialVersion(scalaVersion.value) match {
42-
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
49+
case Some((2, scalaMajor)) if scalaMajor >= 11 && scalaMajor <= 12 =>
4350
scalacOptions.value ++ Seq(
4451
"-deprecation:false",
4552
"-Xfatal-warnings",
4653
"-Xplugin-require:semanticdb",
4754
"-Yrangepos",
4855
"-target:jvm-1.8")
56+
case Some((2, 13)) =>
57+
scalacOptions.value ++ Seq(
58+
"-deprecation:false",
59+
"-Xfatal-warnings",
60+
"-Yrangepos",
61+
"-target:jvm-1.8")
4962
case Some((2, 10)) =>
5063
scalacOptions.value ++ Seq("-target:jvm-1.8")
5164
}

changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</properties>
1010
<body>
1111
<!-- types are add, fix, remove, update -->
12-
<release version="2.0.0-M13" date="2017-12-23" description="v2.0.0-13">
12+
<release version="2.0.0-M13" date="2018-02-21" description="v2.0.0-13">
1313
<action dev="cquiroz" type="update" >
1414
Update to scala.js 0.6.22
1515
</action>
@@ -30,6 +30,9 @@
3030
<action dev="cquiroz" type="update" >
3131
Use sbt-tzdb to build the timezone db
3232
</action>
33+
<action dev="cquiroz" type="update" >
34+
Publish only the java.time package
35+
</action>
3336
</release>
3437
<release version="2.0.0-M12" date="2017-06-06" description="v2.0.0-M12">
3538
<action dev="cquiroz" type="update" >

core/js/src/main/scala/java/util/Calendar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package java.util
22

3-
import org.threeten.bp.Instant
3+
import java.time.Instant
44

55
@SerialVersionUID(-1807547505821590642L)
66
abstract class Calendar private[util](timezone: TimeZone = null, locale: Locale = null) extends Cloneable with Serializable with Ordered[Calendar] {

core/js/src/main/scala/java/util/GregorianCalendar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package java.util
22

3-
import org.threeten.bp.ZonedDateTime
3+
import java.time.ZonedDateTime
44

55
@SerialVersionUID(-8125100834729963327L)
66
class GregorianCalendar(timezone: TimeZone = TimeZone.getDefault, locale: Locale = Locale.getDefault) extends Calendar(timezone, locale) {

core/js/src/main/scala/java/util/TimeZone.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package java.util
22

33
import java.text.DateFormatSymbols
44

5-
import org.threeten.bp.{Instant, ZoneId}
6-
import org.threeten.bp.zone.ZoneRulesProvider
5+
import java.time.{Instant, ZoneId}
6+
import java.time.zone.ZoneRulesProvider
77

88
import scala.collection.JavaConverters._
99
import scala.util.Try

docs/src/main/tut/index.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ The implementation is based on the original BSD-licensed reference implementatio
1616
#### Example
1717

1818
```tut:book
19-
// On scala.js you can pick either java.time or org.threeten.bp package to import
20-
//import java.time._
21-
import org.threeten.bp._
19+
import java.time._
2220
2321
// always returns 2009-02-13T23:31:30
2422
val fixedClock = Clock.fixed(Instant.ofEpochSecond(1234567890L), ZoneOffset.ofHours(0))
@@ -60,8 +58,8 @@ Both Scala 2.11 and Scala 2.12 (2.0.0-M8 and later) are supported.
6058

6159
To get started with SBT, add one of these dependencies:
6260

63-
* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M12"` (for Scala)
64-
* `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M12"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
61+
* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M13"` (for Scala)
62+
* `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M13"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
6563

6664
To get the latest snapshots add the repo
6765

@@ -72,8 +70,8 @@ resolvers +=
7270

7371
and either:
7472

75-
* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M13-SNAPSHOT"` (for Scala)
76-
* `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M13-SNAPSHOT"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
73+
* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M14-SNAPSHOT"` (for Scala)
74+
* `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M14-SNAPSHOT"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
7775

7876
### Time zones
7977

@@ -86,7 +84,7 @@ If you don't need to use timezones in your application you can just stop here. B
8684
The timezone for js is provided in a separate bundle which contains all time zones available from
8785
[IANA Time Zone Database](https://www.iana.org/time-zones). To use them you need to add the following dependency
8886

89-
* `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.0.0-M13_2018c-SNAPSHOT"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
87+
* `libraryDependencies += "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.0.0-M13_2018c"` (for Scala.js, [Scala.js plugin](http://www.scala-js.org/tutorial/basic/#sbt-setup) required)
9088

9189
Note that the db is fairly large and due to the characteristics of the API it's not very ammenable to optimization
9290
This database is published every now and then so it maybe old. For current version see the following section.
@@ -103,7 +101,7 @@ To do that you need to:
103101
* Add `sbt-tzdb` to your list of plugins (Note you need sbt 1.x)
104102

105103
```scala
106-
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "0.1.1")
104+
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "0.1.2")
107105
```
108106

109107
* Enable the plugin for your `Scala.js` project:
@@ -156,12 +154,19 @@ Have a look at the [issues](https://github.com/cquiroz/scala-java-time/issues) o
156154

157155
##### 2.0
158156

159-
The current version is published containing the code in both packages: `org.threeten.bp` and `java.time`.
160-
161157
A stable release of 2.0 will be published with only `java.time` on its binary after a (hopefully) short RC phase.
162158

163159
#### FAQs
164160

161+
##### What's with the packages? the code uses `org.threeten.bp` but I use `java.time`
162+
163+
The original code was in the `org.threeten.bp` and that has been maintained, among other reasons, because writing
164+
code on the `java` namespace tends to produce issues with the security controls of the JVM
165+
166+
Thus the code is on `org.threeten.bp` but during packaging the code is moved to `java.time` and `org.threeten.bp` is removed.
167+
168+
Most applications would use the `java.time` package mirroring the JVM
169+
165170
##### Is this project derived from OpenJDK?
166171

167172
No. This project is derived from the Reference Implementation previously hosted on GitHub.

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.1")
2121

2222
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.10")
2323

24-
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "0.1.1")
24+
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "0.1.2")
2525

2626
// Incompatible with 2.12.0-M5
2727
// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5")

0 commit comments

Comments
 (0)