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