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.Artifact;
22 import org.apache.maven.api.ProducedArtifact;
23 import org.apache.maven.api.annotations.Nonnull;
24 import org.apache.maven.api.di.Named;
25 import org.apache.maven.api.di.Singleton;
26 import org.apache.maven.api.services.ArtifactFactory;
27 import org.apache.maven.api.services.ArtifactFactoryRequest;
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 DefaultArtifactFactory implements ArtifactFactory {
35 @Override
36 public Artifact create(@Nonnull ArtifactFactoryRequest request) {
37 nonNull(request, "request");
38 InternalSession session = InternalSession.from(request.getSession());
39 ArtifactType type = null;
40 if (request.getType() != null) {
41 type = session.getSession().getArtifactTypeRegistry().get(request.getType());
42 }
43 String str1 = request.getClassifier();
44 String classifier =
45 str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : null;
46 String str = request.getExtension();
47 String extension =
48 str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : null;
49 return new DefaultArtifact(
50 session,
51 new org.eclipse.aether.artifact.DefaultArtifact(
52 request.getGroupId(),
53 request.getArtifactId(),
54 classifier,
55 extension,
56 request.getVersion(),
57 type));
58 }
59
60 @Override
61 public ProducedArtifact createProduced(@Nonnull ArtifactFactoryRequest request) {
62 nonNull(request, "request");
63 InternalSession session = InternalSession.from(request.getSession());
64 ArtifactType type = null;
65 if (request.getType() != null) {
66 type = session.getSession().getArtifactTypeRegistry().get(request.getType());
67 }
68 String str1 = request.getClassifier();
69 String classifier =
70 str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : null;
71 String str = request.getExtension();
72 String extension =
73 str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : null;
74 return new DefaultProducedArtifact(
75 session,
76 new org.eclipse.aether.artifact.DefaultArtifact(
77 request.getGroupId(),
78 request.getArtifactId(),
79 classifier,
80 extension,
81 request.getVersion(),
82 type));
83 }
84 }