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.codehaus.plexus.components.interactivity.Prompter; |
23 | |
import org.codehaus.plexus.components.interactivity.PrompterException; |
24 | |
import org.codehaus.plexus.logging.AbstractLogEnabled; |
25 | |
|
26 | |
|
27 | 3 | public class DefaultArchetypeGenerationQueryer |
28 | |
extends AbstractLogEnabled |
29 | |
implements ArchetypeGenerationQueryer |
30 | |
{ |
31 | |
|
32 | |
private Prompter prompter; |
33 | |
|
34 | |
public boolean confirmConfiguration( ArchetypeConfiguration archetypeConfiguration ) |
35 | |
throws PrompterException |
36 | |
{ |
37 | 0 | StringBuilder query = new StringBuilder( "Confirm properties configuration:\n" ); |
38 | |
|
39 | 0 | for ( String property : archetypeConfiguration.getRequiredProperties() ) |
40 | |
{ |
41 | 0 | query.append( property + ": " + archetypeConfiguration.getProperty( property ) + "\n" ); |
42 | |
} |
43 | |
|
44 | 0 | String answer = prompter.prompt( query.toString(), "Y" ); |
45 | |
|
46 | 0 | return "Y".equalsIgnoreCase( answer ); |
47 | |
} |
48 | |
|
49 | |
public String getPropertyValue( String requiredProperty, String defaultValue ) |
50 | |
throws PrompterException |
51 | |
{ |
52 | 0 | String query = "Define value for property '" + requiredProperty + "': "; |
53 | |
String answer; |
54 | |
|
55 | 0 | if ( ( defaultValue != null ) && !defaultValue.equals( "null" ) ) |
56 | |
{ |
57 | 0 | answer = prompter.prompt( query, defaultValue ); |
58 | |
} |
59 | |
else |
60 | |
{ |
61 | 0 | answer = prompter.prompt( query ); |
62 | |
} |
63 | 0 | return answer; |
64 | |
} |
65 | |
} |