Skip to content

Only java packages on export #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Both Scala 2.11 and Scala 2.12 (2.12.0-M7 and later) are supported.

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

- `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M12"` (for Scala)
- `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)
- `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M13"` (for Scala)
- `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)

#### Documentation

Expand Down
25 changes: 19 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import sbt._
import sbt.io.Using

val scalaVer = "2.12.4"
val crossScalaVer = Seq(scalaVer, "2.10.7", "2.11.12")
val tzdbVersion = "2018c"
val scalaJavaTimeVer = "2.0.0-M13"
val scalaJavaTimeVersion = s"$scalaJavaTimeVer-SNAPSHOT"
val scalaTZDBVersion = s"${scalaJavaTimeVer}_$tzdbVersion-SNAPSHOT"
val scalaJavaTimeVersion = s"$scalaJavaTimeVer"
val scalaTZDBVersion = s"${scalaJavaTimeVer}_$tzdbVersion"

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

scalaVersion := scalaVer,
crossScalaVersions := crossScalaVer,
crossScalaVersions := {
if (scalaJSVersion.startsWith("0.6")) {
Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M2")
} else {
Seq("2.11.12", "2.12.4", "2.13.0-M2")
}
},
autoAPIMappings := true,

libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
case Some((2, scalaMajor)) if scalaMajor >= 11 && scalaMajor <= 12 =>
compilerPlugin("org.scalameta" % "semanticdb-scalac" % "2.1.2" cross CrossVersion.full) :: Nil
case _ =>
Nil
Expand All @@ -37,15 +42,23 @@ lazy val commonSettings = Seq(
"-feature",
"-encoding", "UTF-8",
),
// Don't include threeten on the binaries
mappings in (Compile, packageBin) := (mappings in (Compile, packageBin)).value.filter { case (f, s) => !s.contains("semanticdb") && !s.contains("threeten") },
scalacOptions := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
case Some((2, scalaMajor)) if scalaMajor >= 11 && scalaMajor <= 12 =>
scalacOptions.value ++ Seq(
"-deprecation:false",
"-Xfatal-warnings",
"-Xplugin-require:semanticdb",
"-Yrangepos",
"-target:jvm-1.8")
case Some((2, 13)) =>
scalacOptions.value ++ Seq(
"-deprecation:false",
"-Xfatal-warnings",
"-Yrangepos",
"-target:jvm-1.8")
case Some((2, 10)) =>
scalacOptions.value ++ Seq("-target:jvm-1.8")
}
Expand Down
5 changes: 4 additions & 1 deletion changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</properties>
<body>
<!-- types are add, fix, remove, update -->
<release version="2.0.0-M13" date="2017-12-23" description="v2.0.0-13">
<release version="2.0.0-M13" date="2018-02-21" description="v2.0.0-13">
<action dev="cquiroz" type="update" >
Update to scala.js 0.6.22
</action>
Expand All @@ -30,6 +30,9 @@
<action dev="cquiroz" type="update" >
Use sbt-tzdb to build the timezone db
</action>
<action dev="cquiroz" type="update" >
Publish only the java.time package
</action>
</release>
<release version="2.0.0-M12" date="2017-06-06" description="v2.0.0-M12">
<action dev="cquiroz" type="update" >
Expand Down
2 changes: 1 addition & 1 deletion core/js/src/main/scala/java/util/Calendar.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package java.util

import org.threeten.bp.Instant
import java.time.Instant

@SerialVersionUID(-1807547505821590642L)
abstract class Calendar private[util](timezone: TimeZone = null, locale: Locale = null) extends Cloneable with Serializable with Ordered[Calendar] {
Expand Down
2 changes: 1 addition & 1 deletion core/js/src/main/scala/java/util/GregorianCalendar.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package java.util

import org.threeten.bp.ZonedDateTime
import java.time.ZonedDateTime

@SerialVersionUID(-8125100834729963327L)
class GregorianCalendar(timezone: TimeZone = TimeZone.getDefault, locale: Locale = Locale.getDefault) extends Calendar(timezone, locale) {
Expand Down
4 changes: 2 additions & 2 deletions core/js/src/main/scala/java/util/TimeZone.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package java.util

import java.text.DateFormatSymbols

import org.threeten.bp.{Instant, ZoneId}
import org.threeten.bp.zone.ZoneRulesProvider
import java.time.{Instant, ZoneId}
import java.time.zone.ZoneRulesProvider

import scala.collection.JavaConverters._
import scala.util.Try
Expand Down
27 changes: 16 additions & 11 deletions docs/src/main/tut/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ The implementation is based on the original BSD-licensed reference implementatio
#### Example

```tut:book
// On scala.js you can pick either java.time or org.threeten.bp package to import
//import java.time._
import org.threeten.bp._
import java.time._

// always returns 2009-02-13T23:31:30
val fixedClock = Clock.fixed(Instant.ofEpochSecond(1234567890L), ZoneOffset.ofHours(0))
Expand Down Expand Up @@ -60,8 +58,8 @@ Both Scala 2.11 and Scala 2.12 (2.0.0-M8 and later) are supported.

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

* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M12"` (for Scala)
* `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)
* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M13"` (for Scala)
* `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)

To get the latest snapshots add the repo

Expand All @@ -72,8 +70,8 @@ resolvers +=

and either:

* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M13-SNAPSHOT"` (for Scala)
* `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)
* `libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % "2.0.0-M14-SNAPSHOT"` (for Scala)
* `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)

### Time zones

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

* `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)
* `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)

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

```scala
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "0.1.1")
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "0.1.2")
```

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

##### 2.0

The current version is published containing the code in both packages: `org.threeten.bp` and `java.time`.

A stable release of 2.0 will be published with only `java.time` on its binary after a (hopefully) short RC phase.

#### FAQs

##### What's with the packages? the code uses `org.threeten.bp` but I use `java.time`

The original code was in the `org.threeten.bp` and that has been maintained, among other reasons, because writing
code on the `java` namespace tends to produce issues with the security controls of the JVM

Thus the code is on `org.threeten.bp` but during packaging the code is moved to `java.time` and `org.threeten.bp` is removed.

Most applications would use the `java.time` package mirroring the JVM

##### Is this project derived from OpenJDK?

No. This project is derived from the Reference Implementation previously hosted on GitHub.
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.1")

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

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

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