Coverage Report - org.apache.maven.its.plugins.SerializeMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
SerializeMojo
0 %
0/13
N/A
3
 
 1  
 package org.apache.maven.its.plugins;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.File;
 23  
 import java.io.FileOutputStream;
 24  
 import java.io.IOException;
 25  
 import java.io.OutputStreamWriter;
 26  
 import java.io.Writer;
 27  
 
 28  
 import org.apache.commons.io.IOUtils;
 29  
 import org.apache.maven.plugin.AbstractMojo;
 30  
 import org.apache.maven.plugin.MojoExecutionException;
 31  
 import org.apache.maven.plugin.MojoFailureException;
 32  
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 33  
 import org.codehaus.plexus.util.xml.pull.MXSerializer;
 34  
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
 35  
 
 36  
 /**
 37  
  * @goal serialize
 38  
  * @phase validate
 39  
  */
 40  0
 public class SerializeMojo
 41  
     extends AbstractMojo
 42  
 {
 43  
 
 44  
     /**
 45  
      * @parameter default-value="${project.build.directory}/serialized.xml"
 46  
      */
 47  
     private File file;
 48  
 
 49  
     public void execute()
 50  
         throws MojoExecutionException, MojoFailureException
 51  
     {
 52  0
         Writer writer = null;
 53  0
         XmlSerializer s = new MXSerializer();
 54  
         try
 55  
         {
 56  0
             file.getParentFile().mkdirs();
 57  0
             writer = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" );
 58  0
             s.setOutput( writer );
 59  
 
 60  0
             Xpp3Dom dom = new Xpp3Dom( "root" );
 61  
 
 62  0
             dom.writeToSerializer( "", s );
 63  
         }
 64  0
         catch ( IOException e )
 65  
         {
 66  0
             throw new MojoExecutionException( e.getMessage(), e );
 67  
         }
 68  
         finally
 69  
         {
 70  0
             IOUtils.closeQuietly( writer );
 71  0
         }
 72  0
     }
 73  
 }