@@ -22,11 +22,9 @@ val versions: Map[String, String] = {
22
22
val scalaVer = versions(" 2.13" )
23
23
val scala3Ver = versions(" 3" )
24
24
val tzdbVersion = " 2019c"
25
- val scalajavaLocalesVersion = " 1.3 .0"
25
+ val scalajavaLocalesVersion = " 1.4 .0"
26
26
Global / onChangedBuildSource := ReloadOnSourceChanges
27
27
28
- Global / resolvers += Resolver .sonatypeRepo(" public" )
29
-
30
28
lazy val downloadFromZip : TaskKey [Unit ] =
31
29
taskKey[Unit ](" Download the tzdb tarball and extract it" )
32
30
@@ -54,25 +52,33 @@ inThisBuild(
54
52
)
55
53
)
56
54
57
- publish / skip := true
58
-
59
- def scalaVersionSpecificFolders (srcName : String , srcBaseDir : java.io.File , scalaVersion : String ) = {
60
- def extraDirs (suffix : String ) =
61
- List (CrossType .Pure , CrossType .Full )
62
- .flatMap(_.sharedSrcDir(srcBaseDir, srcName).toList.map(f => file(f.getPath + suffix)))
63
- CrossVersion .partialVersion(scalaVersion) match {
64
- case Some ((2 , y)) => extraDirs(" -2.x" ) ++ (if (y >= 13 ) extraDirs(" -2.13+" ) else Nil )
65
- case Some ((0 | 3 , _)) => extraDirs(" -2.13+" ) ++ extraDirs(" -3.x" )
66
- case _ => Nil
67
- }
68
- }
55
+ lazy val root = project
56
+ .in(file(" ." ))
57
+ .settings(commonSettings)
58
+ .settings(
59
+ publish / skip := true
60
+ )
61
+ .aggregate(
62
+ core.js,
63
+ core.jvm,
64
+ core.native,
65
+ tzdb.js,
66
+ tzdb.jvm,
67
+ tzdb.native,
68
+ tests.js,
69
+ tests.jvm,
70
+ tests.native,
71
+ demo.js,
72
+ demo.jvm,
73
+ demo.native
74
+ )
69
75
70
76
lazy val commonSettings = Seq (
71
77
description := " java.time API implementation in Scala and Scala.js" ,
72
78
scalaVersion := scalaVer,
73
79
crossScalaVersions := versions.toList.map(_._2),
74
80
// Don't include threeten on the binaries
75
- Compile / packageBin / mappings := (Compile / packageBin / mappings).value.filter { case (f , s) =>
81
+ Compile / packageBin / mappings := (Compile / packageBin / mappings).value.filter { case (_ , s) =>
76
82
! s.contains(" threeten" )
77
83
},
78
84
Compile / scalacOptions ++= {
@@ -91,15 +97,16 @@ lazy val commonSettings = Seq(
91
97
Seq .empty
92
98
}
93
99
},
94
- Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(" main" ,
95
- baseDirectory.value,
96
- scalaVersion.value
97
- ),
98
- Test / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(" test" ,
99
- baseDirectory.value,
100
- scalaVersion.value
101
- ),
102
100
scalacOptions ++= { if (isDotty.value) Seq .empty else Seq (" -target:jvm-1.8" ) },
101
+ scalacOptions --= {
102
+ if (isDotty.value)
103
+ List (
104
+ " -Xfatal-warnings"
105
+ )
106
+ else
107
+ List (
108
+ )
109
+ },
103
110
javaOptions ++= Seq (" -Dfile.encoding=UTF8" ),
104
111
autoAPIMappings := true ,
105
112
Compile / doc / sources := { if (isDotty.value) Seq () else (Compile / doc / sources).value }
@@ -122,7 +129,7 @@ def copyAndReplace(srcDirs: Seq[File], destinationDir: File): Seq[File] = {
122
129
false
123
130
)
124
131
125
- val onlyScalaDirs = srcDirs.filter(_.getName.matches(" .*scala(-\\ d\\ .x )?" ))
132
+ val onlyScalaDirs = srcDirs.filter(_.getName.matches(" .*scala(-\\ d)?" ))
126
133
// Copy the source files from the base project, exclude classes on java.util and dirs
127
134
val generatedFiles : List [java.io.File ] = onlyScalaDirs
128
135
.foldLeft(Set .empty[File ]) { (files, sourceDir) =>
@@ -152,10 +159,10 @@ def copyAndReplace(srcDirs: Seq[File], destinationDir: File): Seq[File] = {
152
159
generatedFiles
153
160
}
154
161
155
- lazy val scalajavatime = crossProject(JVMPlatform , JSPlatform , NativePlatform )
162
+ lazy val core = crossProject(JVMPlatform , JSPlatform , NativePlatform )
156
163
.crossType(CrossType .Full )
157
164
.in(file(" core" ))
158
- .settings(commonSettings : _* )
165
+ .settings(commonSettings)
159
166
.settings(
160
167
name := " scala-java-time" ,
161
168
libraryDependencies += (" org.portable-scala" %%% " portable-scala-reflect" % " 1.1.2" )
@@ -191,7 +198,6 @@ lazy val scalajavatime = crossProject(JVMPlatform, JSPlatform, NativePlatform)
191
198
)
192
199
)
193
200
.nativeSettings(
194
- crossScalaVersions -= scala3Ver,
195
201
Compile / sourceGenerators += Def .task {
196
202
val srcDirs = (Compile / sourceDirectories).value
197
203
val destinationDir = (Compile / sourceManaged).value
@@ -202,26 +208,24 @@ lazy val scalajavatime = crossProject(JVMPlatform, JSPlatform, NativePlatform)
202
208
)
203
209
)
204
210
205
- lazy val scalajavatimeTZDB = crossProject(JVMPlatform , JSPlatform , NativePlatform )
211
+ lazy val tzdb = crossProject(JVMPlatform , JSPlatform , NativePlatform )
206
212
.crossType(CrossType .Full )
207
213
.in(file(" tzdb" ))
208
214
.settings(commonSettings)
209
215
.settings(
210
- name := " scala-java-time-tzdb"
216
+ name := " scala-java-time-tzdb" ,
217
+ includeTTBP := true
211
218
)
212
219
.jsSettings(
213
- dbVersion := TzdbPlugin .Version (tzdbVersion),
214
- includeTTBP := true ,
220
+ dbVersion := TzdbPlugin .Version (tzdbVersion),
215
221
Compile / sourceGenerators += Def .task {
216
222
val srcDirs = (Compile / sourceManaged).value
217
223
val destinationDir = (Compile / sourceManaged).value
218
224
copyAndReplace(Seq (srcDirs), destinationDir)
219
225
}.taskValue
220
226
)
221
227
.nativeSettings(
222
- crossScalaVersions -= scala3Ver,
223
228
dbVersion := TzdbPlugin .Version (tzdbVersion),
224
- includeTTBP := true ,
225
229
tzdbPlatform := TzdbPlugin .Platform .Native ,
226
230
Compile / sourceGenerators += Def .task {
227
231
val srcDirs = (Compile / sourceManaged).value
@@ -230,44 +234,36 @@ lazy val scalajavatimeTZDB = crossProject(JVMPlatform, JSPlatform, NativePlatfor
230
234
}.taskValue
231
235
)
232
236
.jvmSettings(
233
- includeTTBP := true ,
234
237
tzdbPlatform := TzdbPlugin .Platform .Jvm
235
238
)
236
- .dependsOn(scalajavatime)
237
-
238
- lazy val scalajavatimeTZDBJVM = scalajavatimeTZDB.jvm.enablePlugins(TzdbPlugin )
239
- lazy val scalajavatimeTZDBJS = scalajavatimeTZDB.js.enablePlugins(TzdbPlugin )
240
- lazy val scalajavatimeTZDBNative = scalajavatimeTZDB.native.enablePlugins(TzdbPlugin )
239
+ .dependsOn(core)
240
+ .enablePlugins(TzdbPlugin )
241
241
242
- lazy val scalajavatimeTests = crossProject(JVMPlatform , JSPlatform , NativePlatform )
242
+ lazy val tests = crossProject(JVMPlatform , JSPlatform , NativePlatform )
243
243
.crossType(CrossType .Full )
244
244
.in(file(" tests" ))
245
- .settings(commonSettings : _* )
245
+ .settings(commonSettings)
246
246
.settings(
247
- name := " scala-java-time-tests" ,
248
- // No, SBT, we don't want any artifacts for root.
249
- // No, not even an empty jar.
250
- publish := {},
251
- publishLocal := {},
252
- publishArtifact := false ,
247
+ name := " tests" ,
248
+ publish / skip := true ,
253
249
Keys .`package` := file(" " ),
254
- Compile / skip := isDotty.value,
255
250
libraryDependencies +=
256
- " org.scalatest" %%% " scalatest" % " 3.2.12" % " test " ,
251
+ " org.scalatest" %%% " scalatest" % " 3.2.12" % Test ,
257
252
scalacOptions ~= (_.filterNot(
258
253
Set (" -Wnumeric-widen" , " -Ywarn-numeric-widen" , " -Ywarn-value-discard" , " -Wvalue-discard" )
259
254
))
260
255
)
261
256
.jvmSettings(
262
257
// Fork the JVM test to ensure that the custom flags are set
263
- Test / fork := true ,
264
- Test / baseDirectory := baseDirectory.value.getParentFile,
258
+ Test / fork := true ,
259
+ Test / baseDirectory := baseDirectory.value.getParentFile,
265
260
// Use CLDR provider for locales
266
261
// https://docs.oracle.com/javase/8/docs/technotes/guides/intl/enhancements.8.html#cldr
267
262
Test / javaOptions ++= Seq (" -Duser.language=en" ,
268
263
" -Duser.country=US" ,
269
264
" -Djava.locale.providers=CLDR"
270
- )
265
+ ),
266
+ Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy .Flat
271
267
)
272
268
.jsSettings(
273
269
Test / parallelExecution := false ,
@@ -281,7 +277,6 @@ lazy val scalajavatimeTests = crossProject(JVMPlatform, JSPlatform, NativePlatfo
281
277
)
282
278
)
283
279
.nativeSettings(
284
- crossScalaVersions -= scala3Ver,
285
280
Test / parallelExecution := false ,
286
281
Test / sourceGenerators += Def .task {
287
282
val srcDirs = (Test / sourceDirectories).value
@@ -292,22 +287,20 @@ lazy val scalajavatimeTests = crossProject(JVMPlatform, JSPlatform, NativePlatfo
292
287
" io.github.cquiroz" %%% " locales-full-db" % scalajavaLocalesVersion
293
288
)
294
289
)
295
- .dependsOn(scalajavatime, scalajavatimeTZDB )
290
+ .dependsOn(core, tzdb )
296
291
297
292
val zonesFilterFn = (x : String ) => x == " Europe/Helsinki" || x == " America/Santiago"
298
293
299
294
lazy val demo = crossProject(JSPlatform , JVMPlatform , NativePlatform )
300
295
.in(file(" demo" ))
301
- .dependsOn(scalajavatime )
296
+ .dependsOn(core )
302
297
.enablePlugins(TzdbPlugin )
303
298
.settings(
304
- scalaVersion := scalaVer,
305
- name := " demo" ,
306
- publish := {},
307
- publishLocal := {},
308
- publishArtifact := false ,
309
- Keys .`package` := file(" " ),
310
- zonesFilter := zonesFilterFn
299
+ scalaVersion := scalaVer,
300
+ name := " demo" ,
301
+ publish / skip := true ,
302
+ Keys .`package` := file(" " ),
303
+ zonesFilter := zonesFilterFn
311
304
)
312
305
.jsSettings(
313
306
// scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
@@ -326,10 +319,6 @@ lazy val demo = crossProject(JSPlatform, JVMPlatform, NativePlatform)
326
319
Compile / scalacOptions -= " -Xfatal-warnings"
327
320
)
328
321
329
- lazy val demoJS = demo.js
330
- lazy val demoJVM = demo.jvm
331
- lazy val demoNative = demo.native
332
-
333
322
// lazy val docs = project
334
323
// .in(file("docs"))
335
324
// .dependsOn(scalajavatime.jvm, scalajavatime.js)
0 commit comments