1
- val crossScalaVersions212 = (13 to 18 ).map(" 2.12." + _)
2
- val crossScalaVersions213 = (4 to 11 ).map(" 2.13." + _)
1
+ val crossScalaVersions212 = (14 to 18 ).map(" 2.12." + _)
2
+ val crossScalaVersions213 = (8 to 12 ).map(" 2.13." + _)
3
3
val crossScalaVersions3 =
4
- (0 to 3 ).map(" 3.1." + _) ++
4
+ (2 to 3 ).map(" 3.1." + _) ++
5
5
(0 to 2 ).map(" 3.2." + _) ++
6
- (0 to 0 ).map(" 3.3." + _)
6
+ (0 to 1 ).map(" 3.3." + _)
7
7
8
- val publishScalaVersions =
9
- Seq (crossScalaVersions212, crossScalaVersions213).map(_.last) ++ Seq (" 3.1.3" )
8
+ val scala2_12 = crossScalaVersions212.last
9
+ val scala2_13 = crossScalaVersions213.last
10
+ val scala3 = crossScalaVersions3.last
11
+ val scala3PublishVersion = " 3.1.3"
12
+
13
+ val publishScalaVersions = Seq (scala2_12, scala2_13, scala3PublishVersion)
10
14
11
15
def scalaReleasesForBinaryVersion (v : String ): Seq [String ] = v match {
12
16
case " 2.12" => crossScalaVersions212
@@ -19,27 +23,37 @@ def scalaReleasesForBinaryVersion(v: String): Seq[String] = v match {
19
23
}
20
24
21
25
def scalaStdlibForBinaryVersion (
22
- nativeBinVer : String ,
23
- scalaBinVer : String
24
- ): Seq [String ] = {
25
- def depPattern (lib : String , v : String ) =
26
- s " ${lib}_native ${nativeBinVer}_ ${v}"
27
- val scalalib = " scalalib"
28
- val scala3lib = " scala3lib"
29
- val commonLibs = Seq (
26
+ organization : String ,
27
+ nativeVersion : String ,
28
+ nativeBinaryVersion : String ,
29
+ scalaBinaryVersion : String
30
+ ): Seq [ModuleID ] = {
31
+ def artifact (module : String , binV : String , version : String = nativeVersion) =
32
+ organization % s " ${module}_native ${nativeBinaryVersion}_ $binV" % version
33
+
34
+ def scalalibVersion (scalaBinVersion : String ): String = {
35
+ val scalaVersion = scalaReleasesForBinaryVersion(scalaBinaryVersion).last
36
+ s " $scalaVersion+ $nativeVersion"
37
+ }
38
+ def scalalib (binV : String ) = artifact(" scalalib" , binV, scalalibVersion(binV))
39
+ val scala3lib = artifact(" scalalib" , " 3" , scalalibVersion(" 3" ))
40
+ val crossRuntimeLibraries = List (
30
41
" nativelib" ,
31
42
" clib" ,
32
43
" posixlib" ,
33
44
" windowslib" ,
34
45
" javalib" ,
35
46
" auxlib"
36
- )
37
- scalaBinVer match {
38
- case " 2.12" | " 2.13" =>
39
- (commonLibs :+ scalalib).map(depPattern(_, scalaBinVer))
40
- case " 3" =>
41
- (commonLibs :+ scala3lib).map(depPattern(_, scalaBinVer)) :+
42
- depPattern(scalalib, " 2.13" )
47
+ ).map(artifact(_, scalaBinaryVersion))
48
+
49
+ val nonCrossRuntimeLibraries = List (" javalib-intf" )
50
+ .map(organization % _ % nativeVersion)
51
+
52
+ val runtimeLibraries = crossRuntimeLibraries ++ nonCrossRuntimeLibraries
53
+
54
+ scalaBinaryVersion match {
55
+ case " 2.12" | " 2.13" => scalalib(scalaBinaryVersion) :: runtimeLibraries
56
+ case " 3" => scala3lib :: scalalib(" 2.13" ) :: runtimeLibraries
43
57
case ver =>
44
58
throw new IllegalArgumentException (
45
59
s " Unsupported binary scala version ` ${ver}` "
@@ -55,9 +69,9 @@ val cliAssemblyJarName = settingKey[String]("Name of created assembly jar")
55
69
inThisBuild(
56
70
Def .settings(
57
71
organization := " org.scala-native" ,
58
- scalaNativeVersion := " 0.4.15 " ,
72
+ scalaNativeVersion := " 0.5.0-SNAPSHOT " ,
59
73
version := scalaNativeVersion.value,
60
- scalaVersion := crossScalaVersions212.last ,
74
+ scalaVersion := scala3PublishVersion ,
61
75
crossScalaVersions := publishScalaVersions,
62
76
homepage := Some (url(" http://www.scala-native.org" )),
63
77
startYear := Some (2021 ),
@@ -74,7 +88,7 @@ inThisBuild(
74
88
Some (
" scm:git:[email protected] :scala-native/scala-native-cli.git" )
75
89
)
76
90
),
77
- resolvers += Resolver .sonatypeRepo (" snapshots" ),
91
+ resolvers ++ = Resolver .sonatypeOssRepos (" snapshots" ),
78
92
resolvers += Resolver .mavenCentral,
79
93
resolvers += Resolver .defaultLocal
80
94
)
@@ -143,10 +157,33 @@ lazy val cliScriptedTests = project
143
157
144
158
def nativeBinaryVersion (version : String ): String = {
145
159
val VersionPattern = raw " (\d+)\.(\d+)\.(\d+)(\-.*)? " .r
146
- val VersionPattern (major, minor, _, _) = version
147
- s " $major. $minor"
160
+ val VersionPattern (major, minor, patch, milestone) = version
161
+ if (patch != null && milestone != null ) version
162
+ else s " $major. $minor"
163
+ }
164
+
165
+ val nativeSourceExtensions = Set (" .c" , " .cpp" , " .cxx" , " .h" , " .hpp" , " .S" )
166
+ val DeduplicateOrRename = new sbtassembly.MergeStrategy {
167
+ def name : String = " deduplicate-or-rename"
168
+ def apply (
169
+ tempDir : java.io.File ,
170
+ path : String ,
171
+ files : Seq [java.io.File ]
172
+ ): Either [String , Seq [(java.io.File , String )]] =
173
+ MergeStrategy .deduplicate(tempDir, path, files) match {
174
+ case v @ Right (_) => v
175
+ case _ => MergeStrategy .rename(tempDir, path, files)
176
+ }
148
177
}
178
+
149
179
lazy val cliPackSettings = Def .settings(
180
+ assemblyMergeStrategy := {
181
+ val default = assemblyMergeStrategy.value
182
+ file =>
183
+ if (nativeSourceExtensions.exists(file.endsWith)) DeduplicateOrRename
184
+ else if (file.endsWith(" scala-native.properties" )) MergeStrategy .concat
185
+ else default(file)
186
+ },
150
187
cliPackLibJars := {
151
188
val s = streams.value
152
189
val log = s.log
@@ -159,13 +196,15 @@ lazy val cliPackSettings = Def.settings(
159
196
val scalaFullVers = scalaReleasesForBinaryVersion(scalaBinVer)
160
197
val cliAssemblyJar = assembly.value
161
198
162
- val scalaStdLibraryModuleIDs =
163
- scalaStdlibForBinaryVersion(nativeBinVer, scalaBinVer)
164
-
165
199
// Standard modules needed for linking of Scala Native
166
- val stdLibModuleIDs = scalaStdLibraryModuleIDs.map(
167
- scalaNativeOrg % _ % snVer
168
- )
200
+ val stdLibModuleIDs =
201
+ scalaStdlibForBinaryVersion(
202
+ organization = scalaNativeOrg,
203
+ nativeVersion = snVer,
204
+ nativeBinaryVersion = nativeBinVer,
205
+ scalaBinaryVersion = scalaBinVer
206
+ )
207
+
169
208
val compilerPluginModuleIDs =
170
209
scalaFullVers.map(v => scalaNativeOrg % s " nscplugin_ $v" % snVer)
171
210
val allModuleIDs = (stdLibModuleIDs ++ compilerPluginModuleIDs).toVector
@@ -235,6 +274,10 @@ lazy val cliPackSettings = Def.settings(
235
274
" @SCALANATIVE_BIN_VER@" ,
236
275
nativeBinaryVersion(snVer)
237
276
)
277
+ .replaceAllLiterally(
278
+ " @SCALALIB_2_13_FOR_3_VER@" ,
279
+ crossScalaVersions213.last
280
+ )
238
281
val dest = trgBin / scriptFile.getName
239
282
IO .write(dest, processedContent)
240
283
if (scriptFile.canExecute)
@@ -259,11 +302,14 @@ lazy val publishSettings = Def.settings(
259
302
},
260
303
credentials ++= {
261
304
for {
262
- realm <- sys.env.get(" MAVEN_REALM" )
263
- domain <- sys.env.get(" MAVEN_DOMAIN" )
264
305
user <- sys.env.get(" MAVEN_USER" )
265
306
password <- sys.env.get(" MAVEN_PASSWORD" )
266
- } yield Credentials (realm, domain, user, password)
307
+ } yield Credentials (
308
+ realm = " Sonatype Nexus Repository Manager" ,
309
+ host = " oss.sonatype.org" ,
310
+ userName = user,
311
+ passwd = password
312
+ )
267
313
}.toSeq,
268
314
developers ++= List (
269
315
Developer (
0 commit comments