1 | |
package org.apache.maven.plugin.toolchain; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.HashMap; |
23 | |
import java.util.Map; |
24 | |
|
25 | |
import org.codehaus.plexus.component.configurator.ComponentConfigurationException; |
26 | |
import org.codehaus.plexus.component.configurator.ConfigurationListener; |
27 | |
import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; |
28 | |
import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; |
29 | |
import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; |
30 | |
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; |
31 | |
import org.codehaus.plexus.configuration.PlexusConfiguration; |
32 | |
import org.codehaus.plexus.configuration.PlexusConfigurationException; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class ToolchainConverter |
40 | |
extends AbstractConfigurationConverter |
41 | |
{ |
42 | |
|
43 | 0 | public static final String ROLE = ConfigurationConverter.class.getName(); |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public boolean canConvert( Class type ) |
49 | |
{ |
50 | 0 | return Toolchains.class.isAssignableFrom( type ); |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
public Object fromConfiguration( ConverterLookup converterLookup, |
57 | |
PlexusConfiguration configuration, |
58 | |
Class type, Class baseType, |
59 | |
ClassLoader classLoader, |
60 | |
ExpressionEvaluator expressionEvaluator, |
61 | |
ConfigurationListener listener ) |
62 | |
throws ComponentConfigurationException |
63 | |
{ |
64 | 0 | Toolchains retValue = new Toolchains(); |
65 | 0 | processConfiguration( retValue, configuration, expressionEvaluator ); |
66 | |
|
67 | 0 | return retValue; |
68 | |
} |
69 | |
|
70 | |
private void processConfiguration( Toolchains chain, |
71 | |
PlexusConfiguration configuration, |
72 | |
ExpressionEvaluator expressionEvaluator ) |
73 | |
throws ComponentConfigurationException |
74 | |
{ |
75 | 0 | Map map = new HashMap(); |
76 | 0 | PlexusConfiguration[] tools = configuration.getChildren(); |
77 | 0 | for ( int i = 0; i < tools.length; i++ ) |
78 | |
{ |
79 | 0 | String type = tools[i].getName(); |
80 | 0 | PlexusConfiguration[] params = tools[i].getChildren(); |
81 | 0 | Map parameters = new HashMap(); |
82 | 0 | for ( int j = 0; j < params.length; j++ ) |
83 | |
{ |
84 | |
try |
85 | |
{ |
86 | 0 | String name = params[j].getName(); |
87 | 0 | String val = params[j].getValue(); |
88 | 0 | parameters.put( name, val ); |
89 | |
} |
90 | 0 | catch ( PlexusConfigurationException ex ) |
91 | |
{ |
92 | 0 | throw new ComponentConfigurationException( ex ); |
93 | 0 | } |
94 | |
} |
95 | 0 | map.put( type, parameters ); |
96 | |
} |
97 | 0 | chain.toolchains = map; |
98 | 0 | } |
99 | |
} |