6
votes

I am trying to use the protoc jar maven plugin in intelij. I've added this to my pom.xml:

        <plugin>
            <groupId>com.github.os72</groupId>
            <artifactId>protoc-jar-maven-plugin</artifactId>
            <version>3.1.0.2</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <includeDirectories>
                            <include>src/main/protobuf</include>
                        </includeDirectories>
                        <inputDirectories>
                            <include>src/main/protobuf</include>
                        </inputDirectories>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I have a proto file located at src/main/protobuf. I also have this in my pom.xml:

    <dependency>
        <groupId>com.github.os72</groupId>
        <artifactId>protoc-jar</artifactId>
        <version>3.1.0.1</version>
    </dependency>

And here is the proto:

package stringtest;

message StringObject {
    repeated string string_one = 1;
    repeated string string_two = 2;
    repeated string string_three = 3;
}

However, whenever I right click on my module and click build, or if I go to the Build menu and hit Build project, I do not see any compiled protobuf files being generated. I also do not see any errors. Does anyone know what I am doing wrong?

1
Did you find a solution to this problem? I am trying to figure out the same...IgorGanapolsky
Unfortunately, I haven't. I think I'm just going to write a script to use protoc and generate the classes for me. It's annoying, but at least it should work.srchulo

1 Answers

0
votes

Make sure your .proto file is in your resources folder src/main/resources and your pom.xml can be anywhere within the src folder when you run maven install. You should see your files within your main java folder be generated.