@@ -5,52 +5,51 @@ import java.nio.file.Path
5
5
import seed .Cli .PackageConfig
6
6
import MavenCentral .{CompilerVersion , PlatformVersion }
7
7
import seed .cli .util .Ansi
8
- import seed .model .Artefact .PlatformSuffix
9
- import seed .model .Build .{Dep , Module }
8
+ import seed .model .Build .{Dep , JavaDep , Module , ScalaDep }
10
9
import seed .model .Platform .{JVM , JavaScript , Native }
11
10
import seed .model .{Artefact , Build , Platform , Resolution }
12
11
import seed .Log
13
12
import seed .config .BuildConfig
14
13
15
14
object ArtefactResolution {
16
- def dependencyFromDep (dep : Dep ,
17
- platform : Platform ,
18
- platformVersion : PlatformVersion ,
19
- compilerVersion : CompilerVersion ,
20
- platformSuffix : PlatformSuffix = PlatformSuffix .PlatformAndCompiler
21
- ): Dep =
22
- Dep (
15
+ def javaDepFromScalaDep (dep : ScalaDep ,
16
+ platform : Platform ,
17
+ platformVersion : PlatformVersion ,
18
+ compilerVersion : CompilerVersion
19
+ ): JavaDep =
20
+ JavaDep (
23
21
dep.organisation,
24
22
MavenCentral .formatArtefactName(
25
- Artefact (dep.organisation, dep.artefact, platformSuffix), platform,
26
- platformVersion, compilerVersion
23
+ dep.artefact, dep.versionTag, platform, platformVersion, compilerVersion
27
24
), dep.version)
28
25
29
- def dependencyFromArtefact (artefact : Artefact ,
30
- version : String ,
31
- platform : Platform ,
32
- platformVersion : PlatformVersion ,
33
- compilerVersion : CompilerVersion ): Dep =
34
- Dep (
26
+ def javaDepFromArtefact (artefact : Artefact ,
27
+ version : String ,
28
+ platform : Platform ,
29
+ platformVersion : PlatformVersion ,
30
+ compilerVersion : CompilerVersion
31
+ ): JavaDep =
32
+ JavaDep (
35
33
artefact.organisation,
36
- MavenCentral .formatArtefactName(
37
- artefact, platform, platformVersion, compilerVersion),
38
- version)
34
+ artefact.versionTag.fold(artefact.name)(vt =>
35
+ MavenCentral .formatArtefactName(artefact.name, vt, platform,
36
+ platformVersion, compilerVersion)
37
+ ), version)
39
38
40
- def jsPlatformDeps (build : Build , module : Module ): Set [Dep ] = {
39
+ def jsPlatformDeps (build : Build , module : Module ): Set [JavaDep ] = {
41
40
val scalaVersion = BuildConfig .scalaVersion(build.project, List (module))
42
41
val scalaJsVersion = build.project.scalaJsVersion.get
43
42
44
43
Set (
45
44
Artefact .ScalaJsCompiler ,
46
45
Artefact .ScalaJsLibrary
47
46
).map(artefact =>
48
- dependencyFromArtefact (artefact, scalaJsVersion, JavaScript ,
47
+ javaDepFromArtefact (artefact, scalaJsVersion, JavaScript ,
49
48
scalaJsVersion, scalaVersion)
50
49
)
51
50
}
52
51
53
- def nativePlatformDeps (build : Build , module : Module ): Set [Dep ] = {
52
+ def nativePlatformDeps (build : Build , module : Module ): Set [JavaDep ] = {
54
53
val scalaVersion = BuildConfig .scalaVersion(build.project, List (module))
55
54
val scalaNativeVersion = build.project.scalaNativeVersion.get
56
55
@@ -61,78 +60,52 @@ object ArtefactResolution {
61
60
Artefact .ScalaNativeNativelib ,
62
61
Artefact .ScalaNativeAuxlib
63
62
).map(artefact =>
64
- dependencyFromArtefact (artefact, scalaNativeVersion, Native ,
63
+ javaDepFromArtefact (artefact, scalaNativeVersion, Native ,
65
64
scalaNativeVersion, scalaVersion)
66
65
)
67
66
}
68
67
69
- def jvmArtefacts (stack : List [Module ]): Set [(Platform , Artefact .Versioned )] =
70
- stack.flatMap(_.scalaDeps).map(dep =>
71
- JVM -> Artefact .Versioned (
72
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .PlatformAndCompiler ),
73
- dep.version)
74
- ).toSet ++
75
- stack.flatMap(_.javaDeps).map(dep =>
76
- JVM -> Artefact .Versioned (
77
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .Regular ), dep.version)
78
- ).toSet
68
+ def jvmArtefacts (stack : List [Module ]): Set [(Platform , Dep )] =
69
+ stack.flatMap(_.scalaDeps).map(dep => JVM -> dep).toSet ++
70
+ stack.flatMap(_.javaDeps).map(dep => JVM -> dep).toSet
79
71
80
- def jvmDeps (build : Build , stack : List [Module ]): Set [Dep ] = {
72
+ def jvmDeps (build : Build , stack : List [Module ]): Set [JavaDep ] = {
81
73
val scalaVersion = BuildConfig .scalaVersion(build.project, stack)
82
74
83
75
stack.flatMap(_.scalaDeps).map(dep =>
84
- dependencyFromArtefact(
85
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .PlatformAndCompiler ),
86
- dep.version, JVM , scalaVersion, scalaVersion)
76
+ javaDepFromScalaDep(dep, JVM , scalaVersion, scalaVersion)
87
77
).toSet ++
88
- stack.flatMap(_.javaDeps).map(dep =>
89
- dependencyFromArtefact(
90
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .Regular ),
91
- dep.version, JVM , scalaVersion, scalaVersion)
92
- ).toSet
78
+ stack.flatMap(_.javaDeps).toSet
93
79
}
94
80
95
- def jsArtefacts (stack : List [Module ]): Set [(Platform , Artefact .Versioned )] =
96
- stack.flatMap(_.scalaDeps).map(dep =>
97
- JavaScript ->
98
- Artefact .Versioned (
99
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .PlatformAndCompiler ),
100
- dep.version)
101
- ).toSet
81
+ def jsArtefacts (stack : List [Module ]): Set [(Platform , Dep )] =
82
+ stack.flatMap(_.scalaDeps).map(dep => JavaScript -> dep).toSet
102
83
103
- def jsDeps (build : Build , stack : List [Module ]): Set [Dep ] =
84
+ def jsDeps (build : Build , stack : List [Module ]): Set [JavaDep ] =
104
85
build.project.scalaJsVersion match {
105
86
case None => Set ()
106
87
case Some (scalaJsVersion) =>
107
88
val scalaVersion = BuildConfig .scalaVersion(build.project, stack)
108
89
stack.flatMap(_.scalaDeps).map(dep =>
109
- dependencyFromArtefact(
110
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .PlatformAndCompiler ),
111
- dep.version, JavaScript , scalaJsVersion, scalaVersion)
90
+ javaDepFromScalaDep(dep, JavaScript , scalaJsVersion, scalaVersion)
112
91
).toSet
113
92
}
114
93
115
- def nativeArtefacts (stack : List [Module ]): Set [(Platform , Artefact .Versioned )] =
116
- stack.flatMap(_.scalaDeps).map(dep =>
117
- Native -> Artefact .Versioned (
118
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .PlatformAndCompiler ),
119
- dep.version)
120
- ).toSet
94
+ def nativeArtefacts (stack : List [Module ]): Set [(Platform , Dep )] =
95
+ stack.flatMap(_.scalaDeps).map(dep => Native -> dep).toSet
121
96
122
- def nativeDeps (build : Build , stack : List [Module ]): Set [Dep ] =
97
+ def nativeDeps (build : Build , stack : List [Module ]): Set [JavaDep ] =
123
98
build.project.scalaNativeVersion match {
124
99
case None => Set ()
125
100
case Some (scalaNativeVersion) =>
126
101
val scalaVersion = BuildConfig .scalaVersion(build.project, stack)
127
102
stack.flatMap(_.scalaDeps).map(dep =>
128
- dependencyFromArtefact(
129
- Artefact (dep.organisation, dep.artefact, PlatformSuffix .PlatformAndCompiler ),
130
- dep.version, Native , scalaNativeVersion, scalaVersion)
103
+ javaDepFromScalaDep(dep, Native , scalaNativeVersion, scalaVersion)
131
104
).toSet
132
105
}
133
106
134
- def compilerDeps (build : Build , module : Module ): List [Set [Dep ]] = {
135
- def f (build : Build , module : Module ): Set [Dep ] = {
107
+ def compilerDeps (build : Build , module : Module ): List [Set [JavaDep ]] = {
108
+ def f (build : Build , module : Module ): Set [JavaDep ] = {
136
109
import build .project .scalaOrganisation
137
110
val scalaVersion = BuildConfig .scalaVersion(build.project, List (module))
138
111
@@ -141,7 +114,7 @@ object ArtefactResolution {
141
114
Artefact .scalaLibrary(scalaOrganisation),
142
115
Artefact .scalaReflect(scalaOrganisation)
143
116
).map(artefact =>
144
- dependencyFromArtefact (artefact, scalaVersion, JVM , scalaVersion,
117
+ javaDepFromArtefact (artefact, scalaVersion, JVM , scalaVersion,
145
118
scalaVersion))
146
119
}
147
120
@@ -153,23 +126,23 @@ object ArtefactResolution {
153
126
).filter(_.nonEmpty)
154
127
}
155
128
156
- def allCompilerDeps (build : Build ): List [Set [Dep ]] =
129
+ def allCompilerDeps (build : Build ): List [Set [JavaDep ]] =
157
130
build.module.values.toList.flatMap(compilerDeps(build, _)).distinct
158
131
159
- def platformDeps (build : Build , module : Module ): Set [Dep ] =
132
+ def platformDeps (build : Build , module : Module ): Set [JavaDep ] =
160
133
module.targets.toSet[Platform ].flatMap { target =>
161
134
if (target == JavaScript )
162
135
jsPlatformDeps(build, module.js.getOrElse(Module ()))
163
136
else if (target == Native ) nativePlatformDeps(build,
164
137
module.native.getOrElse(Module ()))
165
- else Set [Dep ]()
138
+ else Set [JavaDep ]()
166
139
}
167
140
168
141
def libraryDeps (build : Build ,
169
142
module : Module ,
170
143
platforms : Set [Platform ],
171
144
parent : Module = Module ()
172
- ): Set [Dep ] = {
145
+ ): Set [JavaDep ] = {
173
146
val targets = if (module.targets.isEmpty) parent.targets else module.targets
174
147
targets.toSet[Platform ].intersect(platforms).flatMap { target =>
175
148
// Shared libraries
@@ -200,7 +173,7 @@ object ArtefactResolution {
200
173
def libraryArtefacts (build : Build ,
201
174
module : Module ,
202
175
parent : Module = Module ()
203
- ): Set [(Platform , Artefact . Versioned )] =
176
+ ): Set [(Platform , Dep )] =
204
177
module.targets.toSet[Platform ].flatMap { target =>
205
178
if (target == JVM ) jvmArtefacts(List (module, parent))
206
179
else if (target == JavaScript ) jsArtefacts(List (module, parent))
@@ -215,15 +188,15 @@ object ArtefactResolution {
215
188
List (native, parent.native.getOrElse(Module ()), module))) ++
216
189
module.test.toSet.flatMap(libraryArtefacts(build, _, module))
217
190
218
- def allPlatformDeps (build : Build ): Set [Dep ] =
191
+ def allPlatformDeps (build : Build ): Set [JavaDep ] =
219
192
build.module.values.toSet.flatMap(platformDeps(build, _))
220
193
221
194
def allLibraryDeps (build : Build ,
222
195
platforms : Set [Platform ] = Set (JVM , JavaScript , Native )
223
- ): Set [Dep ] =
196
+ ): Set [JavaDep ] =
224
197
build.module.values.toSet.flatMap(libraryDeps(build, _, platforms))
225
198
226
- def allLibraryArtefacts (build : Build ): Map [Platform , Set [Artefact . Versioned ]] =
199
+ def allLibraryArtefacts (build : Build ): Map [Platform , Set [Dep ]] =
227
200
build.module.values.toSet.flatMap(libraryArtefacts(build, _))
228
201
.groupBy(_._1)
229
202
.mapValues(_.map(_._2))
@@ -233,9 +206,9 @@ object ArtefactResolution {
233
206
scalaVersion : String ,
234
207
classPath : List [Path ]
235
208
): Resolution .ScalaCompiler = {
236
- val compilerDep = Dep (scalaOrganisation, " scala-compiler" , scalaVersion)
237
- val libraryDep = Dep (scalaOrganisation, " scala-library" , scalaVersion)
238
- val reflectDep = Dep (scalaOrganisation, " scala-reflect" , scalaVersion)
209
+ val compilerDep = JavaDep (scalaOrganisation, " scala-compiler" , scalaVersion)
210
+ val libraryDep = JavaDep (scalaOrganisation, " scala-library" , scalaVersion)
211
+ val reflectDep = JavaDep (scalaOrganisation, " scala-reflect" , scalaVersion)
239
212
240
213
val resolution = resolutionResult.find(r =>
241
214
Coursier .hasDep(r, compilerDep)).get
@@ -265,8 +238,8 @@ object ArtefactResolution {
265
238
build : Build ,
266
239
packageConfig : PackageConfig ,
267
240
optionalArtefacts : Boolean ,
268
- platformDeps : Set [Dep ],
269
- compilerDeps : List [Set [Dep ]],
241
+ platformDeps : Set [JavaDep ],
242
+ compilerDeps : List [Set [JavaDep ]],
270
243
) = {
271
244
val silent = packageConfig.silent || seedConfig.resolution.silent
272
245
if (! silent) Coursier .initLogger()
@@ -281,7 +254,7 @@ object ArtefactResolution {
281
254
build.resolvers.ivy.foreach(ivy => Log .info(" - " + Ansi .italic(ivy.url) + " (Ivy)" ))
282
255
build.resolvers.maven.foreach(maven => Log .info(" - " + Ansi .italic(maven) + " (Maven)" ))
283
256
284
- def resolve (deps : Set [Dep ]) =
257
+ def resolve (deps : Set [JavaDep ]) =
285
258
Coursier .resolveAndDownload(deps, build.resolvers, resolvedIvyPath,
286
259
resolvedCachePath, optionalArtefacts)
287
260
0 commit comments