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