1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.codehaus.plexus.archiver.diags;
20
21 import javax.annotation.Nonnull;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.nio.charset.Charset;
26
27 import org.codehaus.plexus.archiver.ArchivedFileSet;
28 import org.codehaus.plexus.archiver.Archiver;
29 import org.codehaus.plexus.archiver.ArchiverException;
30 import org.codehaus.plexus.archiver.FileSet;
31 import org.codehaus.plexus.components.io.resources.PlexusIoResource;
32 import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
33 import org.slf4j.Logger;
34
35
36
37
38
39 public class DryRunArchiver extends DelgatingArchiver {
40
41 private final Logger logger;
42
43 public DryRunArchiver(final Archiver target, final Logger logger) {
44 super(target);
45 this.logger = logger;
46 }
47
48
49
50
51 @Override
52 public void addArchivedFileSet(
53 final @Nonnull File archiveFile, final String prefix, final String[] includes, final String[] excludes) {
54 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
55 }
56
57 private void debug(final String message) {
58 if ((logger != null) && logger.isDebugEnabled()) {
59 logger.debug(message);
60 }
61 }
62
63
64
65
66 @Override
67 @Deprecated
68 public void addArchivedFileSet(final @Nonnull File archiveFile, final String prefix) throws ArchiverException {
69 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
70 }
71
72
73
74
75 @Override
76 public void addArchivedFileSet(final File archiveFile, final String[] includes, final String[] excludes)
77 throws ArchiverException {
78 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
79 }
80
81
82
83
84 @Override
85 public void addArchivedFileSet(final @Nonnull File archiveFile) throws ArchiverException {
86 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
87 }
88
89
90
91
92 @Override
93 public void addDirectory(
94 final @Nonnull File directory, final String prefix, final String[] includes, final String[] excludes)
95 throws ArchiverException {
96 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
97 }
98
99
100
101
102 @Override
103 public void addSymlink(String symlinkName, String symlinkDestination) throws ArchiverException {
104 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
105 }
106
107
108
109
110 @Override
111 public void addSymlink(String symlinkName, int permissions, String symlinkDestination) throws ArchiverException {
112 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
113 }
114
115
116
117
118 @Override
119 @Deprecated
120 public void addDirectory(final @Nonnull File directory, final String prefix) throws ArchiverException {
121 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
122 }
123
124
125
126
127 @Override
128 @Deprecated
129 public void addDirectory(final @Nonnull File directory, final String[] includes, final String[] excludes)
130 throws ArchiverException {
131 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
132 }
133
134
135
136
137 @Override
138 @Deprecated
139 public void addDirectory(final @Nonnull File directory) throws ArchiverException {
140 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
141 }
142
143
144
145
146 @Override
147 public void addFile(final @Nonnull File inputFile, final @Nonnull String destFileName, final int permissions)
148 throws ArchiverException {
149 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
150 }
151
152
153
154
155 @Override
156 public void addFile(final @Nonnull File inputFile, final @Nonnull String destFileName) throws ArchiverException {
157 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
158 }
159
160
161
162
163 @Override
164 public void createArchive() throws ArchiverException, IOException {
165 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
166 }
167
168
169
170
171 @Override
172 public void setDotFileDirectory(final File dotFileDirectory) {
173 throw new UnsupportedOperationException("Undocumented feature of plexus-archiver; this is not yet supported.");
174 }
175
176
177
178
179 @Override
180 public void addArchivedFileSet(final ArchivedFileSet fileSet) throws ArchiverException {
181
182 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
183 }
184
185 @Override
186 public void addArchivedFileSet(ArchivedFileSet fileSet, Charset charset) throws ArchiverException {
187 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
188 }
189
190
191
192
193 @Override
194 public void addFileSet(final @Nonnull FileSet fileSet) throws ArchiverException {
195 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
196 }
197
198 @Override
199 public void addResource(PlexusIoResource resource, String destFileName, int permissions) throws ArchiverException {
200 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
201 }
202
203 @Override
204 public void addResources(PlexusIoResourceCollection resources) throws ArchiverException {
205 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
206 }
207
208 private String getMethodName() {
209 final NullPointerException npe = new NullPointerException();
210 final StackTraceElement[] trace = npe.getStackTrace();
211 final StackTraceElement methodElement = trace[1];
212 return methodElement.getMethodName() + " (archiver line: " + methodElement.getLineNumber() + ")";
213 }
214 }