1 | |
package org.apache.maven.archetype.ui; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.archetype.ArchetypeGenerationRequest; |
23 | |
import org.codehaus.plexus.util.StringUtils; |
24 | |
|
25 | |
public class ArchetypeDefinition |
26 | |
{ |
27 | |
private String groupId; |
28 | |
|
29 | |
private String artifactId; |
30 | |
|
31 | |
private String version; |
32 | |
|
33 | |
private String name; |
34 | |
|
35 | |
private String repository; |
36 | |
|
37 | |
private String goals; |
38 | |
|
39 | |
private String url; |
40 | |
|
41 | |
private String description; |
42 | |
|
43 | |
public ArchetypeDefinition() |
44 | 5 | { |
45 | 5 | } |
46 | |
|
47 | |
public ArchetypeDefinition( ArchetypeGenerationRequest request ) |
48 | 8 | { |
49 | 8 | setGroupId( request.getArchetypeGroupId() ); |
50 | 8 | setArtifactId( request.getArchetypeArtifactId() ); |
51 | 8 | setVersion( request.getArchetypeVersion() ); |
52 | 8 | } |
53 | |
|
54 | |
public String getArtifactId() |
55 | |
{ |
56 | 39 | return this.artifactId; |
57 | |
} |
58 | |
|
59 | |
public String getGoals() |
60 | |
{ |
61 | 7 | return this.goals; |
62 | |
} |
63 | |
|
64 | |
public String getGroupId() |
65 | |
{ |
66 | 64 | return this.groupId; |
67 | |
} |
68 | |
|
69 | |
public String getName() |
70 | |
{ |
71 | 7 | return this.name; |
72 | |
} |
73 | |
|
74 | |
public String getRepository() |
75 | |
{ |
76 | 8 | return this.repository; |
77 | |
} |
78 | |
|
79 | |
public String getVersion() |
80 | |
{ |
81 | 37 | return this.version; |
82 | |
} |
83 | |
|
84 | |
public String getUrl() |
85 | |
{ |
86 | 0 | return this.url; |
87 | |
} |
88 | |
|
89 | |
public String getDescription() |
90 | |
{ |
91 | 0 | return this.description; |
92 | |
} |
93 | |
|
94 | |
public void setArtifactId( String artifactId ) |
95 | |
{ |
96 | 17 | this.artifactId = artifactId; |
97 | 17 | } |
98 | |
|
99 | |
public void setGoals( String goals ) |
100 | |
{ |
101 | 2 | this.goals = goals; |
102 | 2 | } |
103 | |
|
104 | |
public void setGroupId( String groupId ) |
105 | |
{ |
106 | 18 | this.groupId = groupId; |
107 | 18 | } |
108 | |
|
109 | |
public void setName( String name ) |
110 | |
{ |
111 | 2 | this.name = name; |
112 | 2 | } |
113 | |
|
114 | |
public void setRepository( String repository ) |
115 | |
{ |
116 | 1 | this.repository = repository; |
117 | 1 | } |
118 | |
|
119 | |
public void setVersion( String version ) |
120 | |
{ |
121 | 18 | this.version = version; |
122 | 18 | } |
123 | |
|
124 | |
public void setUrl( String url ) |
125 | |
{ |
126 | 0 | this.url = url; |
127 | 0 | } |
128 | |
|
129 | |
public void setDescription( String description ) |
130 | |
{ |
131 | 0 | this.description = description; |
132 | 0 | } |
133 | |
|
134 | |
public void reset() |
135 | |
{ |
136 | 0 | setGroupId( null ); |
137 | 0 | setArtifactId( null ); |
138 | 0 | setVersion( null ); |
139 | 0 | } |
140 | |
|
141 | |
public boolean isArtifactDefined() |
142 | |
{ |
143 | 14 | return StringUtils.isNotEmpty( getArtifactId() ); |
144 | |
} |
145 | |
|
146 | |
public boolean isDefined() |
147 | |
{ |
148 | 18 | return isPartiallyDefined() && isVersionDefined(); |
149 | |
} |
150 | |
|
151 | |
public boolean isGroupDefined() |
152 | |
{ |
153 | 30 | return StringUtils.isNotEmpty( getGroupId() ); |
154 | |
} |
155 | |
|
156 | |
public boolean isPartiallyDefined() |
157 | |
{ |
158 | 30 | return isGroupDefined() && isArtifactDefined(); |
159 | |
} |
160 | |
|
161 | |
public boolean isVersionDefined() |
162 | |
{ |
163 | 6 | return StringUtils.isNotEmpty( getVersion() ); |
164 | |
} |
165 | |
|
166 | |
public void updateRequest( ArchetypeGenerationRequest request ) |
167 | |
{ |
168 | 5 | request.setArchetypeGroupId( getGroupId() ); |
169 | |
|
170 | 5 | request.setArchetypeArtifactId( getArtifactId() ); |
171 | |
|
172 | 5 | request.setArchetypeVersion( getVersion() ); |
173 | |
|
174 | 5 | request.setArchetypeGoals( getGoals() ); |
175 | |
|
176 | 5 | request.setArchetypeName( getName() ); |
177 | |
|
178 | 5 | if ( StringUtils.isNotEmpty( getRepository() ) ) |
179 | |
{ |
180 | 1 | request.setArchetypeRepository( getRepository() ); |
181 | |
} |
182 | 5 | } |
183 | |
} |