Skip to content

Commit

Permalink
skip lombok on empty projects
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed May 28, 2018
1 parent 7d7daa6 commit dbc2c6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.Getter;
import lombok.Setter;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.*;

import java.io.File;
import java.util.stream.Collectors;
Expand All @@ -19,16 +17,25 @@ public class Delombok extends JavaExec {
@Nested
private DelombokOptions options = new DelombokOptions();

@Internal
private final ConfigurableFileCollection input = getProject().files();

@InputFiles
private FileCollection input;
@SkipWhenEmpty
protected FileCollection getNonEmptySourceRoots() {
return getProject().files(
getInput().getFiles().stream()
.filter(File::isDirectory)
.collect(Collectors.toList())
);
}

@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT", justification = "setMain() and args()")
public Delombok() {
setMain("lombok.launch.Main");
args("delombok");
getArgumentProviders().add(getOptions());
getArgumentProviders().add(() -> getInput().getFiles().stream()
.filter(File::isDirectory)
getArgumentProviders().add(() -> getNonEmptySourceRoots().getFiles().stream()
.map(File::getPath)
.collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void configureJavaPluginDefaults() {
delombok.getOptions().setEncoding(compileJava.getOptions().getEncoding());
delombok.getOptions().setClasspath(compileJava.getClasspath());
compileJava.getInputs().file(generateLombokConfig.getOutputFile());
delombok.setInput(sourceSet.getAllJava().getSourceDirectories());
delombok.getInput().from(sourceSet.getAllJava().getSourceDirectories());
});

delombok.getOptions().setTarget(new File(delombokBaseDir, sourceSet.getName()));
Expand Down

0 comments on commit dbc2c6e

Please sign in to comment.