1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.basepom.inline.mojo;
16
17 import static com.google.common.base.Preconditions.checkState;
18
19 import org.apache.maven.artifact.Artifact;
20 import org.eclipse.aether.graph.Dependency;
21
22 public final class InlineDependency {
23
24 private ArtifactIdentifier artifactIdentifier = null;
25
26 private boolean transitive = true;
27 private boolean optionals = false;
28
29 public void setArtifact(String artifact) {
30 this.artifactIdentifier = new ArtifactIdentifier(artifact);
31 }
32
33 public ArtifactIdentifier getArtifactIdentifier() {
34 checkState(artifactIdentifier != null, "no artifact has been set!");
35 return artifactIdentifier;
36 }
37
38 public boolean isInlineTransitive() {
39 return transitive;
40 }
41
42 public InlineDependency setInlineTransitive(boolean transitive) {
43 this.transitive = transitive;
44 return this;
45 }
46
47 public boolean isInlineOptionals() {
48 return optionals;
49 }
50
51 public InlineDependency setInlineOptionals(boolean optionals) {
52 this.optionals = optionals;
53 return this;
54 }
55
56 public boolean matchDependency(Dependency dependency) {
57 return getArtifactIdentifier().matchDependency(dependency);
58 }
59
60 public boolean matchArtifact(Artifact artifact) {
61 return getArtifactIdentifier().matchArtifact(artifact);
62 }
63
64 @Override
65 public String toString() {
66 String flags = transitive ? "inline transitive" : "";
67 return String.format("%s [%s]", artifactIdentifier, flags);
68 }
69 }