Repository: quarkusio/quarkus
Issue: llegalAccessError with Panache MongoDB and Gradle

**Describe the bug**
Following this ticket https://github.com/quarkusio/quarkus/issues/12514

The bug has been fixed with Maven in the 1.11.0.Final but still exist if we use Gradle instead.

**Expected behavior**
The application should be able to access the entities with MongoDb.

**Actual behavior**
An exception is raised:
```
java.lang.IllegalAccessError: class org.acme.ExampleResource tried to access protected field org.acme.db.TestEntity.name
```
while the field is public.

**To Reproduce**

Sample repo: https://github.com/avdev4j/quarkus-mongo-gradle

- Clone the repo: `git clone git@github.com:avdev4j/quarkus-mongo-gradle.git`
- Run tests:` ./gradlew test`
- testHelloEndpoint() will fail with the following error:

<details><pre>
ExampleResourceTest STANDARD_ERROR
    Feb 16, 2021 10:44:02 AM io.quarkus.bootstrap.runner.Timing printStartupTime
    INFO: Quarkus 1.11.3.Final on JVM started in 6.314s. Listening on: http://localhost:8081
    Feb 16, 2021 10:44:02 AM io.quarkus.bootstrap.runner.Timing printStartupTime
    INFO: Profile test activated.
    Feb 16, 2021 10:44:02 AM io.quarkus.bootstrap.runner.Timing printStartupTime
    INFO: Installed features: [cdi, mongodb-client, mongodb-panache, mutiny, resteasy, smallrye-context-propagation]

ExampleResourceTest > testHelloEndpoint() STANDARD_ERROR
    Feb 16, 2021 10:44:03 AM io.quarkus.vertx.http.runtime.QuarkusErrorHandler handle
    ERROR: HTTP Request to /hello failed, error id: 3986bfb1-8405-43f6-b48b-6bafe1a2689b-1
    org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalAccessError: class org.acme.ExampleResource tried to access protected field org.acme.db.TestEntity.name (org.acme.ExampleResource and org.acme.db.TestEntity are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @17d70d9e)
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:41)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
    Caused by: java.lang.IllegalAccessError: class org.acme.ExampleResource tried to access protected field org.acme.db.TestEntity.name (org.acme.ExampleResource and org.acme.db.TestEntity are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @17d70d9e)
        at org.acme.ExampleResource.hello(ExampleResource.java:17)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:643)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:507)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:457)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:459)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:419)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:393)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:68)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 15 more
</pre></details>

**Configuration**
application.properties is empty

**Screenshots**
(If applicable, add screenshots to help explain your problem.)

**Environment (please complete the following information):**
 - Output of `uname -a` or `ver`: 
 `Darwin MacBook-Pro.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64`
 - Output of `java -version`: `openjdk version "11.0.7" 2020-04-14`
 - GraalVM version (if different from Java): /
 - Quarkus version or git rev: `1.11.3.FInal`
 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): 
```
 ------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.7 (AdoptOpenJDK 11.0.7+10)
OS:           Mac OS X 10.16 x86_64
```

**Additional context**
(Add any other context about the problem here.)

cc @danielpetisme 

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

diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
index 3d3b31f50b1..3169d956afb 100644
--- a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
+++ b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
@@ -138,7 +138,14 @@ public void execute(Task test) {
                 JavaPlugin.class,
                 javaPlugin -> {
                     project.afterEvaluate(this::afterEvaluate);
+                    ConfigurationContainer configurations = project.getConfigurations();
                     JavaCompile compileJavaTask = (JavaCompile) tasks.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
+
+                    // By default, gradle looks for annotation processors in the annotationProcessor configuration.
+                    // This configure the compile task to look for annotation processors in the compileClasspath.
+                    compileJavaTask.getOptions().setAnnotationProcessorPath(
+                            configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME));
+
                     compileJavaTask.dependsOn(quarkusGenerateCode);
                     quarkusGenerateCode.setSourceRegistrar(compileJavaTask::source);
 
@@ -171,8 +178,6 @@ public void execute(Task test) {
                                     .plus(mainSourceSet.getOutput())
                                     .plus(testSourceSet.getOutput()));
 
-                    ConfigurationContainer configurations = project.getConfigurations();
-
                     // create a custom configuration for devmode
                     configurations.create(DEV_MODE_CONFIGURATION_NAME).extendsFrom(
                             configurations.getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME),