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

at.yawk.valda.Art Maven / Gradle / Ivy

package at.yawk.valda;

import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import lombok.experimental.UtilityClass;
import org.testng.SkipException;
import org.zeroturnaround.exec.ProcessExecutor;
import org.zeroturnaround.exec.ProcessResult;

/**
 * @author yawkat
 */
@UtilityClass
public final class Art {
    private static final String PATH = System.getenv("ART_RUNTIME");

    public static boolean available() {
        return PATH != null;
    }

    public static ProcessResult run(Path dex, String mainClass, String... args)
            throws InterruptedException, TimeoutException, IOException {
        if (!available()) { throw new SkipException("ART_RUNTIME env variable not set"); }
        return new ProcessExecutor()
                .command(ImmutableList.builder()
                                 .add(PATH.split(" "))
                                 .add("-cp", dex.toString(), mainClass)
                                 .add(args)
                                 .build())
                .exitValueAny()
                .readOutput(true)
                .timeout(20, TimeUnit.SECONDS)
                .execute();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy