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

dev.gradleplugins.runnerkit.providers.WorkingDirectoryProvider Maven / Gradle / Ivy

There is a newer version: 0.0.148
Show newest version
package dev.gradleplugins.runnerkit.providers;

import dev.gradleplugins.fixtures.file.FileSystemUtils;
import dev.gradleplugins.runnerkit.GradleExecutionContext;

import java.io.File;
import java.util.function.Function;
import java.util.function.Supplier;

public final class WorkingDirectoryProvider extends AbstractGradleExecutionProvider {
    public static WorkingDirectoryProvider unset() {
        return noValue(WorkingDirectoryProvider.class);
    }

    public static WorkingDirectoryProvider of(File workingDirectory) {
        return fixed(WorkingDirectoryProvider.class, workingDirectory);
    }

    public static WorkingDirectoryProvider of(Supplier workingDirectorySupplier) {
        return supplied(WorkingDirectoryProvider.class, workingDirectorySupplier);
    }

    public static Function relativeToWorkingDirectory(String path) {
        return context -> {
            ((GradleExecutionProviderInternal) context.getWorkingDirectory()).calculateValue(context);
            return FileSystemUtils.file(context.getWorkingDirectory().get(), path);
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy