KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > model > converter > V4PomRewriter


1 package org.apache.maven.model.converter;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.maven.model.Model;
20 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
21 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
22
23 import java.io.Reader JavaDoc;
24 import java.io.Writer JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 /**
29  * @author jdcasey
30  */

31 public class V4PomRewriter
32     implements ArtifactPomRewriter
33 {
34     private ModelConverter translator;
35
36     public void rewrite( Reader from, Writer to, boolean reportOnly, String JavaDoc groupId, String JavaDoc artifactId, String JavaDoc version,
37                          String JavaDoc packaging )
38         throws Exception JavaDoc
39     {
40         Model model = null;
41
42         if ( from != null )
43         {
44             MavenXpp3Reader reader = new MavenXpp3Reader();
45
46             model = reader.read( from );
47         }
48         else
49         {
50             model = new Model();
51         }
52
53         if ( model != null )
54         {
55             translator.validateV4Basics( model, groupId, artifactId, version, packaging );
56
57             if ( !reportOnly )
58             {
59                 MavenXpp3Writer writer = new MavenXpp3Writer();
60                 writer.write( to, model );
61             }
62         }
63     }
64
65     public List JavaDoc getWarnings()
66     {
67         return translator.getWarnings();
68     }
69 }
Popular Tags