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 javax.inject.Named;
22 import javax.inject.Singleton;
23
24 import org.apache.maven.api.ArtifactCoordinate;
25 import org.apache.maven.api.annotations.Nonnull;
26 import org.apache.maven.api.services.ArtifactCoordinateFactory;
27 import org.apache.maven.api.services.ArtifactCoordinateFactoryRequest;
28 import org.eclipse.aether.artifact.ArtifactType;
29
30 import static org.apache.maven.internal.impl.Utils.nonNull;
31
32 @Named
33 @Singleton
34 public class DefaultArtifactCoordinateFactory implements ArtifactCoordinateFactory {
35 @Override
36 public ArtifactCoordinate create(@Nonnull ArtifactCoordinateFactoryRequest request) {
37 nonNull(request, "request");
38 InternalSession session = InternalSession.from(request.getSession());
39 if (request.getCoordinateString() != null) {
40 return new DefaultArtifactCoordinate(
41 session, new org.eclipse.aether.artifact.DefaultArtifact(request.getCoordinateString()));
42 } else {
43 ArtifactType type = null;
44 if (request.getType() != null) {
45 type = session.getSession().getArtifactTypeRegistry().get(request.getType());
46 }
47 String str1 = request.getClassifier();
48 String classifier = str1 != null && !str1.isEmpty()
49 ? request.getClassifier()
50 : type != null ? type.getClassifier() : "";
51 String str = request.getExtension();
52 String extension =
53 str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : "";
54 return new DefaultArtifactCoordinate(
55 session,
56 new org.eclipse.aether.artifact.DefaultArtifact(
57 request.getGroupId(),
58 request.getArtifactId(),
59 classifier,
60 extension,
61 request.getVersion(),
62 type));
63 }
64 }
65 }