Coverage Report - org.apache.maven.archiver.MavenArchiveConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
MavenArchiveConfiguration
64%
29/45
100%
2/2
1.042
 
 1  
 package org.apache.maven.archiver;
 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.util.ArrayList;
 24  
 import java.util.HashMap;
 25  
 import java.util.List;
 26  
 import java.util.Map;
 27  
 
 28  
 /**
 29  
  * Capture common archive configuration.
 30  
  *
 31  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 32  
  * @version $Id: MavenArchiveConfiguration.java 607639 2007-12-31 01:15:15Z dennisl $
 33  
  * @todo is this general enough to be in Plexus Archiver?
 34  
  */
 35  14
 public class MavenArchiveConfiguration
 36  
 {
 37  14
     private boolean compress = true;
 38  
 
 39  
     private boolean index;
 40  
 
 41  14
     private boolean addMavenDescriptor = true;
 42  
 
 43  
     private File manifestFile;
 44  
 
 45  
     private ManifestConfiguration manifest;
 46  
 
 47  14
     private Map manifestEntries = new HashMap();
 48  
 
 49  14
     private List manifestSections = new ArrayList();
 50  
 
 51  
     /**
 52  
      * @since 2.2
 53  
      */
 54  14
     private boolean forced = true;
 55  
 
 56  
     /**
 57  
      * @since 2.3
 58  
      */
 59  
     private File pomPropertiesFile;
 60  
 
 61  
     public boolean isCompress()
 62  
     {
 63  14
         return compress;
 64  
     }
 65  
 
 66  
     public boolean isIndex()
 67  
     {
 68  14
         return index;
 69  
     }
 70  
 
 71  
     public boolean isAddMavenDescriptor()
 72  
     {
 73  14
         return addMavenDescriptor;
 74  
     }
 75  
 
 76  
     public File getManifestFile()
 77  
     {
 78  14
         return manifestFile;
 79  
     }
 80  
 
 81  
     public ManifestConfiguration getManifest()
 82  
     {
 83  77
         if ( manifest == null )
 84  
         {
 85  13
             manifest = new ManifestConfiguration();
 86  
         }
 87  77
         return manifest;
 88  
     }
 89  
 
 90  
     public void setCompress( boolean compress )
 91  
     {
 92  0
         this.compress = compress;
 93  0
     }
 94  
 
 95  
     public void setIndex( boolean index )
 96  
     {
 97  0
         this.index = index;
 98  0
     }
 99  
 
 100  
     public void setAddMavenDescriptor( boolean addMavenDescriptor )
 101  
     {
 102  0
         this.addMavenDescriptor = addMavenDescriptor;
 103  0
     }
 104  
 
 105  
     public void setManifestFile( File manifestFile )
 106  
     {
 107  0
         this.manifestFile = manifestFile;
 108  0
     }
 109  
 
 110  
     public void setManifest( ManifestConfiguration manifest )
 111  
     {
 112  1
         this.manifest = manifest;
 113  1
     }
 114  
 
 115  
     public void addManifestEntry( Object key, Object value )
 116  
     {
 117  3
         manifestEntries.put( key, value );
 118  3
     }
 119  
 
 120  
     public void addManifestEntries( Map map )
 121  
     {
 122  0
         manifestEntries.putAll( map );
 123  0
     }
 124  
 
 125  
     public boolean isManifestEntriesEmpty()
 126  
     {
 127  21
         return manifestEntries.isEmpty();
 128  
     }
 129  
 
 130  
     public Map getManifestEntries()
 131  
     {
 132  4
         return manifestEntries;
 133  
     }
 134  
     
 135  
     public void setManifestEntries( Map manifestEntries )
 136  
     {
 137  1
         this.manifestEntries = manifestEntries;
 138  1
     }
 139  
     
 140  
     public void addManifestSection( ManifestSection section ) 
 141  
     {
 142  0
         manifestSections.add( section );
 143  0
     }
 144  
     
 145  
     public void addManifestSections( List list ) 
 146  
     {
 147  0
         manifestSections.addAll( list );
 148  0
     }
 149  
     
 150  
     public boolean isManifestSectionsEmpty() 
 151  
     {
 152  21
         return manifestSections.isEmpty();
 153  
     }
 154  
     
 155  
     public List getManifestSections() 
 156  
     {
 157  2
         return manifestSections;
 158  
     }
 159  
     
 160  
     public void setManifestSections( List manifestSections )
 161  
     {
 162  2
         this.manifestSections = manifestSections;
 163  2
     }
 164  
 
 165  
     /**
 166  
      * <p>Returns, whether recreating the archive is forced (default). Setting
 167  
      * this option to false means, that the archiver should compare the
 168  
      * timestamps of included files with the timestamp of the target archive
 169  
      * and rebuild the archive only, if the latter timestamp precedes the
 170  
      * former timestamps. Checking for timestamps will typically offer a
 171  
      * performance gain (in particular, if the following steps in a build
 172  
      * can be suppressed, if an archive isn't recrated) on the cost that
 173  
      * you get inaccurate results from time to time. In particular, removal
 174  
      * of source files won't be detected.</p>
 175  
      * <p>An archiver doesn't necessarily support checks for uptodate. If
 176  
      * so, setting this option to true will simply be ignored.</p>
 177  
      * @return True, if the target archive should always be created; false
 178  
      *   otherwise
 179  
      * @see #setForced(boolean)
 180  
      */
 181  
     public boolean isForced()
 182  
     {
 183  28
         return forced;
 184  
     }
 185  
 
 186  
     /**
 187  
      * <p>Sets, whether recreating the archive is forced (default). Setting
 188  
      * this option to false means, that the archiver should compare the
 189  
      * timestamps of included files with the timestamp of the target archive
 190  
      * and rebuild the archive only, if the latter timestamp precedes the
 191  
      * former timestamps. Checking for timestamps will typically offer a
 192  
      * performance gain (in particular, if the following steps in a build
 193  
      * can be suppressed, if an archive isn't recrated) on the cost that
 194  
      * you get inaccurate results from time to time. In particular, removal
 195  
      * of source files won't be detected.</p>
 196  
      * <p>An archiver doesn't necessarily support checks for uptodate. If
 197  
      * so, setting this option to true will simply be ignored.</p>
 198  
      * @param forced True, if the target archive should always be created; false
 199  
      *   otherwise
 200  
      * @see #isForced()
 201  
      */
 202  
     public void setForced( boolean forced )
 203  
     {
 204  13
         this.forced = forced;
 205  13
     }
 206  
 
 207  
     /**
 208  
      * Returns the location of the "pom.properties" file. 
 209  
      * May be null, in which case a default value is choosen.
 210  
      * @return "pom.properties" location or null.
 211  
      */
 212  
     public File getPomPropertiesFile()
 213  
     {
 214  14
         return pomPropertiesFile;
 215  
     }
 216  
 
 217  
     /**
 218  
      * Sets the location of the "pom.properties" file. 
 219  
      * May be null, in which case a default value is choosen.
 220  
      * @param pomPropertiesFile "pom.properties" location or null.
 221  
      */
 222  
     public void setPomPropertiesFile( File pomPropertiesFile )
 223  
     {
 224  0
         this.pomPropertiesFile = pomPropertiesFile;
 225  0
     }
 226  
 }