1 package org.apache.maven.model.converter;
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.io.xpp3.MavenXpp3Reader;
24 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
25
26 import java.io.Reader;
27 import java.io.Writer;
28 import java.util.List;
29
30
31
32
33
34 public class V4PomRewriter
35 implements ArtifactPomRewriter
36 {
37
38
39
40 private ModelConverter translator;
41
42 public void rewrite( Reader from, Writer to, boolean reportOnly, String groupId, String artifactId, String version,
43 String packaging )
44 throws Exception
45 {
46 Model model = null;
47
48 if ( from != null )
49 {
50 MavenXpp3Reader reader = new MavenXpp3Reader();
51
52 model = reader.read( from );
53 }
54 else
55 {
56 model = new Model();
57 }
58
59 if ( model != null )
60 {
61 translator.validateV4Basics( model, groupId, artifactId, version, packaging );
62
63 if ( !reportOnly )
64 {
65 MavenXpp3Writer writer = new MavenXpp3Writer();
66 writer.write( to, model );
67 }
68 }
69 }
70
71 public List getWarnings()
72 {
73 return translator.getWarnings();
74 }
75 }