xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
242 stars 79 forks source link

Broken in Reactor setups by Maven 3.8 #101

Open ches opened 2 years ago

ches commented 2 years ago

Describe the bug

It appears that in reactor projects where downstream modules depend on the build output of a module in which protobuf-maven-plugin generates code, with Maven 3.8.x the build products are no longer available on the classpath for the downstream modules—they fail to compile with "cannot find symbol" errors for the protobuf products.

I find that the protobuf products are built as expected in target/generated-sources and target/classes of the upstream module, it appears that the problem is only in classpath propagation through the reactor build state.

Reverting to Maven 3.6.3 works around the issue.

Environment

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /usr/local/Cellar/maven/3.8.5/libexec
Java version: 1.8.0_292, vendor: AdoptOpenJDK, runtime: /Users/cmartin/.sdkman/candidates/java/8.0.292.hs-adpt/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Standalone or IDE

Standalone

Plugin configuration

        <plugin>
          <groupId>org.xolstice.maven.plugins</groupId>
          <artifactId>protobuf-maven-plugin</artifactId>
          <version>0.6.1</version>
          <configuration>
            <checkStaleness>true</checkStaleness>
            <protocArtifact>
                com.google.protobuf:protoc:${protocVersion}:exe:${os.detected.classifier}
            </protocArtifact>
            <pluginId>grpc-java</pluginId>
            <pluginArtifact>
                io.grpc:protoc-gen-grpc-java:${grpcVersion}:exe:${os.detected.classifier}
            </pluginArtifact>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>
                <goal>compile-custom</goal>
                <goal>test-compile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

To Reproduce

I will try to come back to this issue to add a minimal and publicly-available reproduction project.

Steps to reproduce the behavior:

  1. Set up a multi-module Maven build, where Module A uses protobuf-maven-plugin to generate some Java classes.
  2. Make a Module B which depends on Module A and refers to symbols produced by it.
  3. Use Maven 3.8 and run mvn --also-make compile

Log output

Compilation errors with "cannot find symbol" for the proto products. Again, can update with actual build logs from a public repro.

Expected behavior

Module B builds successfully, as it does when using Maven 3.6.