1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.impl;
20
21 import org.apache.maven.api.ArtifactCoordinates;
22 import org.apache.maven.api.annotations.Nonnull;
23 import org.apache.maven.api.di.Named;
24 import org.apache.maven.api.di.Singleton;
25 import org.apache.maven.api.services.ArtifactCoordinatesFactory;
26 import org.apache.maven.api.services.ArtifactCoordinatesFactoryRequest;
27 import org.eclipse.aether.artifact.ArtifactType;
28
29 import static org.apache.maven.internal.impl.Utils.nonNull;
30
31 @Named
32 @Singleton
33 public class DefaultArtifactCoordinatesFactory implements ArtifactCoordinatesFactory {
34 @Override
35 public ArtifactCoordinates create(@Nonnull ArtifactCoordinatesFactoryRequest request) {
36 nonNull(request, "request");
37 InternalSession session = InternalSession.from(request.getSession());
38 if (request.getCoordinatesString() != null) {
39 return new DefaultArtifactCoordinates(
40 session, new org.eclipse.aether.artifact.DefaultArtifact(request.getCoordinatesString()));
41 } else {
42 ArtifactType type = null;
43 if (request.getType() != null) {
44 type = session.getSession().getArtifactTypeRegistry().get(request.getType());
45 }
46 String str1 = request.getClassifier();
47 String classifier = str1 != null && !str1.isEmpty()
48 ? request.getClassifier()
49 : type != null ? type.getClassifier() : "";
50 String str = request.getExtension();
51 String extension =
52 str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : "";
53 return new DefaultArtifactCoordinates(
54 session,
55 new org.eclipse.aether.artifact.DefaultArtifact(
56 request.getGroupId(),
57 request.getArtifactId(),
58 classifier,
59 extension,
60 request.getVersion(),
61 type));
62 }
63 }
64 }