xolstice / protobuf-maven-plugin

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

Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom #98

Closed AliHassan89 closed 2 years ago

AliHassan89 commented 2 years ago

Hi,

I've been struggling with the following error.

[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom (compile) on project grpc: protoc did not exit cleanly. Review output for more information. -> [Help 1]

Here is how my maven pom file looks like.

`<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">

<artifactId>grpc</artifactId>

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <protobuf.version>3.19.4</protobuf.version>
    <protoc.version>1.44.0</protoc.version>
</properties>

<dependencies>
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-grpc</artifactId>
        <version>4.1.5</version>
        <exclusions>
            <exclusion>
                <groupId>io.vertx</groupId>
                <artifactId>vertx-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-core</artifactId>
        <version>${vertx.version}</version>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>protoc-gen-grpc-java</artifactId>
        <version>${protoc.version}</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-stub</artifactId>
        <version>${protoc.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>RELEASE</version>
    </dependency>
</dependencies>

<build>
    <extensions>
        <extension>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
            <version>1.7.0</version>
        </extension>
    </extensions>
    <plugins>
        <plugin>
            <groupId>org.xolstice.maven.plugins</groupId>
            <artifactId>protobuf-maven-plugin</artifactId>
            <version>0.6.1</version>
            <configuration>
                <protocArtifact>
                    com.google.protobuf:protoc:3.14.0:exe:${os.detected.classifier}
                </protocArtifact>
                <pluginId>grpc-java</pluginId>
                <pluginArtifact>io.grpc:protoc-gen-grpc-java:${protoc.version}:exe:${os.detected.classifier}
                </pluginArtifact>
                <protocPlugins>
                    <protocPlugin>
                        <id>vertx-grpc-protoc-plugin</id>
                        <groupId>io.vertx</groupId>
                        <artifactId>vertx-grpc-protoc-plugin</artifactId>
                        <version>4.2.3</version>
                        <mainClass>io.vertx.grpc.protoc.plugin.VertxGrpcGenerator</mainClass>
                    </protocPlugin>
                </protocPlugins>
            </configuration>
            <executions>
                <execution>
                    <id>compile</id>
                    <configuration>
                        <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                        <clearOutputDirectory>false</clearOutputDirectory>
                    </configuration>
                    <goals>
                        <goal>compile</goal>
                        <goal>compile-custom</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <goals>
                        <goal>test-compile</goal>
                        <goal>test-compile-custom</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

`

@sergei-ivanov I saw you commented on this issue. Any idea what's causing it? Please let me know if you need more info.

AliHassan89 commented 2 years ago

Fixed it by enclosing plugins in <pluginManagement>

AliHassan89 commented 2 years ago

I changed my child pom file to move all the generated code to the target folder. I couldn't get it working with pluginManagement tag. I moved pluginManagement to my parent pom and using the defined plugin in parent pom under pluginManagment in my child pom. Here are both the pom files:

Parent pom:

              <pluginManagement>
                 <plugin>
                    <groupId>org.xolstice.maven.plugins</groupId>
                    <artifactId>protobuf-maven-plugin</artifactId>
                    <version>0.6.1</version>
                    <configuration>
                        <protocArtifact>
                            com.google.protobuf:protoc:3.14.0:exe:${os.detected.classifier}
                        </protocArtifact>
                        <pluginId>grpc-java</pluginId>
                        <pluginArtifact>io.grpc:protoc-gen-grpc-java:${protoc.version}:exe:${os.detected.classifier}
                        </pluginArtifact>
                        <protocPlugins>
                            <protocPlugin>
                                <id>vertx-grpc-protoc-plugin</id>
                                <groupId>io.vertx</groupId>
                                <artifactId>vertx-grpc-protoc-plugin</artifactId>
                                <version>4.2.3</version>
                                <mainClass>io.vertx.grpc.protoc.plugin.VertxGrpcGenerator</mainClass>
                            </protocPlugin>
                        </protocPlugins>
                    </configuration>
                    <executions>
                        <execution>
                            <id>compile</id>
                            <configuration>
                                <outputDirectory>${protobuf.output.directory}</outputDirectory>
                                <clearOutputDirectory>false</clearOutputDirectory>
                            </configuration>
                            <goals>
                                <goal>compile</goal>
                                <goal>compile-custom</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>test-compile</id>
                            <goals>
                                <goal>test-compile</goal>
                                <goal>test-compile-custom</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

Child pom:

         </plugins>
             <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
            </plugin>
        </plugins>

The error I'm getting is : Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom (compile) on project: protoc did not exit cleanly. Review output for more information. -> [Help 1]

AliHassan89 commented 2 years ago

Resolved this issue. The problem was that CI pipeline running RHEL 7 that supports glibc 2.12. Whereas protoc after version 1.34 is not compatible with glibc 2.12. The fix is to use supported protoc and protobuf versions. The versions which worked for me are protoc 3.12.0 and protobuf 1.34.0.

BoHuang2018 commented 2 years ago

Resolved this issue. The problem was that CI pipeline running RHEL 7 that supports glibc 2.12. Whereas protoc after version 1.34 is not compatible with glibc 2.12. The fix is to use supported protoc and protobuf versions. The versions which worked for me are protoc 3.12.0 and protobuf 1.34.0.

Hi @AliHassan89, I am facing the same error. I read your solution here. However, this is my first time to see these terminologies like RHEL 7 that supports glibc 2.12 .... Could you give more details about how to implement the solution step by step ?