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 public void addArchivedFileSet(final @Nonnull File archiveFile, final String prefix) throws ArchiverException {
68 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
69 }
70
71
72
73
74 @Override
75 public void addArchivedFileSet(final File archiveFile, final String[] includes, final String[] excludes)
76 throws ArchiverException {
77 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
78 }
79
80
81
82
83 @Override
84 public void addArchivedFileSet(final @Nonnull File archiveFile) throws ArchiverException {
85 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
86 }
87
88
89
90
91 @Override
92 public void addDirectory(
93 final @Nonnull File directory, final String prefix, final String[] includes, final String[] excludes)
94 throws ArchiverException {
95 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
96 }
97
98
99
100
101 @Override
102 public void addSymlink(String symlinkName, String symlinkDestination) throws ArchiverException {
103 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
104 }
105
106
107
108
109 @Override
110 public void addSymlink(String symlinkName, int permissions, String symlinkDestination) throws ArchiverException {
111 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
112 }
113
114
115
116
117 @Override
118 public void addDirectory(final @Nonnull File directory, final String prefix) throws ArchiverException {
119 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
120 }
121
122
123
124
125 @Override
126 public void addDirectory(final @Nonnull File directory, final String[] includes, final String[] excludes)
127 throws ArchiverException {
128 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
129 }
130
131
132
133
134 @Override
135 public void addDirectory(final @Nonnull File directory) throws ArchiverException {
136 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
137 }
138
139
140
141
142 @Override
143 public void addFile(final @Nonnull File inputFile, final @Nonnull String destFileName, final int permissions)
144 throws ArchiverException {
145 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
146 }
147
148
149
150
151 @Override
152 public void addFile(final @Nonnull File inputFile, final @Nonnull String destFileName) throws ArchiverException {
153 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
154 }
155
156
157
158
159 @Override
160 public void createArchive() throws ArchiverException, IOException {
161 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
162 }
163
164
165
166
167 @Override
168 public void setDotFileDirectory(final File dotFileDirectory) {
169 throw new UnsupportedOperationException("Undocumented feature of plexus-archiver; this is not yet supported.");
170 }
171
172
173
174
175 @Override
176 public void addArchivedFileSet(final ArchivedFileSet fileSet) throws ArchiverException {
177
178 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
179 }
180
181 @Override
182 public void addArchivedFileSet(ArchivedFileSet fileSet, Charset charset) throws ArchiverException {
183 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
184 }
185
186
187
188
189 @Override
190 public void addFileSet(final @Nonnull FileSet fileSet) throws ArchiverException {
191 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
192 }
193
194 @Override
195 public void addResource(PlexusIoResource resource, String destFileName, int permissions) throws ArchiverException {
196 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
197 }
198
199 @Override
200 public void addResources(PlexusIoResourceCollection resources) throws ArchiverException {
201 debug("DRY RUN: Skipping delegated call to: " + getMethodName());
202 }
203
204 private String getMethodName() {
205 final NullPointerException npe = new NullPointerException();
206 final StackTraceElement[] trace = npe.getStackTrace();
207 final StackTraceElement methodElement = trace[1];
208 return methodElement.getMethodName() + " (archiver line: " + methodElement.getLineNumber() + ")";
209 }
210 }