io.freefair.gradle.plugins.lombok.internal.CleanLombokConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lombok-plugin Show documentation
Show all versions of lombok-plugin Show documentation
Collection of Lombok related Gradle plugins
The newest version!
package io.freefair.gradle.plugins.lombok.internal;
import io.freefair.gradle.plugins.lombok.tasks.LombokConfig;
import lombok.SneakyThrows;
import org.gradle.api.Action;
import org.gradle.api.NonNullApi;
import org.gradle.api.Task;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Lars Grefer
*/
@NonNullApi
public class CleanLombokConfig implements Action {
@Override
@SneakyThrows(IOException.class)
public void execute(Task task) {
LombokConfig lombokConfig = (LombokConfig) task;
Path file = lombokConfig.getOutputFile().get().getAsFile().toPath();
List filtered;
try (Stream lines = Files.lines(file)) {
filtered = lines.filter(line -> line.contains("="))
.sorted()
.distinct()
.collect(Collectors.toList());
}
Files.write(file, filtered);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy