All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.freefair.gradle.plugins.plantuml.PlantumlAction Maven / Gradle / Ivy

package io.freefair.gradle.plugins.plantuml;

import lombok.SneakyThrows;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SourceFileReader;
import org.gradle.workers.WorkAction;

/**
 * Gradle {@link WorkAction} for PlantUML {@link SourceFileReader}.
 *
 * @author Lars Grefer
 * @see SourceFileReader
 */
public abstract class PlantumlAction implements WorkAction {

    @SneakyThrows
    @Override
    public void execute() {

        FileFormat fileFormat = getParameters().getFileFormat()
                .map(String::toUpperCase)
                .map(FileFormat::valueOf)
                .getOrElse(FileFormat.PNG);

        FileFormatOption fileFormatOption = new FileFormatOption(fileFormat, getParameters().getWithMetadata().get());

        SourceFileReader sourceFileReader = new SourceFileReader(
                getParameters().getInputFile().getAsFile().get(),
                getParameters().getOutputDirectory().getAsFile().get(),
                fileFormatOption
        );

        sourceFileReader.getGeneratedImages();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy