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

Annotation processors not run for hot reload of multi module maven project #10833

Closed
Postremus opened this issue Jul 19, 2020 · 6 comments
Closed
Labels

Comments

@Postremus
Copy link
Member

Postremus commented Jul 19, 2020

Describe the bug
I have a multi module maven project with the following structure:

project:

  • web (quarkus project)
  • service (jar packaging)

The service modul has a provided dependency to an annotation processor - hibernate-jpamodelgen to be exact.
During a normal "mvn compile", the annotation processor is run, and the static metamodel gets generated.

Now, i started dev mode.
If I change one of my entity classes, the annotation processor is not run again during hot reload.

As a workaround, I can add all annotation processors to the "web" project. The are then run correctly during dev mode reload.

Alternatively, I could also change the ap to compile scope in the service project, which hints at class path problems.

Expected behavior
Compilation is done with the correct class path of a specific module. All annotation processors of a module are executed.

Actual behavior
Annotation processor is not run on dev mode hot reload.

To Reproduce

  1. Download the reproducer project:
    ap-test.zip
  2. Execute mvn clean compile quarkus:dev on the main project (ap-test), and open http://localhost:8080/hello in your browser
  3. You will see output like [id, ID]. These are all fields currently in the static metamodel of the ExampleEntity class. The metamodel gets generated by the annotion processor.
  4. Open the ExampleEntity class, and add/remove attributes.
  5. Reload the browser page.
  6. No change to the displayed metamodel fields.

If you now restart dev mode (mvn clean compile quarkus:dev), the change in metamodel is shown.

If you change the hibernate-jpamodelgen to compile scope, it is correctly re run on hot reload.

Environment (please complete the following information):

  • Output of uname -a or ver:
    Linux martin 5.4.0-40-generic Arc - request context propagation #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version:
    openjdk 11.0.7 2020-04-14 LTS
    OpenJDK Runtime Environment Zulu11.39+15-CA (build 11.0.7+10-LTS)
    OpenJDK 64-Bit Server VM Zulu11.39+15-CA (build 11.0.7+10-LTS, mixed mode)
  • Quarkus version or git rev:
    1.6.0.Final
  • Build tool (ie. output of mvnw --version or gradlew --version):
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: /home/martin/.sdkman/candidates/maven/current
    Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: /home/martin/.sdkman/candidates/java/11.0.7-zulu
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "5.4.0-40-generic", arch: "amd64", family: "unix"
@Postremus Postremus added the kind/bug Something isn't working label Jul 19, 2020
@Postremus Postremus changed the title Annotation processors not run for hot reload of multi module project Annotation processors not run for hot reload of multi module maven project Jul 19, 2020
@famod
Copy link
Member

famod commented Jul 19, 2020

@Postremus Thanks for reporting this!

Unfortunately, this is a long standing (unresolved) issue: #1502
So I'll have to close this as a duplicate.

@famod famod closed this as completed Jul 19, 2020
@famod famod added the triage/duplicate This issue or pull request already exists label Jul 19, 2020
@famod
Copy link
Member

famod commented Jul 19, 2020

Sorry, I just realized that you are already using the provided workaround that was mentioned here: #1502 (comment)
Btw, I ran into #1502 with hibernate-jpamodelgen myself but I did not want to add it as a dependency since it brings in jaxb which has a specific Quarkus-module that shall be used instead and I wanted to avoid conflicts. See also: #1502 (comment)

I'll reopen this so that @aloubyansky can have a look. But I suppose this will be tricky since provided dependencies are not propagated to downstream modules.
You could add it to the root parent, but that might also cause inconsistencies...

@famod famod reopened this Jul 19, 2020
@famod famod added area/devmode area/maven and removed triage/duplicate This issue or pull request already exists labels Jul 19, 2020
@aloubyansky
Copy link
Member

Yes, it's a good one. We need to properly setup the classpath for each module.

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Jul 27, 2020
Each module now contains a list of dependencies,
so individual class paths are respected.

Partially Fixes quarkusio#10833, as this will now work when
quarkus:dev is run from the root, but not when it is
run from a sub folder. As we currently can't resolve
the dependencies of the other project.
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Jul 27, 2020
Each module now contains a list of dependencies,
so individual class paths are respected.

Partially Fixes quarkusio#10833, as this will now work when
quarkus:dev is run from the root, but not when it is
run from a sub folder. As we currently can't resolve
the dependencies of the other project.
gsmet pushed a commit to stuartwdouglas/quarkus that referenced this issue Jul 27, 2020
Each module now contains a list of dependencies,
so individual class paths are respected.

Partially Fixes quarkusio#10833, as this will now work when
quarkus:dev is run from the root, but not when it is
run from a sub folder. As we currently can't resolve
the dependencies of the other project.
gsmet pushed a commit to stuartwdouglas/quarkus that referenced this issue Jul 28, 2020
Each module now contains a list of dependencies,
so individual class paths are respected.

Partially Fixes quarkusio#10833, as this will now work when
quarkus:dev is run from the root, but not when it is
run from a sub folder. As we currently can't resolve
the dependencies of the other project.
@famod
Copy link
Member

famod commented Mar 11, 2021

@Postremus

You could add it to the root parent

Have you ever tried this?

@Postremus
Copy link
Member Author

Closing this one. This is deprecated now that one is supposed to declare annotation processors using the compiler plugin

@Postremus
Copy link
Member Author

If I define the annotationProcessorPaths on the compiler-plugin of different modules, they are not executed by the quarkus dev mode hot reload.

If I define my compiler-plugin configuration additionally on the module housing my quarkus-maven-plugin, then the annotation processors are executed for each hot reload.

@famod fyi

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.hibernate.orm</groupId>
                            <artifactId>hibernate-jpamodelgen</artifactId>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants