Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
raydac committed Aug 26, 2020
1 parent 6cb7e97 commit 13b87da
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions jcp/src/main/java/com/igormaznitsa/jcp/gradle/JcpTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.inject.Inject;
import org.apache.commons.io.FilenameUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.logging.Logger;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputFiles;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskExecutionException;
import org.gradle.execution.commandline.TaskConfigurationException;
Expand Down Expand Up @@ -145,17 +147,12 @@ public class JcpTask extends DefaultTask {
/**
* Collection of all files which have been generated during preprocessing.
*/
private final ListProperty<File> outcomingFiles;
private final ConfigurableFileCollection outcomingFiles;

/**
* Collection of all files which have been used for preprocessing (including configuration files)
*/
private final ListProperty<File> incomingFiles;

private final AtomicReference<Iterable<File>> outcomingFilesIterator =
new AtomicReference<>(Collections.emptyList());
private final AtomicReference<Iterable<File>> incomingFilesIterator =
new AtomicReference<>(Collections.emptyList());
private final ConfigurableFileCollection incomingFiles;

@Inject
public JcpTask(final ObjectFactory factory) {
Expand Down Expand Up @@ -190,18 +187,16 @@ public JcpTask(final ObjectFactory factory) {
this.target = factory.property(File.class).convention(new File(this.getProject().getBuildDir(),
"java-comment-preprocessor" + File.separatorChar + this.getTaskIdentity().name));

this.incomingFiles = factory.listProperty(File.class)
.value(() -> this.incomingFilesIterator.get().iterator());

this.outcomingFiles = factory.listProperty(File.class)
.value(() -> this.outcomingFilesIterator.get().iterator());
this.incomingFiles = factory.fileCollection();
this.outcomingFiles = factory.fileCollection();
}

public ListProperty<File> getOutcomingFiles() {
@OutputFiles
public FileCollection getOutcomingFiles() {
return this.outcomingFiles;
}

public ListProperty<File> getIncomingFiles() {
public FileCollection getIncomingFiles() {
return this.incomingFiles;
}

Expand Down Expand Up @@ -430,7 +425,7 @@ public void warning(final String message) {
preprocessor.getContext().findAllProducedFiles();
final Collection<File> foundAllInputFiles = preprocessor.getContext().findAllInputFiles();

this.outcomingFilesIterator.set(foundAllGeneratedFiles);
this.incomingFilesIterator.set(foundAllInputFiles);
this.outcomingFiles.setFrom(foundAllGeneratedFiles);
this.incomingFiles.setFrom(foundAllInputFiles);
}
}

0 comments on commit 13b87da

Please sign in to comment.