Coverage Report - org.apache.maven.plugins.site.SiteStageMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
SiteStageMojo
0%
0/16
0%
0/6
0
 
 1  
 package org.apache.maven.plugins.site;
 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  
 
 24  
 import org.apache.maven.plugin.MojoExecutionException;
 25  
 
 26  
 /**
 27  
  * Generates a site in a local staging or mock directory based on the site URL
 28  
  * specified in the <code>&lt;distributionManagement&gt;</code> section of the
 29  
  * POM.
 30  
  * <p>
 31  
  * It can be used to test that links between module sites in a multi module
 32  
  * build works.
 33  
  * </p>
 34  
  *
 35  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
 36  
  * @version $Id: org.apache.maven.plugins.site.SiteStageMojo.html 816558 2012-05-08 12:00:46Z hboutemy $
 37  
  * @goal stage
 38  
  * @requiresDependencyResolution test
 39  
  */
 40  0
 public class SiteStageMojo
 41  
     extends AbstractDeployMojo
 42  
 {
 43  
     /**
 44  
      * Staging directory location. This needs to be an absolute path, like
 45  
      * <code>C:\stagingArea\myProject\</code> on Windows or
 46  
      * <code>/stagingArea/myProject/</code> on Unix.
 47  
      * If this is not specified, the site will be staged in ${project.build.directory}/staging.
 48  
      *
 49  
      * @parameter expression="${stagingDirectory}"
 50  
      */
 51  
     private File stagingDirectory;
 52  
 
 53  
     @Override
 54  
     protected String getDeployRepositoryID()
 55  
         throws MojoExecutionException
 56  
     {
 57  0
         return "stagingLocal";
 58  
     }
 59  
 
 60  
     @Override
 61  
     protected String getDeployRepositoryURL()
 62  
         throws MojoExecutionException
 63  
     {
 64  0
         final String stageDir = ( stagingDirectory == null ) ? null : stagingDirectory.getAbsolutePath();
 65  0
         final String outputDir = getStagingDirectory( stageDir );
 66  
 
 67  0
         getLog().info( "Using this base directory for staging: " + outputDir );
 68  
 
 69  0
         final File outputDirectory = new File( outputDir );
 70  
         // Safety
 71  0
         if ( !outputDirectory.exists() )
 72  
         {
 73  0
             outputDirectory.mkdirs();
 74  
         }
 75  
 
 76  0
         return "file://" + outputDirectory.getAbsolutePath();
 77  
     }
 78  
 
 79  
     /**
 80  
      * Find the directory where staging will take place.
 81  
      *
 82  
      * @param usersStagingDirectory The staging directory as suggested by the user's configuration
 83  
      *
 84  
      * @return the directory for staging
 85  
      */
 86  
     private String getStagingDirectory( String usersStagingDirectory )
 87  
     {
 88  0
         String topLevelURL = null;
 89  
 
 90  0
         if ( usersStagingDirectory != null )
 91  
         {
 92  
             // the user has specified a stagingDirectory - use it
 93  0
             getLog().debug( "stagingDirectory specified by the user: " + usersStagingDirectory );
 94  0
             topLevelURL = usersStagingDirectory;
 95  
         }
 96  
         else
 97  
         {
 98  
             // The user didn't specify a URL, use the top level target dir
 99  0
             topLevelURL =
 100  
                 getTopLevelBuildDirectory().getAbsolutePath() + "/" + DEFAULT_STAGING_DIRECTORY;
 101  0
             getLog().debug( "stagingDirectory NOT specified, using the top level project: " + topLevelURL );
 102  
         }
 103  
 
 104  
         // Return either
 105  
         //   usersURL
 106  
         // or
 107  
         //   topLevelProjectURL + "staging"
 108  0
         return topLevelURL;
 109  
     }
 110  
 }