Repository: quarkusio/quarkus
Issue: Running gradle quarkusDev fails in a multi-module Gradle project

### Describe the bug

I am learning the tutorial: [GETTING STARTED WITH REACTIVE](https://quarkus.io/guides/getting-started-reactive)

When I run `gradle :quarkus-reactive:quarkusDev` in a multi-module gradle project, I get an exception

> Execution failed for task ':quarkus-reactive:compileJava'.
> \\> Cannot change dependencies of dependency configuration ':quarkus-reactive:annotationProcessor' after it has been included in dependency resolution. Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration.

When I comment out `implementation("io.quarkus:quarkus-hibernate-reactive-panache")` it works fine

### Expected behavior

This Quarkus plugin should work fine in other submodules

### Actual behavior

this Quarkus plugin doesn't seem to be able to execute `compileJava` task in submodule

### How to Reproduce?

Here is my example code:

[reproduce/quarkus at main · tabuyos/reproduce](https://github.com/tabuyos/reproduce/tree/main/quarkus)

Execute the `gradle :quarkus-reactive:quarkusDev` task in the quarkus directory

### Output of `uname -a` or `ver`

Microsoft Windows [version 10.0.19043.1466]

### Output of `java -version`

openjdk version "16" 2021-03-16

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.7.1.Final

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

Gradle 7.0.2

### Additional information

_No response_

Changed files:
devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java

diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
index 55d857392b2..05cbf49b6a1 100644
--- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
+++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
@@ -54,6 +54,7 @@
 import io.quarkus.gradle.tasks.QuarkusTestNative;
 import io.quarkus.gradle.tasks.QuarkusUpdate;
 import io.quarkus.gradle.tooling.GradleApplicationModelBuilder;
+import io.quarkus.gradle.tooling.dependency.DependencyUtils;
 import io.quarkus.gradle.tooling.dependency.ExtensionDependency;
 
 public class QuarkusPlugin implements Plugin<Project> {
@@ -299,10 +300,12 @@ private void registerConditionalDependencies(Project project) {
                             configName).declareConditionalDependencies();
                     deploymentClasspathBuilder.createBuildClasspath(testExtensions, configName);
                 });
-        project.getConfigurations().getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME).getIncoming()
-                .beforeResolve(annotationProcessors -> {
-                    Set<ResolvedArtifact> compileClasspathArtifacts = project.getConfigurations()
-                            .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).getResolvedConfiguration()
+        project.getConfigurations().getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME)
+                .withDependencies(annotationProcessors -> {
+                    Set<ResolvedArtifact> compileClasspathArtifacts = DependencyUtils
+                            .duplicateConfiguration(project, project.getConfigurations()
+                                    .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME))
+                            .getResolvedConfiguration()
                             .getResolvedArtifacts();
 
                     // enable the Panache annotation processor on the classpath, if it's found among the dependencies