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

dev.mccue.tools.javac.Javac Maven / Gradle / Ivy

There is a newer version: 2024.09.03
Show newest version
package dev.mccue.tools.javac;

import dev.mccue.tools.AbstractToolRunner;
import dev.mccue.tools.ExitStatusException;
import dev.mccue.tools.Tool;

import java.util.function.Consumer;
import java.util.spi.ToolProvider;

public final class Javac extends AbstractToolRunner {
    private Javac(Tool tool, JavacArguments arguments) {
        super(tool, arguments);
    }

    private Javac() {
        super(
                Tool.ofToolProvider(ToolProvider.findFirst("javac").orElseThrow()),
                new JavacArguments()
        );
    }

    public static Javac runner() {
        return new Javac();
    }

    public static Javac runner(Tool tool) {
        return new Javac(tool, new JavacArguments());
    }

    public static Javac runner(Tool tool, JavacArguments arguments) {
        return new Javac(tool, arguments);
    }

    public static Javac runner(JavacArguments arguments) {
        return new Javac(
                Tool.ofToolProvider(ToolProvider.findFirst("javac").orElseThrow()),
                arguments
        );
    }

    public static Javac runner(Consumer consumer) {
        var javac = runner();
        consumer.accept(javac.arguments);
        return javac;
    }

    public static Javac runner(Tool tool, Consumer consumer) {
        var javac = runner(tool);
        consumer.accept(javac.arguments);
        return javac;
    }

    public static void run(Tool tool, JavacArguments arguments) throws ExitStatusException {
        new Javac(tool, arguments).run();
    }

    public static void run(JavacArguments arguments) throws ExitStatusException {
        runner(arguments).run();
    }

    public static void run(Tool tool, Consumer consumer) throws ExitStatusException {
        runner(tool, consumer).run();
    }

    public static void run(Consumer consumer) throws ExitStatusException {
        runner(consumer).run();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy