View Javadoc
1   /*
2    * Copyright 2014 The Codehaus Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.codehaus.plexus.archiver.diags;
17  
18  import javax.annotation.Nonnull;
19  
20  import java.io.File;
21  import java.io.IOException;
22  import java.nio.charset.Charset;
23  import java.nio.file.attribute.FileTime;
24  import java.util.Collections;
25  import java.util.Comparator;
26  import java.util.Date;
27  import java.util.Map;
28  
29  import org.codehaus.plexus.archiver.ArchiveEntry;
30  import org.codehaus.plexus.archiver.ArchivedFileSet;
31  import org.codehaus.plexus.archiver.Archiver;
32  import org.codehaus.plexus.archiver.ArchiverException;
33  import org.codehaus.plexus.archiver.FileSet;
34  import org.codehaus.plexus.archiver.ResourceIterator;
35  import org.codehaus.plexus.components.io.resources.PlexusIoResource;
36  import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
37  
38  /**
39   * An archiver that does nothing. Really.
40   */
41  @SuppressWarnings("UnusedDeclaration")
42  public class NoOpArchiver implements Archiver {
43  
44      boolean useJvmChmod;
45  
46      private boolean ignorePermissions;
47  
48      @Override
49      public void createArchive() throws ArchiverException, IOException {}
50  
51      @Override
52      public void addDirectory(@Nonnull File directory) throws ArchiverException {}
53  
54      @Override
55      public void addDirectory(@Nonnull File directory, String prefix) throws ArchiverException {}
56  
57      @Override
58      public void addDirectory(@Nonnull File directory, String[] includes, String[] excludes) throws ArchiverException {}
59  
60      @Override
61      public void addDirectory(@Nonnull File directory, String prefix, String[] includes, String[] excludes)
62              throws ArchiverException {}
63  
64      @Override
65      public void addFileSet(@Nonnull FileSet fileSet) throws ArchiverException {}
66  
67      @Override
68      public void addSymlink(String symlinkName, String symlinkDestination) throws ArchiverException {}
69  
70      @Override
71      public void addSymlink(String symlinkName, int permissions, String symlinkDestination) throws ArchiverException {}
72  
73      @Override
74      public void addFile(@Nonnull File inputFile, @Nonnull String destFileName) throws ArchiverException {}
75  
76      @Override
77      public void addFile(@Nonnull File inputFile, @Nonnull String destFileName, int permissions)
78              throws ArchiverException {}
79  
80      @Override
81      public void addArchivedFileSet(@Nonnull File archiveFile) throws ArchiverException {}
82  
83      @Override
84      public void addArchivedFileSet(@Nonnull File archiveFile, String prefix) throws ArchiverException {}
85  
86      @Override
87      public void addArchivedFileSet(File archiveFile, String[] includes, String[] excludes) throws ArchiverException {}
88  
89      @Override
90      public void addArchivedFileSet(@Nonnull File archiveFile, String prefix, String[] includes, String[] excludes)
91              throws ArchiverException {}
92  
93      @Override
94      public void addArchivedFileSet(ArchivedFileSet fileSet) throws ArchiverException {}
95  
96      @Override
97      public void addArchivedFileSet(ArchivedFileSet fileSet, Charset charset) throws ArchiverException {}
98  
99      @Override
100     public void addResource(PlexusIoResource resource, String destFileName, int permissions) throws ArchiverException {}
101 
102     @Override
103     public void addResources(PlexusIoResourceCollection resources) throws ArchiverException {}
104 
105     @Override
106     public File getDestFile() {
107         return null;
108     }
109 
110     @Override
111     public void setDestFile(File destFile) {}
112 
113     @Override
114     public void setFileMode(int mode) {}
115 
116     @Override
117     public int getFileMode() {
118         return 0;
119     }
120 
121     @Override
122     public int getOverrideFileMode() {
123         return 0;
124     }
125 
126     @Override
127     public void setDefaultFileMode(int mode) {}
128 
129     @Override
130     public int getDefaultFileMode() {
131         return 0;
132     }
133 
134     @Override
135     public void setDirectoryMode(int mode) {}
136 
137     @Override
138     public int getDirectoryMode() {
139         return 0;
140     }
141 
142     @Override
143     public int getOverrideDirectoryMode() {
144         return 0;
145     }
146 
147     @Override
148     public void setDefaultDirectoryMode(int mode) {}
149 
150     @Override
151     public int getDefaultDirectoryMode() {
152         return 0;
153     }
154 
155     @Override
156     public boolean getIncludeEmptyDirs() {
157         return false;
158     }
159 
160     @Override
161     public void setIncludeEmptyDirs(boolean includeEmptyDirs) {}
162 
163     @Override
164     public void setDotFileDirectory(File dotFileDirectory) {}
165 
166     @Nonnull
167     @Override
168     public ResourceIterator getResources() throws ArchiverException {
169         return new ResourceIterator() {
170 
171             @Override
172             public boolean hasNext() {
173                 return false;
174             }
175 
176             @Override
177             public ArchiveEntry next() {
178                 return null;
179             }
180 
181             @Override
182             public void remove() {
183                 throw new UnsupportedOperationException("remove");
184             }
185         };
186     }
187 
188     @Override
189     public Map<String, ArchiveEntry> getFiles() {
190         return Collections.emptyMap();
191     }
192 
193     @Override
194     public boolean isForced() {
195         return false;
196     }
197 
198     @Override
199     public void setForced(boolean forced) {}
200 
201     @Override
202     public boolean isSupportingForced() {
203         return false;
204     }
205 
206     @Override
207     public String getDuplicateBehavior() {
208         return null;
209     }
210 
211     @Override
212     public void setDuplicateBehavior(String duplicate) {}
213 
214     @Override
215     public void setUseJvmChmod(boolean useJvmChmod) {
216         this.useJvmChmod = useJvmChmod;
217     }
218 
219     @Override
220     public boolean isUseJvmChmod() {
221         return useJvmChmod;
222     }
223 
224     @Override
225     public boolean isIgnorePermissions() {
226         return ignorePermissions;
227     }
228 
229     @Override
230     public void setIgnorePermissions(boolean ignorePermissions) {
231         this.ignorePermissions = ignorePermissions;
232     }
233 
234     /**
235      * @deprecated Use {@link #setLastModifiedTime(FileTime)} instead.
236      */
237     @Override
238     @Deprecated
239     public void setLastModifiedDate(final Date lastModifiedDate) {}
240 
241     /**
242      * @deprecated Use {@link #getLastModifiedTime()} instead.
243      */
244     @Override
245     @Deprecated
246     public Date getLastModifiedDate() {
247         return null;
248     }
249 
250     @Override
251     public void setLastModifiedTime(final FileTime lastModifiedTime) {}
252 
253     @Override
254     public FileTime getLastModifiedTime() {
255         return null;
256     }
257 
258     @Override
259     public void setFilenameComparator(final Comparator<String> filenameComparator) {}
260 
261     @Override
262     public void setOverrideUid(int uid) {}
263 
264     @Override
265     public void setOverrideUserName(String userName) {}
266 
267     @Override
268     public int getOverrideUid() {
269         return 0;
270     }
271 
272     @Override
273     public String getOverrideUserName() {
274         return null;
275     }
276 
277     @Override
278     public void setOverrideGid(int gid) {}
279 
280     @Override
281     public void setOverrideGroupName(String groupName) {}
282 
283     @Override
284     public int getOverrideGid() {
285         return 0;
286     }
287 
288     @Override
289     public String getOverrideGroupName() {
290         return null;
291     }
292 
293     @Override
294     public void setUmask(int umask) {}
295 
296     @Override
297     public int getUmask() {
298         return 0;
299     }
300 
301     /**
302      * @deprecated Use {@link #configureReproducibleBuild(FileTime)} instead.
303      */
304     @Override
305     @Deprecated
306     public void configureReproducible(Date lastModifiedDate) {}
307 
308     @Override
309     public void configureReproducibleBuild(FileTime lastModifiedTime) {}
310 }