View Javadoc

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  public class MavenArchiveConfiguration
36  {
37      private boolean compress = true;
38  
39      private boolean index;
40  
41      private boolean addMavenDescriptor = true;
42  
43      private File manifestFile;
44  
45      private ManifestConfiguration manifest;
46  
47      private Map manifestEntries = new HashMap();
48  
49      private List manifestSections = new ArrayList();
50  
51      /**
52       * @since 2.2
53       */
54      private boolean forced = true;
55  
56      /**
57       * @since 2.3
58       */
59      private File pomPropertiesFile;
60  
61      public boolean isCompress()
62      {
63          return compress;
64      }
65  
66      public boolean isIndex()
67      {
68          return index;
69      }
70  
71      public boolean isAddMavenDescriptor()
72      {
73          return addMavenDescriptor;
74      }
75  
76      public File getManifestFile()
77      {
78          return manifestFile;
79      }
80  
81      public ManifestConfiguration getManifest()
82      {
83          if ( manifest == null )
84          {
85              manifest = new ManifestConfiguration();
86          }
87          return manifest;
88      }
89  
90      public void setCompress( boolean compress )
91      {
92          this.compress = compress;
93      }
94  
95      public void setIndex( boolean index )
96      {
97          this.index = index;
98      }
99  
100     public void setAddMavenDescriptor( boolean addMavenDescriptor )
101     {
102         this.addMavenDescriptor = addMavenDescriptor;
103     }
104 
105     public void setManifestFile( File manifestFile )
106     {
107         this.manifestFile = manifestFile;
108     }
109 
110     public void setManifest( ManifestConfiguration manifest )
111     {
112         this.manifest = manifest;
113     }
114 
115     public void addManifestEntry( Object key, Object value )
116     {
117         manifestEntries.put( key, value );
118     }
119 
120     public void addManifestEntries( Map map )
121     {
122         manifestEntries.putAll( map );
123     }
124 
125     public boolean isManifestEntriesEmpty()
126     {
127         return manifestEntries.isEmpty();
128     }
129 
130     public Map getManifestEntries()
131     {
132         return manifestEntries;
133     }
134     
135     public void setManifestEntries( Map manifestEntries )
136     {
137         this.manifestEntries = manifestEntries;
138     }
139     
140     public void addManifestSection( ManifestSection section ) 
141     {
142         manifestSections.add( section );
143     }
144     
145     public void addManifestSections( List list ) 
146     {
147         manifestSections.addAll( list );
148     }
149     
150     public boolean isManifestSectionsEmpty() 
151     {
152         return manifestSections.isEmpty();
153     }
154     
155     public List getManifestSections() 
156     {
157         return manifestSections;
158     }
159     
160     public void setManifestSections( List manifestSections )
161     {
162         this.manifestSections = manifestSections;
163     }
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         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         this.forced = forced;
205     }
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         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         this.pomPropertiesFile = pomPropertiesFile;
225     }
226 }