1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
package org.apache.maven.archetype.ui; |
21 | |
|
22 | |
import org.apache.maven.archetype.common.ArchetypeConfiguration; |
23 | |
import org.codehaus.plexus.components.interactivity.Prompter; |
24 | |
import org.codehaus.plexus.components.interactivity.PrompterException; |
25 | |
import org.codehaus.plexus.logging.AbstractLogEnabled; |
26 | |
|
27 | |
import java.util.Iterator; |
28 | |
|
29 | |
|
30 | 9 | public class DefaultArchetypeGenerationQueryer |
31 | |
extends AbstractLogEnabled |
32 | |
implements ArchetypeGenerationQueryer |
33 | |
{ |
34 | |
|
35 | |
private Prompter prompter; |
36 | |
|
37 | |
public boolean confirmConfiguration( ArchetypeConfiguration archetypeConfiguration ) |
38 | |
throws |
39 | |
PrompterException |
40 | |
{ |
41 | 0 | String query = "Confirm properties configuration:\n"; |
42 | |
|
43 | 0 | Iterator requiredPropertiesIter = |
44 | |
archetypeConfiguration.getRequiredProperties().iterator(); |
45 | |
|
46 | 0 | while ( requiredPropertiesIter.hasNext() ) |
47 | |
{ |
48 | 0 | String property = (String) requiredPropertiesIter.next(); |
49 | 0 | query += property + ": " + archetypeConfiguration.getProperty( property ) + "\n"; |
50 | 0 | } |
51 | |
|
52 | 0 | String answer = prompter.prompt( query, "Y" ); |
53 | |
|
54 | 0 | return "Y".equalsIgnoreCase( answer ); |
55 | |
} |
56 | |
|
57 | |
public String getPropertyValue( String requiredProperty, |
58 | |
String defaultValue ) |
59 | |
throws |
60 | |
PrompterException |
61 | |
{ |
62 | 0 | String query = "Define value for " + requiredProperty + ": "; |
63 | |
String answer; |
64 | |
|
65 | 0 | if ( ( defaultValue != null ) && !defaultValue.equals( "null" ) ) |
66 | |
{ |
67 | 0 | answer = prompter.prompt( query, defaultValue ); |
68 | |
} |
69 | |
else |
70 | |
{ |
71 | 0 | answer = prompter.prompt( query ); |
72 | |
} |
73 | 0 | return answer; |
74 | |
} |
75 | |
} |