Dagger: Dagger-gRPC server annotation processor

Created on 23 Oct 2020  路  5Comments  路  Source: google/dagger

I'm trying to use Dagger in a java gRPC service project. I've been following the official documentation of Dagger for creating gRPC servers available here: https://dagger.dev/dev-guide/grpc-servers.html.

Upon building, Dagger should automatically create auto generated classes from the used annotation (@GrpcService). Unfortunately, I can't get the program to auto generate the needed classes when I compile.

I'm using "dagger-grpc-server" maven dependency version 2.28.1 and gRPC version 1.30.2. Also, I tried adding "dagger-grpc-server-processor" version 2.28.1 to the annotationProcessorPaths once, and I tried adding "dagger-grpc-server-annotations" version 2.28.1 to the annotationProcessorPaths, but neither of them worked.

The goal is to get dagger to automatically create the generated files during compilation. Which plugins am I missing?

needs investigation

All 5 comments

Hi @MostafaAmer-2,

Sorry, I couldn't reproduce this. Can you check that if these are java sources you have added the processor artifact to annotationProcessor and if these are Kotlin sources you have added the processor artifact to kapt, as shown below:

dependencies {
    implementation "com.google.dagger:dagger-grpc-server:$daggerVersion"

    // For processing java sources
    annotationProcessor "com.google.dagger:dagger-grpc-server-processor:$daggerVersion"

    // For processing Kotlin sources
    kapt "com.google.dagger:dagger-grpc-server-processor:$daggerVersion"
}

Hello @bcorso ,

Thank you for reply. I am currently using dagger and gRPC in a java project and here are my maven dependencies. I tried adding the ones you specified, but still the auto generated files didn't get created upon compilation.

    <dependency>
        <groupId>com.google.dagger</groupId>
        <artifactId>dagger-grpc-server</artifactId>
        <version>2.28.1</version>
    </dependency>

                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <release>11</release>
                        <!-- Plugging Dagger in -->
                        <annotationProcessorPaths>
                            <path>
                                <groupId>com.google.dagger</groupId>
                                <artifactId>dagger-grpc-server-processor</artifactId>
                                <version>2.28.1</version>
                            </path>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>

@MostafaAmer-2, is your source Java or Kotlin?

Quote @MostafaAmer-2

... and gRPC in a java project and here are ...

Hmm, I'm not sure then.

I might have to find some time to reproduce locally with maven unless you have an example project already.

Also, can you check if other compiler plugins are running? E.g. is com.google.dagger:dagger-compiler working for you?

Was this page helpful?
0 / 5 - 0 ratings