1 package org.apache.maven.project.validation;
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.building.DefaultModelBuildingRequest;
24 import org.apache.maven.model.building.ModelBuildingRequest;
25 import org.apache.maven.model.building.ModelProblem;
26 import org.apache.maven.model.building.ModelProblemCollector;
27 import org.apache.maven.model.building.ModelProblemCollectorRequest;
28 import org.codehaus.plexus.component.annotations.Component;
29 import org.codehaus.plexus.component.annotations.Requirement;
30
31
32
33
34 @Component( role = ModelValidator.class )
35 @Deprecated
36 public class DefaultModelValidator
37 implements ModelValidator
38 {
39
40 @Requirement
41 private org.apache.maven.model.validation.ModelValidator modelValidator;
42
43 public ModelValidationResult validate( Model model )
44 {
45 ModelValidationResult result = new ModelValidationResult();
46
47 ModelBuildingRequest request =
48 new DefaultModelBuildingRequest().setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 );
49
50 SimpleModelProblemCollector problems = new SimpleModelProblemCollector( result );
51
52 modelValidator.validateEffectiveModel( model, request, problems );
53
54 return result;
55 }
56
57 private static class SimpleModelProblemCollector
58 implements ModelProblemCollector
59 {
60
61 ModelValidationResult result;
62
63 SimpleModelProblemCollector( ModelValidationResult result )
64 {
65 this.result = result;
66 }
67
68 public void add( ModelProblemCollectorRequest req )
69 {
70 if ( !ModelProblem.Severity.WARNING.equals( req.getSeverity() ) )
71 {
72 result.addMessage( req.getMessage() );
73 }
74 }
75 }
76 }