1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.commonjava.maven.plugins.execroot;
17
18 import org.apache.maven.plugin.MojoExecutionException;
19 import org.apache.maven.project.MavenProject;
20
21
22
23
24 public class ProjectRef {
25
26
27 private String groupId;
28
29
30 private String artifactId;
31
32
33
34
35
36
37 public String getGroupId() {
38 return groupId;
39 }
40
41
42
43
44
45
46
47 public void setGroupId(final String groupId) {
48 this.groupId = groupId;
49 }
50
51
52
53
54
55
56 public String getArtifactId() {
57 return artifactId;
58 }
59
60
61
62
63
64
65
66 public void setArtifactId(final String artifactId) {
67 this.artifactId = artifactId;
68 }
69
70
71
72
73
74
75
76 public void validate() throws MojoExecutionException {
77 if (empty(groupId) || empty(artifactId)) {
78 throw new MojoExecutionException("Project references must contain groupId AND artifactId.");
79 }
80 }
81
82
83
84
85
86
87
88
89
90 private boolean empty(final String str) {
91 return str == null || str.trim().length() == 0;
92 }
93
94
95
96
97
98
99
100
101
102 public boolean matches(final MavenProject project) {
103 return project.getGroupId().equals(groupId) && project.getArtifactId().equals(artifactId);
104 }
105
106 @Override
107 public String toString() {
108 return groupId + ":" + artifactId;
109 }
110
111 }