1 package org.apache.maven.model.building;
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.model.Model;
23 import org.apache.maven.model.composition.DefaultDependencyManagementImporter;
24 import org.apache.maven.model.composition.DependencyManagementImporter;
25 import org.apache.maven.model.inheritance.DefaultInheritanceAssembler;
26 import org.apache.maven.model.inheritance.InheritanceAssembler;
27 import org.apache.maven.model.interpolation.ModelInterpolator;
28 import org.apache.maven.model.interpolation.StringSearchModelInterpolator;
29 import org.apache.maven.model.io.DefaultModelReader;
30 import org.apache.maven.model.io.ModelReader;
31 import org.apache.maven.model.locator.DefaultModelLocator;
32 import org.apache.maven.model.locator.ModelLocator;
33 import org.apache.maven.model.management.DefaultDependencyManagementInjector;
34 import org.apache.maven.model.management.DefaultPluginManagementInjector;
35 import org.apache.maven.model.management.DependencyManagementInjector;
36 import org.apache.maven.model.management.PluginManagementInjector;
37 import org.apache.maven.model.normalization.DefaultModelNormalizer;
38 import org.apache.maven.model.normalization.ModelNormalizer;
39 import org.apache.maven.model.path.DefaultModelPathTranslator;
40 import org.apache.maven.model.path.DefaultModelUrlNormalizer;
41 import org.apache.maven.model.path.DefaultPathTranslator;
42 import org.apache.maven.model.path.DefaultUrlNormalizer;
43 import org.apache.maven.model.path.ModelPathTranslator;
44 import org.apache.maven.model.path.ModelUrlNormalizer;
45 import org.apache.maven.model.path.PathTranslator;
46 import org.apache.maven.model.path.UrlNormalizer;
47 import org.apache.maven.model.plugin.DefaultPluginConfigurationExpander;
48 import org.apache.maven.model.plugin.DefaultReportConfigurationExpander;
49 import org.apache.maven.model.plugin.DefaultReportingConverter;
50 import org.apache.maven.model.plugin.LifecycleBindingsInjector;
51 import org.apache.maven.model.plugin.PluginConfigurationExpander;
52 import org.apache.maven.model.plugin.ReportConfigurationExpander;
53 import org.apache.maven.model.plugin.ReportingConverter;
54 import org.apache.maven.model.profile.DefaultProfileInjector;
55 import org.apache.maven.model.profile.DefaultProfileSelector;
56 import org.apache.maven.model.profile.ProfileInjector;
57 import org.apache.maven.model.profile.ProfileSelector;
58 import org.apache.maven.model.profile.activation.FileProfileActivator;
59 import org.apache.maven.model.profile.activation.JdkVersionProfileActivator;
60 import org.apache.maven.model.profile.activation.OperatingSystemProfileActivator;
61 import org.apache.maven.model.profile.activation.ProfileActivator;
62 import org.apache.maven.model.profile.activation.PropertyProfileActivator;
63 import org.apache.maven.model.superpom.DefaultSuperPomProvider;
64 import org.apache.maven.model.superpom.SuperPomProvider;
65 import org.apache.maven.model.validation.DefaultModelValidator;
66 import org.apache.maven.model.validation.ModelValidator;
67
68
69
70
71
72
73
74
75
76 public class DefaultModelBuilderFactory
77 {
78
79 protected ModelProcessor newModelProcessor()
80 {
81 DefaultModelProcessor processor = new DefaultModelProcessor();
82 processor.setModelLocator( newModelLocator() );
83 processor.setModelReader( newModelReader() );
84 return processor;
85 }
86
87 protected ModelLocator newModelLocator()
88 {
89 return new DefaultModelLocator();
90 }
91
92 protected ModelReader newModelReader()
93 {
94 return new DefaultModelReader();
95 }
96
97 protected ProfileSelector newProfileSelector()
98 {
99 DefaultProfileSelector profileSelector = new DefaultProfileSelector();
100
101 for ( ProfileActivator activator : newProfileActivators() )
102 {
103 profileSelector.addProfileActivator( activator );
104 }
105
106 return profileSelector;
107 }
108
109 protected ProfileActivator[] newProfileActivators()
110 {
111 return new ProfileActivator[] { new JdkVersionProfileActivator(), new OperatingSystemProfileActivator(),
112 new PropertyProfileActivator(), new FileProfileActivator().setPathTranslator( newPathTranslator() ) };
113 }
114
115 protected UrlNormalizer newUrlNormalizer()
116 {
117 return new DefaultUrlNormalizer();
118 }
119
120 protected PathTranslator newPathTranslator()
121 {
122 return new DefaultPathTranslator();
123 }
124
125 protected ModelInterpolator newModelInterpolator()
126 {
127 UrlNormalizer normalizer = newUrlNormalizer();
128 PathTranslator pathTranslator = newPathTranslator();
129 return new StringSearchModelInterpolator().setPathTranslator( pathTranslator ).setUrlNormalizer( normalizer );
130 }
131
132 protected ModelValidator newModelValidator()
133 {
134 return new DefaultModelValidator();
135 }
136
137 protected ModelNormalizer newModelNormalizer()
138 {
139 return new DefaultModelNormalizer();
140 }
141
142 protected ModelPathTranslator newModelPathTranslator()
143 {
144 return new DefaultModelPathTranslator().setPathTranslator( newPathTranslator() );
145 }
146
147 protected ModelUrlNormalizer newModelUrlNormalizer()
148 {
149 return new DefaultModelUrlNormalizer().setUrlNormalizer( newUrlNormalizer() );
150 }
151
152 protected InheritanceAssembler newInheritanceAssembler()
153 {
154 return new DefaultInheritanceAssembler();
155 }
156
157 protected ProfileInjector newProfileInjector()
158 {
159 return new DefaultProfileInjector();
160 }
161
162 protected SuperPomProvider newSuperPomProvider()
163 {
164 return new DefaultSuperPomProvider().setModelProcessor( newModelProcessor() );
165 }
166
167 protected DependencyManagementImporter newDependencyManagementImporter()
168 {
169 return new DefaultDependencyManagementImporter();
170 }
171
172 protected DependencyManagementInjector newDependencyManagementInjector()
173 {
174 return new DefaultDependencyManagementInjector();
175 }
176
177 protected LifecycleBindingsInjector newLifecycleBindingsInjector()
178 {
179 return new StubLifecycleBindingsInjector();
180 }
181
182 protected PluginManagementInjector newPluginManagementInjector()
183 {
184 return new DefaultPluginManagementInjector();
185 }
186
187 protected PluginConfigurationExpander newPluginConfigurationExpander()
188 {
189 return new DefaultPluginConfigurationExpander();
190 }
191
192 protected ReportConfigurationExpander newReportConfigurationExpander()
193 {
194 return new DefaultReportConfigurationExpander();
195 }
196
197 protected ReportingConverter newReportingConverter()
198 {
199 return new DefaultReportingConverter();
200 }
201
202
203
204
205
206
207 public DefaultModelBuilder newInstance()
208 {
209 DefaultModelBuilder modelBuilder = new DefaultModelBuilder();
210
211 modelBuilder.setModelProcessor( newModelProcessor() );
212 modelBuilder.setModelValidator( newModelValidator() );
213 modelBuilder.setModelNormalizer( newModelNormalizer() );
214 modelBuilder.setModelPathTranslator( newModelPathTranslator() );
215 modelBuilder.setModelUrlNormalizer( newModelUrlNormalizer() );
216 modelBuilder.setModelInterpolator( newModelInterpolator() );
217 modelBuilder.setInheritanceAssembler( newInheritanceAssembler() );
218 modelBuilder.setProfileInjector( newProfileInjector() );
219 modelBuilder.setProfileSelector( newProfileSelector() );
220 modelBuilder.setSuperPomProvider( newSuperPomProvider() );
221 modelBuilder.setDependencyManagementImporter( newDependencyManagementImporter() );
222 modelBuilder.setDependencyManagementInjector( newDependencyManagementInjector() );
223 modelBuilder.setLifecycleBindingsInjector( newLifecycleBindingsInjector() );
224 modelBuilder.setPluginManagementInjector( newPluginManagementInjector() );
225 modelBuilder.setPluginConfigurationExpander( newPluginConfigurationExpander() );
226 modelBuilder.setReportConfigurationExpander( newReportConfigurationExpander() );
227 modelBuilder.setReportingConverter( newReportingConverter() );
228
229 return modelBuilder;
230 }
231
232 private static class StubLifecycleBindingsInjector
233 implements LifecycleBindingsInjector
234 {
235
236 @Override
237 public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
238 {
239 }
240
241 }
242
243 }