Coverage Report - org.apache.maven.plugin.assembly.mojos.AbstractDirectoryMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractDirectoryMojo
0%
0/28
0%
0/6
7,5
 
 1  
 package org.apache.maven.plugin.assembly.mojos;
 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 org.apache.maven.plugin.MojoExecutionException;
 23  
 import org.apache.maven.plugin.MojoFailureException;
 24  
 import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
 25  
 import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
 26  
 import org.apache.maven.plugin.assembly.archive.AssemblyArchiver;
 27  
 import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
 28  
 import org.apache.maven.plugin.assembly.io.AssemblyReadException;
 29  
 import org.apache.maven.plugin.assembly.io.AssemblyReader;
 30  
 import org.apache.maven.plugin.assembly.model.Assembly;
 31  
 
 32  
 import java.util.Iterator;
 33  
 import java.util.List;
 34  
 
 35  
 /**
 36  
  * @version $Id: AbstractDirectoryMojo.java 1392520 2012-10-01 19:01:56Z krosenvold $
 37  
  */
 38  
 @Deprecated
 39  0
 public abstract class AbstractDirectoryMojo
 40  
     extends AbstractAssemblyMojo
 41  
 {
 42  
     @Override
 43  
     public void execute()
 44  
         throws MojoExecutionException, MojoFailureException
 45  
     {
 46  0
         final AssemblyReader reader = getAssemblyReader();
 47  
 
 48  
         List<Assembly> assemblies;
 49  
         try
 50  
         {
 51  0
             assemblies = reader.readAssemblies( this );
 52  
         }
 53  0
         catch ( final AssemblyReadException e )
 54  
         {
 55  0
             throw new MojoExecutionException( "Error reading assembly descriptors: " + e.getMessage(), e );
 56  
         }
 57  0
         catch ( final InvalidAssemblerConfigurationException e )
 58  
         {
 59  0
             throw new MojoFailureException( reader, e.getMessage(), "Mojo configuration is invalid: " + e.getMessage() );
 60  0
         }
 61  
 
 62  0
         for ( final Iterator<Assembly> i = assemblies.iterator(); i.hasNext(); )
 63  
         {
 64  0
             final Assembly assembly = i.next();
 65  0
             createDirectory( assembly );
 66  0
         }
 67  0
     }
 68  
 
 69  
     private void createDirectory( final Assembly assembly )
 70  
         throws MojoExecutionException, MojoFailureException
 71  
     {
 72  0
         final AssemblyArchiver archiver = getAssemblyArchiver();
 73  
 
 74  0
         String fullName = getFinalName();
 75  
 
 76  0
         if ( appendAssemblyId )
 77  
         {
 78  0
             fullName = fullName + "-" + assembly.getId();
 79  
         }
 80  0
         else if ( getClassifier() != null )
 81  
         {
 82  0
             fullName = fullName + "-" + getClassifier();
 83  
         }
 84  
 
 85  
         try
 86  
         {
 87  0
             archiver.createArchive( assembly, fullName, "dir", this, isRecompressZippedFiles());
 88  
         }
 89  0
         catch ( final ArchiveCreationException e )
 90  
         {
 91  0
             throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
 92  
         }
 93  0
         catch ( final AssemblyFormattingException e )
 94  
         {
 95  0
             throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
 96  
         }
 97  0
         catch ( final InvalidAssemblerConfigurationException e )
 98  
         {
 99  0
             throw new MojoFailureException( assembly, "Assembly is incorrectly configured: " + assembly.getId(),
 100  
                                             "Assembly: " + assembly.getId() + " is not configured correctly: "
 101  
                                                             + e.getMessage() );
 102  0
         }
 103  0
     }
 104  
 
 105  
 }