-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
False
-
False
-
None
When processing ProtoStream annotations, a compile error will occur if the dependency does not have protostream-processor.
From reading the following documentation, I believe that I only need to set up a protostream-processor in the Maven Compiler Plugin.
https://github.com/infinispan/protostream/tree/5.0.1.Final?tab=readme-ov-file#annotation-processor
So I created the following code.
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>proto-stream-compilation-error</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> <dependencies> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-client-hotrod</artifactId> <version>15.0.0.Final</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.12.1</version> <configuration> <!-- Annotation processors --> <annotationProcessorPaths> <annotationProcessorPath> <groupId>org.infinispan.protostream</groupId> <artifactId>protostream-processor</artifactId> <version>5.0.1.Final</version> </annotationProcessorPath> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build> </project>
package org.example; import org.infinispan.protostream.annotations.Proto; @Proto public record Book( String title, int price ) { }
package org.example; import org.infinispan.protostream.GeneratedSchema; import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder;@AutoProtoSchemaBuilder( includeClasses = { Book.class }, schemaFileName = "library.proto", schemaFilePath = "proto/", schemaPackageName = "book_sample") interface LibraryInitializer extends GeneratedSchema { }
When I build this project, I get a compile error.
mvn compile
[INFO] --- compiler:3.12.1:compile (default-compile) @ proto-stream-compilation-error --- [INFO] Recompiling the module because of changed source code. [INFO] Compiling 2 source files with javac [debug target 17] to target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /path/to/proto-stream-compilation-error/target/generated-sources/annotations/org/example/LibraryInitializerImpl.java:[16,55] package org.infinispan.protostream.annotations.impl.processor does not exist
The following part of the generated source code seems to be the problem.
@org.infinispan.protostream.annotations.impl.processor.OriginatingClasses({ org.example.Book.class })
If I add protostream-processor to the dependencies, it compiles without any problem, but from the documentation, this is not necessary, is it?
<dependency> <groupId>org.infinispan.protostream</groupId> <artifactId>protostream-processor</artifactId> <version>5.0.1.Final</version> <scope>provided</scope> </dependency>