|
13 | 13 | import java.nio.charset.StandardCharsets; |
14 | 14 | import java.util.ArrayList; |
15 | 15 | import java.util.Arrays; |
| 16 | +import java.util.Collection; |
16 | 17 | import java.util.Collections; |
17 | 18 | import java.util.List; |
| 19 | +import java.util.concurrent.atomic.AtomicReference; |
18 | 20 | import java.util.stream.Collectors; |
19 | 21 | import javax.inject.Inject; |
20 | 22 | import org.apache.commons.io.FilenameUtils; |
@@ -140,6 +142,21 @@ public class JcpTask extends DefaultTask { |
140 | 142 | */ |
141 | 143 | private final Property<Boolean> dontOverwriteSameContent; |
142 | 144 |
|
| 145 | + /** |
| 146 | + * Collection of all files which have been generated during preprocessing. |
| 147 | + */ |
| 148 | + private final ListProperty<File> outcomingFiles; |
| 149 | + |
| 150 | + /** |
| 151 | + * Collection of all files which have been used for preprocessing (including configuration files) |
| 152 | + */ |
| 153 | + private final ListProperty<File> incomingFiles; |
| 154 | + |
| 155 | + private final AtomicReference<Iterable<File>> outcomingFilesIterator = |
| 156 | + new AtomicReference<>(Collections.emptyList()); |
| 157 | + private final AtomicReference<Iterable<File>> incomingFilesIterator = |
| 158 | + new AtomicReference<>(Collections.emptyList()); |
| 159 | + |
143 | 160 | @Inject |
144 | 161 | public JcpTask(final ObjectFactory factory) { |
145 | 162 | this.allowWhitespaces = factory.property(Boolean.class).convention(false); |
@@ -172,6 +189,20 @@ public JcpTask(final ObjectFactory factory) { |
172 | 189 | this.baseDir = factory.property(File.class).convention(this.getProject().getProjectDir()); |
173 | 190 | this.target = factory.property(File.class).convention(new File(this.getProject().getBuildDir(), |
174 | 191 | "java-comment-preprocessor" + File.separatorChar + this.getTaskIdentity().name)); |
| 192 | + |
| 193 | + this.incomingFiles = factory.listProperty(File.class) |
| 194 | + .value(() -> this.incomingFilesIterator.get().iterator()); |
| 195 | + |
| 196 | + this.outcomingFiles = factory.listProperty(File.class) |
| 197 | + .value(() -> this.outcomingFilesIterator.get().iterator()); |
| 198 | + } |
| 199 | + |
| 200 | + public ListProperty<File> getOutcomingFiles() { |
| 201 | + return this.outcomingFiles; |
| 202 | + } |
| 203 | + |
| 204 | + public ListProperty<File> getIncomingFiles() { |
| 205 | + return this.incomingFiles; |
175 | 206 | } |
176 | 207 |
|
177 | 208 | @Override |
@@ -394,5 +425,12 @@ public void warning(final String message) { |
394 | 425 |
|
395 | 426 | logger.debug("Preprocessing starting"); |
396 | 427 | preprocessor.execute(); |
| 428 | + |
| 429 | + final Collection<File> foundAllGeneratedFiles = |
| 430 | + preprocessor.getContext().findAllGeneratedFiles(); |
| 431 | + final Collection<File> foundAllInputFiles = preprocessor.getContext().findAllInputFiles(); |
| 432 | + |
| 433 | + this.outcomingFilesIterator.set(foundAllGeneratedFiles); |
| 434 | + this.incomingFilesIterator.set(foundAllInputFiles); |
397 | 435 | } |
398 | 436 | } |
0 commit comments