2017-08-31 4 views
0

installieren Ich finde Probleme mit dem Erstellen von Protokoll Jar, das Java-Klasse-Dateien aus Proto-Dateien generieren soll. Ich würde wirklich jede Art von Richtung oder Hilfe bei der Einrichtung des Projekts auf eine Ebene schätzen, wo ich Java-Klassen-Dateien von .proto Dateien generieren kannKann nicht Protokoll auf Windows

Ich habe die folgenden Projekte aus protobuf git repo importiert, konnte aber nicht finden protoc.exe Datei in den Projektverzeichnissen.

enter image description here

Die Projekte selbst in der Lage, beschweren sich über nicht bestimmte Klassen zu verweisen. enter image description here

Als ich versuchte, die Erstellung und den Aufbau der protobuf-Eltern-Projekt mit Maven, bekomme ich Fehler wie unten gezeigt

main: 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] Protocol Buffers [Parent] .......................... SUCCESS [ 0.173 s] 
[INFO] Protocol Buffers [Core] ............................ FAILURE [ 0.736 s] 
[INFO] Protocol Buffers [Util] ............................ SKIPPED 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.347 s 
[INFO] Finished at: 2017-08-30T20:52:49-07:00 
[INFO] Final Memory: 16M/220M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (compile-protoc) on project protobuf-java: An Ant BuildException has occured: C:\scratch1\protobuf\protobuf-master\java\core\src\main\proto does not exist. 
[ERROR] around Ant part ...<pathconvert property="proto.files" pathsep=" " refid="proto.path"/>... @ 10:71 in C:\scratch1\protobuf\protobuf-master\java\core\target\antrun\build-main.xml 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

Antwort

1

Ich empfehle Ihnen, eine vorkompilierte protoc.exe binäre Datei unter Windows zu verwenden. Download protoc-x.x.x-win32.zip and protoc-x.x.x-java.zip packages

Dekomprimieren von Dateien sollten Sie ein Ordner wie folgt aus (nur wenige Schlüsseldateien Auflistung) erhalten:

C:\projects\protoc\protoc-x.x.x-win32\bin\protoc.exe 
C:\projects\protoc\protoc-x.x.x\protobuf.pc.in 
C:\projects\protoc\protoc-x.x.x\java\pom.xml 
C:\projects\protoc\protoc-x.x.x\java\core\* 
C:\projects\protoc\protoc-x.x.x\java\util\* 

Compile Java-Projekt Maven verwenden, finden Sie dieses Skript Helfer bat:

cd C:\projects\protoc\protobuf-x.x.x\java 
set JAVA_HOME=c:\program files\Java\jdk1.7.0_75 
"c:\apps\apache-maven\bin\mvn.cmd" "-Dprotobuf.source.dir=C:\projects\protoc\protoc-x.x.x-win32\bin" package 

Sie Sollte JAR-Dateien in den folgenden Ordnern finden, sind dies die Dateien, die Sie in Ihr Projekt einbetten, wenn Sie MyStructureProto.java oder andere protobuf-Objekte (Bytes zum Objekt, Objekt zu Bytes) verwenden.

C:\projects\protoc\protoc-x.x.x\java\core\target\protobuf-java-3.3.0.jar 
C:\projects\protoc\protoc-x.x.x\java\util\target\protobuf-java-util-3.3.0.jar 

Verwenden protoc.exe Java-Implementierung von .proto Template Descriptor zu erstellen:

C:\projects\protoc\protoc-x.x.x-win32\bin\protoc.exe --java_out=. MyStructureProto.proto 
Verwandte Themen