97
97
@ Named
98
98
@ Singleton
99
99
public class DefaultModelBuilder implements ModelBuilder {
100
- /**
101
- * Key for "fail on invalid model" property.
102
- * <p>
103
- * Visible for testing.
104
- */
105
- static final String FAIL_ON_INVALID_MODEL = "maven.modelBuilder.failOnInvalidModel" ;
106
-
107
- /**
108
- * Checks user and system properties (in this order) for value of {@link #FAIL_ON_INVALID_MODEL} property key, if
109
- * set and returns it. If not set, defaults to {@code true}.
110
- * <p>
111
- * This is only meant to provide "escape hatch" for those builds, that are for some reason stuck with invalid models.
112
- */
113
- private static boolean isFailOnInvalidModel (ModelBuildingRequest request ) {
114
- String val = request .getUserProperties ().getProperty (FAIL_ON_INVALID_MODEL );
115
- if (val == null ) {
116
- val = request .getSystemProperties ().getProperty (FAIL_ON_INVALID_MODEL );
117
- }
118
- if (val != null ) {
119
- return Boolean .parseBoolean (val );
120
- }
121
- return true ;
122
- }
123
-
124
100
@ Inject
125
101
private ModelProcessor modelProcessor ;
126
102
@@ -277,7 +253,6 @@ public ModelBuildingResult build(ModelBuildingRequest request) throws ModelBuild
277
253
protected ModelBuildingResult build (ModelBuildingRequest request , Collection <String > importIds )
278
254
throws ModelBuildingException {
279
255
// phase 1
280
- boolean failOnInvalidModel = isFailOnInvalidModel (request );
281
256
DefaultModelBuildingResult result = new DefaultModelBuildingResult ();
282
257
283
258
DefaultModelProblemCollector problems = new DefaultModelProblemCollector (result );
@@ -331,7 +306,7 @@ protected ModelBuildingResult build(ModelBuildingRequest request, Collection<Str
331
306
profileActivationContext .setProjectProperties (tmpModel .getProperties ());
332
307
333
308
Map <String , Activation > interpolatedActivations =
334
- getInterpolatedActivations (rawModel , profileActivationContext , failOnInvalidModel , problems );
309
+ getInterpolatedActivations (rawModel , profileActivationContext , problems );
335
310
injectProfileActivations (tmpModel , interpolatedActivations );
336
311
337
312
List <Profile > activePomProfiles =
@@ -455,12 +430,8 @@ private interface InterpolateString {
455
430
}
456
431
457
432
private Map <String , Activation > getInterpolatedActivations (
458
- Model rawModel ,
459
- DefaultProfileActivationContext context ,
460
- boolean failOnInvalidModel ,
461
- DefaultModelProblemCollector problems ) {
462
- Map <String , Activation > interpolatedActivations =
463
- getProfileActivations (rawModel , true , failOnInvalidModel , problems );
433
+ Model rawModel , DefaultProfileActivationContext context , DefaultModelProblemCollector problems ) {
434
+ Map <String , Activation > interpolatedActivations = getProfileActivations (rawModel , true );
464
435
465
436
if (interpolatedActivations .isEmpty ()) {
466
437
return Collections .emptyMap ();
@@ -782,8 +753,7 @@ private void assembleInheritance(
782
753
}
783
754
}
784
755
785
- private Map <String , Activation > getProfileActivations (
786
- Model model , boolean clone , boolean failOnInvalidModel , ModelProblemCollector problems ) {
756
+ private Map <String , Activation > getProfileActivations (Model model , boolean clone ) {
787
757
Map <String , Activation > activations = new HashMap <>();
788
758
for (Profile profile : model .getProfiles ()) {
789
759
Activation activation = profile .getActivation ();
@@ -796,11 +766,7 @@ private Map<String, Activation> getProfileActivations(
796
766
activation = activation .clone ();
797
767
}
798
768
799
- if (activations .put (profile .getId (), activation ) != null ) {
800
- problems .add (new ModelProblemCollectorRequest (
801
- failOnInvalidModel ? Severity .FATAL : Severity .WARNING , ModelProblem .Version .BASE )
802
- .setMessage ("Duplicate activation for profile " + profile .getId ()));
803
- }
769
+ activations .put (profile .getId (), activation );
804
770
}
805
771
806
772
return activations ;
@@ -821,8 +787,7 @@ private void injectProfileActivations(Model model, Map<String, Activation> activ
821
787
822
788
private Model interpolateModel (Model model , ModelBuildingRequest request , ModelProblemCollector problems ) {
823
789
// save profile activations before interpolation, since they are evaluated with limited scope
824
- // at this stage we already failed if wanted to
825
- Map <String , Activation > originalActivations = getProfileActivations (model , true , false , problems );
790
+ Map <String , Activation > originalActivations = getProfileActivations (model , true );
826
791
827
792
Model interpolatedModel =
828
793
modelInterpolator .interpolateModel (model , model .getProjectDirectory (), request , problems );
0 commit comments