Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build Protobuf for Java in Windows via Eclipse

I download the source Protobuf zip file. Then I open up my Classic Eclipse and choose File->Import->Existing Maven Projects.

I choose the root folder to be /java. It shows that pom.xml has been ticked, choose Next.

The screen says: Setup Maven plugin connectors: with

maven-antrun-plugin:1.3:run (2 errors):
No marketplace entries found to handle maven-antrun-plugin:1.3:run in Eclipse. Please see Help for more information.

Am I missing something here?

like image 434
Dat Chu Avatar asked Dec 01 '11 06:12

Dat Chu


1 Answers

You can ignore that error. But when the import process finish probably you will get:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.3:run (execution: generate-sources, phase: generate-sources)

If so, reason is that your current configuration doesn't support maven-antrun. You can find a related question here: How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds

An explanation of the problem can be found here: http://wiki.eclipse.org/M2E_plugin_execution_not_covered

Easy way to solve? Adding the next block of code to your pom.xml:

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <versionRange>[1.0.0,)</versionRange>
                <goals>
                  <goal>run</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <execute>
                  <runOnIncremental>false</runOnIncremental>
                </execute>
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>

After some usual update Maven project configuration, clear and rebuild all, pom problem disappear.

But then you will get probably some error about missing classes. You must download the protoc binary and execute it for all the .proto files you can find on your sources directory. Example:

protoc --java_out=src/main/java -I../src ..\ src\google\protobuf\descriptor.proto
like image 160
Juan Mellado Avatar answered Oct 29 '22 04:10

Juan Mellado