quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.85k stars 2.7k forks source link

Introduce a UserProjectRootBuildItem #44013

Open ia3andy opened 1 month ago

ia3andy commented 1 month ago

Description

This code is copied in 3 or 4 extensions already, having a build-item would be best :)


    private static Path findProjectRoot(Path outputDirectory) {
        Path currentPath = outputDirectory;
        do {
            if (Files.exists(currentPath.resolve(Paths.get("src", "main")))
                    || Files.exists(currentPath.resolve(Paths.get("config", "application.properties")))
                    || Files.exists(currentPath.resolve(Paths.get("config", "application.yaml")))
                    || Files.exists(currentPath.resolve(Paths.get("config", "application.yml")))) {
                return currentPath.normalize();
            }
            if (currentPath.getParent() != null && Files.exists(currentPath.getParent())) {
                currentPath = currentPath.getParent();
            } else {
                return null;
            }
        } while (true);
    }

Implementation ideas

No response

mcruzdev commented 1 month ago

I would like to care about it @ia3andy :) Could you say what extensions are using (besides roq of course)?

ia3andy commented 1 month ago

I would like to care about it @ia3andy :) Could you say what extensions are using (besides roq of course)?

Quinoa and soon the Web Bundler, I believe there are others as I found this code in some extension in the past so do a search in Quarkus core and Quarkiverse to notify developers when it's done

ia3andy commented 1 month ago

We might also want to move PathUtils from Roq to Quarkus core (runtime)

melloware commented 1 month ago

I am pretty sure I am using it in Quarkus JasperReports also or something similar.

melloware commented 1 month ago

Jasper: https://github.com/quarkiverse/quarkus-jasperreports/blob/f43e220bbb2eaa6e4b7204decc51f6eeb18aa38b/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java#L661-L676