Skip to content

Error of quarkus:dev when the project.build.directory is overridden by a profile #30961

@nghialunatech

Description

@nghialunatech

Describe the bug

In a project I have configured the following profile that overrides the default project build directory with target-api:

    <profile>
      <id>api</id>
      <build>
        <directory>target-api</directory>
      </build>
    </profile>

With that profile, I have no problem compiling / packaging the app (mvn clean package -Papi), the artifacts are found under target-api instead of target

However when launching the quarkus dev mode (mvn clean quarkus:dev -Papi), it failed with an error indicating that the dev mojo still looks for compiled classes under target

Hot reloadable dependency com.example:quarkus_playground:1.0-SNAPSHOT has not been compiled yet (the classes directory /quarkus-project/target/classes does not exist)

Expected behavior

The quarkus:dev mojo should launch normally

Actual behavior

The following error is thrown:

Hot reloadable dependency com.example:quarkus_playground:1.0-SNAPSHOT has not been compiled yet (the classes directory /quarkus-project/target/classes does not exist)

How to Reproduce?

Steps to reproduce:

  1. Init an empty project with the latest version of quarkus (2.16.1.Final as the time of writing)
  2. Add a profile that overrides the build directory (as in the bug description)
  3. Run quarkus:dev with the profile, e.g. mvn quarkus:dev -P<profile>

Output of uname -a or ver

No response

Output of java -version

OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.1.FINAL

Build tool (ie. output of mvnw --version or gradlew --version)

Maven 3.8.4

Additional information

Here is the quick fix I'm applying to get rid of the issue (I'm not sure if it is the right place to patch but it works :D)

Add this line after line 74 of the file below

mp.getOriginalModel().getBuild().setDirectory(mp.getModel().getBuild().getDirectory());

static Map<Path, Model> getProjectMap(MavenSession session) {
final List<MavenProject> allProjects = session.getAllProjects();
if (allProjects == null) {
return Map.of();
}
final Map<Path, Model> projectModels = new HashMap<>(allProjects.size());
for (MavenProject mp : allProjects) {
mp.getOriginalModel().setPomFile(mp.getFile());
projectModels.put(mp.getBasedir().toPath(), mp.getOriginalModel());
}
return projectModels;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions