Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find angular.json when working directory is not the same as the project directory #812

Closed
xjarvik opened this issue Dec 9, 2024 · 3 comments · Fixed by #813
Closed
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@xjarvik
Copy link
Contributor

xjarvik commented Dec 9, 2024

Describe the bug

When running mvn clean install inside the project directory, Quinoa is able to find the angular.json file without problem.
However, if I try to run mvn clean install -f path/to/project/pom.xml, Quinoa fails during the build phase with the following error:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:3.17.3:build (default) on project example-project: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkiverse.quinoa.deployment.QuinoaProcessor#processBuild threw an exception: java.lang.RuntimeException: Quinoa failed to read the angular.json file. %s
[ERROR]         at io.quarkiverse.quinoa.deployment.framework.override.AngularFramework$1.readAngularJson(AngularFramework.java:59)
[ERROR]         at io.quarkiverse.quinoa.deployment.framework.override.AngularFramework$1.lambda$buildDir$2(AngularFramework.java:33)
[ERROR]         at java.base/java.util.Optional.orElseGet(Optional.java:364)
[ERROR]         at io.quarkiverse.quinoa.deployment.framework.override.AngularFramework$1.buildDir(AngularFramework.java:32)
[ERROR]         at io.quarkiverse.quinoa.deployment.QuinoaProcessor.processBuild(QuinoaProcessor.java:184)
[ERROR]         at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:1583)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:499)
[ERROR] Caused by: java.nio.file.NoSuchFileException: .\angular.json
[ERROR]         at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
[ERROR]         at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
[ERROR]         at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
[ERROR]         at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:234)
[ERROR]         at java.base/java.nio.file.Files.newByteChannel(Files.java:379)
[ERROR]         at java.base/java.nio.file.Files.newByteChannel(Files.java:431)
[ERROR]         at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
[ERROR]         at java.base/java.nio.file.Files.newInputStream(Files.java:159)
[ERROR]         at io.quarkiverse.quinoa.deployment.framework.override.AngularFramework$1.readAngularJson(AngularFramework.java:56)

Our Angular application is located in the same directory as the maven module, hence the .\angular.json path. Our application.properties contains the following line:

quarkus.quinoa.ui-dir=./

After quickly looking at the code, I would think something needs to be adjusted in the AngularFramework.java file.

Quinoa version

2.5.0

Quarkus version

3.17.3

Build / Runtime

Angular

Package Manager

NPM

Steps to reproduce the behavior

  1. Set the quarkus.quinoa.ui-dir as described above.
  2. Run mvn clean install -f path/to/project/pom.xml

Expected behavior

The angular.json file should be found regardless of which directory is the working directory.

@melloware melloware added the bug Something isn't working label Dec 9, 2024
@melloware
Copy link
Contributor

Looks like this issue is here:

private static JsonObject readAngularJson(QuinoaConfig configuration) {
Log.debug("=== Configuration ===" + configuration);
try (JsonReader reader = Json
.createReader(Files.newInputStream(Path.of(configuration.uiDir() + "/" + ANGULAR_JSON_FILE)))) {
return reader.readObject();
} catch (IOException | JsonException e) {
throw new RuntimeException("Quinoa failed to read the angular.json file. %s", e);
}
}

Javadoc say uiDir is /src/main/webui` and its relative to the project root but in this case its ASSUMING the project root is your current dir.

@melloware
Copy link
Contributor

it really need to do something similar to the main path.

final String configuredDir = userConfig.uiDir();
        final ProjectDirs projectDirs = resolveProjectDirs(userConfig, outputTarget);
        if (projectDirs == null) {
            return null;
        }
        final Path packageJson = projectDirs.uiDir.resolve(BUILD_FILE);
        if (!Files.isRegularFile(packageJson)) {
            throw new ConfigurationException("No " + BUILD_FILE + " found in Web UI directory: '" + configuredDir + "'");
        }

@melloware melloware added the good first issue Good for newcomers label Dec 9, 2024
@melloware melloware added this to the 2.5.1 milestone Dec 10, 2024
@melloware
Copy link
Contributor

pushing 2.5.1 to Maven Central now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants