/
Session.java
744 lines (677 loc) · 30.2 KB
/
Session.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.api;
import java.nio.file.Path;
import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.api.annotations.ThreadSafe;
import org.apache.maven.api.model.Repository;
import org.apache.maven.api.services.DependencyCoordinateFactory;
import org.apache.maven.api.settings.Settings;
/**
* The session to install / deploy / resolve artifacts and dependencies.
*
* TODO: move the remote repositories in the requests (plugins will need to access this list somehow)
* TODO: add request trace so that requests can be linked together and through the resolver
* TODO: add a Request interface holding session + parent request
*
* @since 4.0.0
*/
@Experimental
@ThreadSafe
public interface Session {
@Nonnull
Settings getSettings();
@Nonnull
LocalRepository getLocalRepository();
@Nonnull
List<RemoteRepository> getRemoteRepositories();
@Nonnull
SessionData getData();
/**
* Returns immutable user properties to use for interpolation. The user properties have been configured directly
* by the user, e.g. via the {@code -Dkey=value} parameter on the command line.
*
* @return the user properties, never {@code null}
*/
@Nonnull
Map<String, String> getUserProperties();
/**
* Returns immutable system properties to use for interpolation. The system properties are collected from the
* runtime environment such as {@link System#getProperties()} and environment variables
* (prefixed with {@code env.}).
*
* @return the system properties, never {@code null}
*/
@Nonnull
Map<String, String> getSystemProperties();
/**
* Each invocation computes a new map of effective properties. To be used in interpolation.
* <p>
* Effective properties are computed from system, user and optionally project properties, layered with
* defined precedence onto each other to achieve proper precedence. Precedence is defined as:
* <ul>
* <li>System properties (lowest precedence)</li>
* <li>Project properties (optional)</li>
* <li>User properties (highest precedence)</li>
* </ul>
* Note: Project properties contains properties injected from profiles, if applicable. Their precedence is
* {@code profile > project}, hence active profile property may override project property.
* <p>
* The caller of this method should decide whether there is a project in scope (hence, a project instance
* needs to be passed) or not.
*
* @param project {@link Project} or {@code null}.
* @return the effective properties, never {@code null}
*/
@Nonnull
Map<String, String> getEffectiveProperties(@Nullable Project project);
/**
* Returns the current maven version
* @return the maven version, never {@code null}
*/
@Nonnull
Version getMavenVersion();
int getDegreeOfConcurrency();
@Nonnull
Instant getStartTime();
/**
* Gets the directory of the topmost project being built, usually the current directory or the
* directory pointed at by the {@code -f/--file} command line argument.
*/
@Nonnull
Path getTopDirectory();
/**
* Gets the root directory of the session, which is the root directory for the top directory project.
*
* @throws IllegalStateException if the root directory could not be found
* @see #getTopDirectory()
* @see Project#getRootDirectory()
*/
@Nonnull
Path getRootDirectory();
@Nonnull
List<Project> getProjects();
/**
* Returns the plugin context for mojo being executed and the specified
* {@link Project}, never returns {@code null} as if context not present, creates it.
*
* <strong>Implementation note:</strong> while this method return type is {@link Map}, the
* returned map instance implements {@link java.util.concurrent.ConcurrentMap} as well.
*
* @throws org.apache.maven.api.services.MavenException if not called from the within a mojo execution
*/
@Nonnull
Map<String, Object> getPluginContext(@Nonnull Project project);
/**
* Retrieves the service for the interface
*
* @throws NoSuchElementException if the service could not be found
*/
@Nonnull
<T extends Service> T getService(@Nonnull Class<T> clazz);
/**
* Creates a derived session using the given local repository.
*
* @param localRepository the new local repository
* @return the derived session
* @throws NullPointerException if {@code localRepository} is null
*/
@Nonnull
Session withLocalRepository(@Nonnull LocalRepository localRepository);
/**
* Creates a derived session using the given remote repositories.
*
* @param repositories the new list of remote repositories
* @return the derived session
* @throws NullPointerException if {@code repositories} is null
*/
@Nonnull
Session withRemoteRepositories(@Nonnull List<RemoteRepository> repositories);
/**
* Register the given listener which will receive all events.
*
* @param listener the listener to register
* @throws NullPointerException if {@code listener} is null
*/
void registerListener(@Nonnull Listener listener);
/**
* Unregisters a previously registered listener.
*
* @param listener the listener to unregister
* @throws NullPointerException if {@code listener} is null
*/
void unregisterListener(@Nonnull Listener listener);
/**
* Returns the list of registered listeners.
*
* @return an immutable collection of listeners, never {@code null}
*/
@Nonnull
Collection<Listener> getListeners();
/**
* Shortcut for {@code getService(RepositoryFactory.class).createLocal(...)}.
*
* @param path location of the local repository to create
* @return cache of artifacts downloaded from a remote repository or built locally
*
* @see org.apache.maven.api.services.RepositoryFactory#createLocal(Path)
*/
@Nonnull
LocalRepository createLocalRepository(@Nonnull Path path);
/**
* Shortcut for {@code getService(RepositoryFactory.class).createRemote(...)}.
*
* @param id identifier of the remote repository to create
* @param url location of the remote repository
* @return remote repository that can be used to download or upload artifacts
*
* @see org.apache.maven.api.services.RepositoryFactory#createRemote(String, String)
*/
@Nonnull
RemoteRepository createRemoteRepository(@Nonnull String id, @Nonnull String url);
/**
* Shortcut for {@code getService(RepositoryFactory.class).createRemote(...)}.
*
* @param repository information needed for establishing connections with remote repository
* @return remote repository that can be used to download or upload artifacts
*
* @see org.apache.maven.api.services.RepositoryFactory#createRemote(Repository)
*/
@Nonnull
RemoteRepository createRemoteRepository(@Nonnull Repository repository);
/**
* Creates a coordinate out of string that is formatted like:
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}.
* <p>
* Shortcut for {@code getService(ArtifactFactory.class).create(...)}.
*
* @param coordString the string having "standard" coordinate.
* @return coordinate used to point to the artifact
*
* @see org.apache.maven.api.services.ArtifactCoordinateFactory#create(Session, String)
*/
@Nonnull
ArtifactCoordinate createArtifactCoordinate(@Nonnull String coordString);
/**
* Shortcut for {@code getService(ArtifactFactory.class).create(...)}.
*
* @param groupId the group identifier, or {@code null} is unspecified
* @param artifactId the artifact identifier, or {@code null} is unspecified
* @param version the artifact version, or {@code null} is unspecified
* @param extension the artifact extension, or {@code null} is unspecified
* @return coordinate used to point to the artifact
*
* @see org.apache.maven.api.services.ArtifactCoordinateFactory#create(Session, String, String, String, String)
*/
@Nonnull
ArtifactCoordinate createArtifactCoordinate(String groupId, String artifactId, String version, String extension);
/**
* Shortcut for {@code getService(ArtifactFactory.class).create(...)}.
*
* @param groupId the group identifier, or {@code null} is unspecified
* @param artifactId the artifact identifier, or {@code null} is unspecified
* @param version the artifact version, or {@code null} is unspecified
* @param classifier the artifact classifier, or {@code null} is unspecified
* @param extension the artifact extension, or {@code null} is unspecified
* @param type the artifact type, or {@code null} is unspecified
* @return coordinate used to point to the artifact
*
* @see org.apache.maven.api.services.ArtifactCoordinateFactory#create(Session, String, String, String, String, String, String)
*/
@Nonnull
ArtifactCoordinate createArtifactCoordinate(
String groupId, String artifactId, String version, String classifier, String extension, String type);
/**
* Shortcut for {@code getService(ArtifactFactory.class).create(...)}.
*
* @param artifact artifact from which to get coordinates
* @return coordinate used to point to the artifact
*
* @see org.apache.maven.api.services.ArtifactCoordinateFactory#create(Session, String, String, String, String, String, String)
*/
@Nonnull
ArtifactCoordinate createArtifactCoordinate(@Nonnull Artifact artifact);
/**
* Shortcut for {@code getService(DependencyFactory.class).create(...)}.
*
* @param coordinate artifact coordinate to get as a dependency coordinate
* @return dependency coordinate for the given artifact
*
* @see DependencyCoordinateFactory#create(Session, ArtifactCoordinate)
*/
@Nonnull
DependencyCoordinate createDependencyCoordinate(@Nonnull ArtifactCoordinate coordinate);
/**
* Shortcut for {@code getService(DependencyFactory.class).create(...)}.
*
* @param dependency dependency for which to get the coordinate
* @return coordinate for the given dependency
*
* @see DependencyCoordinateFactory#create(Session, Dependency)
*/
@Nonnull
DependencyCoordinate createDependencyCoordinate(@Nonnull Dependency dependency);
/**
* Shortcut for {@code getService(ArtifactFactory.class).create(...)}.
*
* @param groupId the group identifier, or {@code null} is unspecified
* @param artifactId the artifact identifier, or {@code null} is unspecified
* @param version the artifact version, or {@code null} is unspecified
* @param extension the artifact extension, or {@code null} is unspecified
* @return artifact with the given coordinates
*
* @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String)
*/
@Nonnull
Artifact createArtifact(String groupId, String artifactId, String version, String extension);
/**
* Shortcut for {@code getService(ArtifactFactory.class).create(...)}.
*
* @param groupId the group identifier, or {@code null} is unspecified
* @param artifactId the artifact identifier, or {@code null} is unspecified
* @param version the artifact version, or {@code null} is unspecified
* @param classifier the artifact classifier, or {@code null} is unspecified
* @param extension the artifact extension, or {@code null} is unspecified
* @param type the artifact type, or {@code null} is unspecified
* @return artifact with the given coordinates
*
* @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String, String, String)
*/
@Nonnull
Artifact createArtifact(
String groupId, String artifactId, String version, String classifier, String extension, String type);
/**
* Shortcut for {@code getService(ArtifactResolver.class).resolve(...)}.
*
* @param coordinate coordinates of the artifact to resolve
* @return requested artifact together with the path to its file
* @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
*
* @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
*/
@Nonnull
Map.Entry<Artifact, Path> resolveArtifact(@Nonnull ArtifactCoordinate coordinate);
/**
* Shortcut for {@code getService(ArtifactResolver.class).resolve(...)}.
*
* @param coordinates coordinates of all artifacts to resolve
* @return requested artifacts together with the paths to their files
* @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
*
* @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
*/
@Nonnull
Map<Artifact, Path> resolveArtifacts(@Nonnull ArtifactCoordinate... coordinates);
/**
* Shortcut for {@code getService(ArtifactResolver.class).resolve(...)}.
*
* @param coordinates coordinates of all artifacts to resolve
* @return requested artifacts together with the paths to their files
* @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
*
* @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
*/
@Nonnull
Map<Artifact, Path> resolveArtifacts(@Nonnull Collection<? extends ArtifactCoordinate> coordinates);
/**
* Shortcut for {@code getService(ArtifactResolver.class).resolve(...)}.
*
* @param artifact the artifact to resolve
* @return requested artifact together with the path to its file
* @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
*
* @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
*/
@Nonnull
Map.Entry<Artifact, Path> resolveArtifact(@Nonnull Artifact artifact);
/**
* Shortcut for {@code getService(ArtifactResolver.class).resolve(...)}.
*
* @param artifacts all artifacts to resolve
* @return requested artifacts together with the paths to their files
* @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
*
* @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
*/
@Nonnull
Map<Artifact, Path> resolveArtifacts(@Nonnull Artifact... artifacts);
/**
* Shortcut for {@code getService(ArtifactInstaller.class).install(...)}.
*
* @param artifacts the artifacts to install
* @throws org.apache.maven.api.services.ArtifactInstallerException if the artifacts installation failed
*
* @see org.apache.maven.api.services.ArtifactInstaller#install(Session, Collection)
*/
void installArtifacts(@Nonnull Artifact... artifacts);
/**
* Shortcut for {@code getService(ArtifactInstaller.class).install(...)}.
*
* @param artifacts the artifacts to install
* @throws org.apache.maven.api.services.ArtifactInstallerException if the artifacts installation failed
*
* @see org.apache.maven.api.services.ArtifactInstaller#install(Session, Collection)
*/
void installArtifacts(@Nonnull Collection<Artifact> artifacts);
/**
* Shortcut for {@code getService(ArtifactDeployer.class).deploy(...)}.
*
* @param repository the repository where to deploy artifacts
* @param artifacts the artifacts to deploy
* @throws org.apache.maven.api.services.ArtifactDeployerException if the artifacts deployment failed
*
* @see org.apache.maven.api.services.ArtifactDeployer#deploy(Session, RemoteRepository, Collection)
*/
void deployArtifact(@Nonnull RemoteRepository repository, @Nonnull Artifact... artifacts);
/**
* Shortcut for {@code getService(ArtifactManager.class).setPath(...)}.
*
* @param artifact the artifact for which to associate a path
* @param path path to associate to the given artifact
*
* @see org.apache.maven.api.services.ArtifactManager#setPath(Artifact, Path)
*/
void setArtifactPath(@Nonnull Artifact artifact, @Nonnull Path path);
/**
* Shortcut for {@code getService(ArtifactManager.class).getPath(...)}.
*
* @param artifact the artifact for which to get a path
* @return path associated to the given artifact
*
* @see org.apache.maven.api.services.ArtifactManager#getPath(Artifact)
*/
@Nonnull
Optional<Path> getArtifactPath(@Nonnull Artifact artifact);
/**
* Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at
* the returned location, the path merely indicates where the artifact would eventually be stored.
* <p>
* Shortcut for {@code getService(LocalArtifactManager.class).getPathForLocalArtitact(...)}.
*
* @param artifact the artifact for which to get a local path
* @return local path associated to the given artifact, or {@code null} if none
*
* @see org.apache.maven.api.services.LocalRepositoryManager#getPathForLocalArtifact(Session, LocalRepository, Artifact)
*/
Path getPathForLocalArtifact(@Nonnull Artifact artifact);
/**
* Gets the relative path for an artifact cached from a remote repository.
* Note that the artifact need not actually exist yet at the returned location,
* the path merely indicates where the artifact would eventually be stored.
* <p>
* Shortcut for {@code getService(LocalArtifactManager.class).getPathForRemoteArtifact(...)}.
*
* @param remote the repository from where artifacts are downloaded
* @param artifact the artifact for which to get a path
* @return path associated to the given artifact
*
* @see org.apache.maven.api.services.LocalRepositoryManager#getPathForRemoteArtifact(Session, LocalRepository, RemoteRepository, Artifact)
*/
@Nonnull
Path getPathForRemoteArtifact(@Nonnull RemoteRepository remote, @Nonnull Artifact artifact);
/**
* Checks whether a given artifact version is considered a {@code SNAPSHOT} or not.
* <p>
* Shortcut for {@code getService(ArtifactManager.class).isSnapshot(...)}.
* <p>
* In case there is {@link Artifact} in scope, the recommended way to perform this check is
* use of {@link Artifact#isSnapshot()} instead.
*
* @param version artifact version
* @return whether the given version is a snapshot
*
* @see org.apache.maven.api.services.VersionParser#isSnapshot(String)
*/
boolean isVersionSnapshot(@Nonnull String version);
/**
* Shortcut for {@code getService(DependencyCollector.class).collect(...)}
*
* @param artifact artifact for which to get the dependencies, including transitive ones
* @return root node of the dependency graph for the given artifact
*
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, Artifact)
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
*/
@Nonnull
Node collectDependencies(@Nonnull Artifact artifact);
/**
* Shortcut for {@code getService(DependencyCollector.class).collect(...)}
*
* @param project project for which to get the dependencies, including transitive ones
* @return root node of the dependency graph for the given project
*
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, Project)
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
*/
@Nonnull
Node collectDependencies(@Nonnull Project project);
/**
* Collects the transitive dependencies of some artifacts and builds a dependency graph. Note that this operation is
* only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the
* artifact files.
* <p>
* Shortcut for {@code getService(DependencyCollector.class).resolve(...)}
*
* @param dependency dependency for which to get transitive dependencies
* @return root node of the dependency graph for the given artifact
*
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, DependencyCoordinate)
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
*/
@Nonnull
Node collectDependencies(@Nonnull DependencyCoordinate dependency);
/**
* Shortcut for {@code getService(DependencyResolver.class).flatten(...)}.
*
* @param node node for which to get a flattened list
* @param scope build path scope (main compile, test compile, etc.) of desired nodes
* @return flattened list of node with the given build path scope
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency flattening failed
*
* @see org.apache.maven.api.services.DependencyResolver#flatten(Session, Node, PathScope)
*/
@Nonnull
List<Node> flattenDependencies(@Nonnull Node node, @Nonnull PathScope scope);
/**
* Shortcut for {@code getService(DependencyResolver.class).resolve(...).getPaths()}.
*
* @param dependencyCoordinate coordinate of the dependency for which to get the paths
* @return paths to the transitive dependencies of the given dependency
*
* @see org.apache.maven.api.services.DependencyResolver#resolve(Session, DependencyCoordinate)
*/
@Nonnull
List<Path> resolveDependencies(@Nonnull DependencyCoordinate dependencyCoordinate);
/**
* Shortcut for {@code getService(DependencyResolver.class).resolve(...).getPaths()}.
*
* @param dependencyCoordinates coordinates of all dependency for which to get the paths
* @return paths to the transitive dependencies of the given dependencies
*
* @see org.apache.maven.api.services.DependencyResolver#resolve(Session, List)
*/
@Nonnull
List<Path> resolveDependencies(@Nonnull List<DependencyCoordinate> dependencyCoordinates);
/**
* Shortcut for {@code getService(DependencyResolver.class).resolve(...).getPaths()}.
*
* @param project the project for which to get dependencies
* @param scope build path scope (main compile, test compile, etc.) of desired paths
* @return paths to the transitive dependencies of the given project
*
* @see org.apache.maven.api.services.DependencyResolver#resolve(Session, Project, PathScope)
*/
@Nonnull
List<Path> resolveDependencies(@Nonnull Project project, @Nonnull PathScope scope);
/**
* Shortcut for {@code getService(DependencyResolver.class).resolve(...).getDispatchedPaths()}.
*
* @param dependencyCoordinate coordinate of the dependency for which to get the paths
* @param scope build path scope (main compile, test compile, etc.) of desired paths
* @param desiredTypes the type of paths to include in the result
* @return paths to the transitive dependencies of the given project
*
* @see org.apache.maven.api.services.DependencyResolver#resolve(Session, Project, PathScope)
*/
@Nonnull
Map<PathType, List<Path>> resolveDependencies(
@Nonnull DependencyCoordinate dependencyCoordinate,
@Nonnull PathScope scope,
@Nonnull Collection<PathType> desiredTypes);
/**
* Shortcut for {@code getService(DependencyResolver.class).resolve(...).getDispatchedPaths()}.
*
* @param project the project for which to get dependencies
* @param scope build path scope (main compile, test compile, etc.) of desired paths
* @param desiredTypes the type of paths to include in the result
* @return paths to the transitive dependencies of the given project
*
* @see org.apache.maven.api.services.DependencyResolver#resolve(Session, Project, PathScope)
*/
@Nonnull
Map<PathType, List<Path>> resolveDependencies(
@Nonnull Project project, @Nonnull PathScope scope, @Nonnull Collection<PathType> desiredTypes);
/**
* Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT"
* to "1.0-20090208.132618-23" or "RELEASE"/"LATEST" to "2.0".
* <p>
* Shortcut for {@code getService(VersionResolver.class).resolve(...)}
*
* @param artifact the artifact for which to resolve the version
* @return resolved version of the given artifact
* @throws org.apache.maven.api.services.VersionResolverException if the resolution failed
*
* @see org.apache.maven.api.services.VersionResolver#resolve(Session, ArtifactCoordinate) (String)
*/
@Nonnull
Version resolveVersion(@Nonnull ArtifactCoordinate artifact);
/**
* Expands a version range to a list of matching versions, in ascending order.
* For example, resolves "[3.8,4.0)" to "3.8", "3.8.1", "3.8.2".
* The returned list of versions is only dependent on the configured repositories and their contents.
* The supplied request may also refer to a single concrete version rather than a version range.
* In this case though, the result contains simply the (parsed) input version, regardless of the
* repositories and their contents.
*
* @param artifact the artifact for which to resolve the versions
* @return a list of resolved {@code Version}s.
* @throws org.apache.maven.api.services.VersionRangeResolverException if the resolution failed
* @see org.apache.maven.api.services.VersionRangeResolver#resolve(Session, ArtifactCoordinate) (String)
*/
@Nonnull
List<Version> resolveVersionRange(@Nonnull ArtifactCoordinate artifact);
/**
* Parses the specified version string, for example "1.0".
* <p>
* Shortcut for {@code getService(VersionParser.class).parseVersion(...)}.
*
* @param version the version string to parse
* @return the version parsed from the given string
* @throws org.apache.maven.api.services.VersionParserException if the parsing failed
* @see org.apache.maven.api.services.VersionParser#parseVersion(String)
*/
@Nonnull
Version parseVersion(@Nonnull String version);
/**
* Parses the specified version range specification, for example "[1.0,2.0)".
* <p>
* Shortcut for {@code getService(VersionParser.class).parseVersionRange(...)}.
*
* @param versionRange the version string to parse
* @return the version range parsed from the given string
* @throws org.apache.maven.api.services.VersionParserException if the parsing failed
* @see org.apache.maven.api.services.VersionParser#parseVersionRange(String)
*/
@Nonnull
VersionRange parseVersionRange(@Nonnull String versionRange);
/**
* Parses the specified version constraint specification, for example "1.0" or "[1.0,2.0)".
* <p>
* Shortcut for {@code getService(VersionParser.class).parseVersionConstraint(...)}.
*
* @param versionConstraint the version string to parse
* @return the version constraint parsed from the given string
* @throws org.apache.maven.api.services.VersionParserException if the parsing failed
* @see org.apache.maven.api.services.VersionParser#parseVersionConstraint(String)
*/
@Nonnull
VersionConstraint parseVersionConstraint(@Nonnull String versionConstraint);
/**
* Obtain the {@link Type} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(TypeRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.TypeRegistry#require(String)
*/
@Nonnull
Type requireType(@Nonnull String id);
/**
* Obtain the {@link Language} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(LanguageRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.LanguageRegistry#require(String)
*/
@Nonnull
Language requireLanguage(@Nonnull String id);
/**
* Obtain the {@link Packaging} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(PackagingRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.PackagingRegistry#require(String)
*/
@Nonnull
Packaging requirePackaging(@Nonnull String id);
/**
* Obtain the {@link ProjectScope} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(ProjectScopeRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.ProjectScopeRegistry#require(String)
*/
@Nonnull
ProjectScope requireProjectScope(@Nonnull String id);
/**
* Obtain the {@link DependencyScope} from the specified {@code id}.
* <p>
* Shortcut for {@code DependencyScope.forId(...)}.
*
* @see org.apache.maven.api.DependencyScope#forId(String)
*/
@Nonnull
DependencyScope requireDependencyScope(@Nonnull String id);
/**
* Obtain the {@link PathScope} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(PathScopeRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.PathScopeRegistry#require(String)
*/
@Nonnull
PathScope requirePathScope(@Nonnull String id);
}