vert-x3 / vertx-service-proxy

EventBus Proxy generation
Apache License 2.0
66 stars 58 forks source link

Annotation processor 'io.vertx.codegen.CodeGenProcessor' not found #70

Closed UkonnRa closed 5 years ago

UkonnRa commented 6 years ago

Hi! While compiling my Vertx project using vertx-service-proxy, I found I get an confusing error: Annotation processor 'io.vertx.codegen.CodeGenProcessor' not found

Here is the pom.xml (Or you can get the whole project here: https://github.com/CasterKKK/CasterMovieVertx if you want):

<dependencies>
    ...
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-service-proxy</artifactId>
        <classifier>processor</classifier>
    </dependency>
    ...
</dependencies>

...
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler.version}</version>
        <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <useIncrementalCompilation>false</useIncrementalCompilation>
            <encoding>${project.build.sourceEncoding}</encoding>
            <generatedSourcesDirectory>src/main/generated</generatedSourcesDirectory>
            <generatedTestSourcesDirectory>src/test/generated</generatedTestSourcesDirectory>
         </configuration>
           <executions>
                <execution>
                    <id>default-compile</id>
                        <configuration>
                            <annotationProcessors>
                                <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                            </annotationProcessors>
                            <generatedSourcesDirectory>src/main/generated</generatedSourcesDirectory>
                            <compilerArgs>
                                <arg>-Acodegen.output=${project.basedir}/src/main</arg>
                            </compilerArgs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <annotationProcessors>
                                <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                            </annotationProcessors>
                           <generatedTestSourcesDirectory>src/test/generated</generatedTestSourcesDirectory>
                       <compilerArgs>
                          <arg>-Acodegen.output=${project.basedir}/src/test</arg>
                    </compilerArgs>
                </configuration>
             </execution>
         </executions>
</plugin>

Show one of the Service:

@VertxGen
@ProxyGen
public interface UserService<T extends User> {

    @Fluent
    UserService register(T element, Handler<AsyncResult<T>> resultHandler) throws IOException;

    @Fluent
    UserService validate(UUID id, Handler<AsyncResult<T>> resultHandler) throws IOException;

    @Fluent
    UserService cancel(UUID id, Handler<AsyncResult<T>> resultHandler);

    @Fluent
    UserService update(UUID id, T element, Handler<AsyncResult<T>> resultHandler);

    @Fluent
    UserService getByJwt(String jwt, Handler<AsyncResult<T>> resultHandler);

    @Fluent
    UserService findById(UUID id, Handler<AsyncResult<T>> resultHandler);

    @Fluent
    UserService findByEmail(String email, Handler<AsyncResult<T>> resultHandler);

    @Fluent
    UserService findAllByState(State state, Handler<AsyncResult<List<T>>> resultHandler);

    @Fluent
    UserService findAllByCreateTimeBetween(Instant from, Instant to, Handler<AsyncResult<List<T>>> resultHandler);

    @Fluent
    UserService findAllByCancelledTimeBetween(Instant from, Instant to, Handler<AsyncResult<List<T>>> resultHandler);
}

And when using mvn package -X -f pom.xml, get an error:

[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project user-module: Compilation failure
Annotation processor 'io.vertx.codegen.CodeGenProcessor' not found

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    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:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
Annotation processor 'io.vertx.codegen.CodeGenProcessor' not found

    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1161)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:168)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :user-module

What's more, I found when I use

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-service-proxy</artifactId>
            <classifier>processor</classifier>
        </dependency>

and

<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-codegen</artifactId>
</dependency>

together, my module-info.java will get a Module xxx reads package 'io.vertx.codegen' from both 'vertx.codegen' and 'vertx.codegen' & Ambiguous module reference: vertx.codege error... What that mean?

UkonnRa commented 6 years ago

What's more, I found some fatal weak points:

  1. It cannot deal with Rx situation, like Single<T> something(P param);, which is a disaster for the users who want to construct a pure Rx project;
  1. The module name is conflict between vertx-service-proxy and vertx-codegen

  2. vertx-server-porxy cannot deal with hierarchy Services with generics.

slinkydeveloper commented 5 years ago

For Rx you must write the service interface in plain java with handlers and then import

    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java2</artifactId>
      <version>3.7.0</version>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java2-gen</artifactId>
      <version>3.7.0</version>
    </dependency>

This will generate the RXified version For the imports (3.6+), you must import vertx-codegen as processor and vertx-service-proxy, like described in the docs: https://vertx.io/docs/vertx-service-proxy/java/#_using_vert_x_service_proxies

Let me know if you need something else