Coverage Report - org.apache.maven.plugin.eclipse.writers.rad.RadWebsiteConfigWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
RadWebsiteConfigWriter
0%
0/16
0%
0/2
2,5
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  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,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.maven.plugin.eclipse.writers.rad;
 20  
 
 21  
 import java.io.File;
 22  
 import java.io.FileOutputStream;
 23  
 import java.io.IOException;
 24  
 import java.io.OutputStreamWriter;
 25  
 import java.io.Writer;
 26  
 
 27  
 import org.apache.maven.artifact.repository.ArtifactRepository;
 28  
 import org.apache.maven.plugin.MojoExecutionException;
 29  
 import org.apache.maven.plugin.eclipse.Constants;
 30  
 import org.apache.maven.plugin.eclipse.EclipseSourceDir;
 31  
 import org.apache.maven.plugin.eclipse.Messages;
 32  
 import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter;
 33  
 import org.apache.maven.plugin.eclipse.writers.wtp.AbstractWtpResourceWriter;
 34  
 import org.codehaus.plexus.util.IOUtil;
 35  
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 36  
 import org.codehaus.plexus.util.xml.XMLWriter;
 37  
 
 38  
 /**
 39  
  * Creates a .settings folder for Eclipse WTP 1.x release and writes out the configuration under it.
 40  
  * 
 41  
  * @author <a href="mailto:nir@cfc.at">Richard van Nieuwenhoven</a>
 42  
  */
 43  0
 public class RadWebsiteConfigWriter
 44  
     extends AbstractEclipseWriter
 45  
 {
 46  
 
 47  
     private static final String WEBSITE_CONFIG_FILENAME = ".website-config";
 48  
 
 49  
     private static final String WEBSITE_CONFIG_STRUCTURE = "structure";
 50  
 
 51  
     private static final String WEBSITE_CONFIG_VERSION = "version";
 52  
 
 53  
     private static final String WEBSITE_CONFIG_WEBSITE = "website";
 54  
 
 55  
     /**
 56  
      * write the website-config file for RAD6 if needed.
 57  
      * 
 58  
      * @see AbstractWtpResourceWriter#write(EclipseSourceDir[], ArtifactRepository, File)
 59  
      * @param sourceDirs all eclipse source directorys
 60  
      * @param localRepository the local reposetory
 61  
      * @param buildOutputDirectory build output directory (target)
 62  
      * @throws MojoExecutionException when writing the config files was not possible
 63  
      */
 64  
     public void write()
 65  
         throws MojoExecutionException
 66  
     {
 67  
         Writer w;
 68  0
         if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( config.getPackaging() ) )
 69  
         {
 70  
             try
 71  
             {
 72  0
                 w =
 73  
                     new OutputStreamWriter( new FileOutputStream( new File( config.getEclipseProjectDirectory(),
 74  
                                                                             WEBSITE_CONFIG_FILENAME ) ), "UTF-8" );
 75  
             }
 76  0
             catch ( IOException ex )
 77  
             {
 78  0
                 throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
 79  0
             }
 80  0
             XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
 81  0
             writeModuleTypeFacetCore( writer );
 82  0
             IOUtil.close( w );
 83  
         }
 84  0
     }
 85  
 
 86  
     /**
 87  
      * write the website-config file.
 88  
      * 
 89  
      * @param writer wher to write to
 90  
      */
 91  
     private void writeModuleTypeFacetCore( XMLWriter writer )
 92  
     {
 93  0
         writer.startElement( WEBSITE_CONFIG_WEBSITE );
 94  0
         writer.addAttribute( WEBSITE_CONFIG_VERSION, "600" );
 95  0
         writer.startElement( WEBSITE_CONFIG_STRUCTURE );
 96  0
         writer.endElement();
 97  0
         writer.endElement();
 98  0
     }
 99  
 }