View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.archetype.ui;
20  
21  import org.apache.maven.archetype.ArchetypeGenerationRequest;
22  import org.codehaus.plexus.util.StringUtils;
23  
24  public class ArchetypeDefinition {
25      private String groupId;
26  
27      private String artifactId;
28  
29      private String version;
30  
31      private String name;
32  
33      private String repository;
34  
35      private String goals;
36  
37      private String url;
38  
39      private String description;
40  
41      public ArchetypeDefinition() {}
42  
43      public ArchetypeDefinition(ArchetypeGenerationRequest request) {
44          setGroupId(request.getArchetypeGroupId());
45          setArtifactId(request.getArchetypeArtifactId());
46          setVersion(request.getArchetypeVersion());
47      }
48  
49      public String getArtifactId() {
50          return this.artifactId;
51      }
52  
53      public String getGoals() {
54          return this.goals;
55      }
56  
57      public String getGroupId() {
58          return this.groupId;
59      }
60  
61      public String getName() {
62          return this.name;
63      }
64  
65      public String getRepository() {
66          return this.repository;
67      }
68  
69      public String getVersion() {
70          return this.version;
71      }
72  
73      public String getUrl() {
74          return this.url;
75      }
76  
77      public String getDescription() {
78          return this.description;
79      }
80  
81      public void setArtifactId(String artifactId) {
82          this.artifactId = artifactId;
83      }
84  
85      public void setGoals(String goals) {
86          this.goals = goals;
87      }
88  
89      public void setGroupId(String groupId) {
90          this.groupId = groupId;
91      }
92  
93      public void setName(String name) {
94          this.name = name;
95      }
96  
97      public void setRepository(String repository) {
98          this.repository = repository;
99      }
100 
101     public void setVersion(String version) {
102         this.version = version;
103     }
104 
105     public void setUrl(String url) {
106         this.url = url;
107     }
108 
109     public void setDescription(String description) {
110         this.description = description;
111     }
112 
113     public void reset() {
114         setGroupId(null);
115         setArtifactId(null);
116         setVersion(null);
117     }
118 
119     public boolean isArtifactDefined() {
120         return StringUtils.isNotEmpty(getArtifactId());
121     }
122 
123     public boolean isDefined() {
124         return isPartiallyDefined() && isVersionDefined();
125     }
126 
127     public boolean isGroupDefined() {
128         return StringUtils.isNotEmpty(getGroupId());
129     }
130 
131     public boolean isPartiallyDefined() {
132         return isGroupDefined() && isArtifactDefined();
133     }
134 
135     public boolean isVersionDefined() {
136         return StringUtils.isNotEmpty(getVersion());
137     }
138 
139     public void updateRequest(ArchetypeGenerationRequest request) {
140         request.setArchetypeGroupId(getGroupId());
141 
142         request.setArchetypeArtifactId(getArtifactId());
143 
144         request.setArchetypeVersion(getVersion());
145 
146         request.setArchetypeGoals(getGoals());
147 
148         request.setArchetypeName(getName());
149 
150         if (StringUtils.isNotEmpty(getRepository())) {
151             request.setArchetypeRepository(getRepository());
152         }
153     }
154 }