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

io.quarkus.container.util.PathsUtil Maven / Gradle / Ivy

package io.quarkus.container.util;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.AbstractMap;

public final class PathsUtil {

    private PathsUtil() {
    }

    /**
     * Return a Map.Entry (which is used as a Tuple) containing the main sources root as the key
     * and the project root as the value
     */
    public static AbstractMap.SimpleEntry findMainSourcesRoot(Path outputDirectory) {
        Path currentPath = outputDirectory;
        do {
            Path toCheck = currentPath.resolve(Paths.get("src", "main"));
            if (toCheck.toFile().exists()) {
                return new AbstractMap.SimpleEntry<>(toCheck, currentPath);
            }
            if (currentPath.getParent() != null && Files.exists(currentPath.getParent())) {
                currentPath = currentPath.getParent();
            } else {
                return null;
            }
        } while (true);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy