Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Sergei Ivanov
    @sergei-ivanov
    @pradeepg26 this is strange, because I can see it in Maven Central
    can you provide a bit more context to the error?
    magick93
    @magick93
    Hello, I am trying to generate java classes using the protobuf-maven-plugin. I can generate classes, however there is only <type>OuterClasse.java generated. No service classes are generated. Any idea why this is?
    Fabien Hermenier
    @fhermeni
    Hello. When I use protobuf:compile it generates the code of all but my service. When I use protobuf:compile-custom, it generates only the code of my service. So a lot of code is missing
    Got it, it is because the output directory where the same. Using <clearOutputDirectory>false</clearOutputDirectory>solved the problem
    uruloki85
    @uruloki85

    Hi! I'm trying to compile 4 proto files located in 3 different projects, A.proto & B.proto in project1, C.proto in project2 and D.proto in project3. A depends on C and D.

                <plugin>
                    <groupId>org.xolstice.maven.plugins</groupId>
                    <artifactId>protobuf-maven-plugin</artifactId>
                    <configuration>
                        <protocArtifact>com.google.protobuf:protoc:${proto.version}:exe:${os.detected.classifier}</protocArtifact>
                        <includes>
                            <include>../project2/src/main/proto/subfolder/*.proto</include>
                            <include>../project3/*.proto</include>
                            <include>src/main/proto/subfolder/*.proto</include>
                            <!-- <include>**/*.proto</include> -->
                        </includes>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>compile-python</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

    When I run maven it says "No proto files to compile.". If I uncomment <include>**/*.proto</include> then it complains about missing types (those defined in project2 and project3). I cannot find in the documentation any example or further information.

    uruloki85
    @uruloki85
    @sergei-ivanov any help? I'd like to use relative paths to project2 and project3 (that's what I tried with ../project, going one level up and then entering in the project2 folder)
    uruloki85
    @uruloki85
    fyi, I finally changed to a different plugin https://github.com/os72/protoc-jar-maven-plugin which very easily allowed me to do what I need
    cliveseldon
    @cliveseldon
    Is there any example of how to find proto files in included jar dependencies of ones project?
    Sergei Ivanov
    @sergei-ivanov
    @uruloki85 sorry, I missed your message, gitter stopped sending notifications for some reason
    dependencies are handled in the standard maven way
    i.e. your project compiles protos into java and then into class files, then the source protos are packaged into the resulting jar file as resources
    the dependent project downloads the dependency jar with packaged protos, unpacks them and uses them as imports
    include/exclude patterns are relative to the proto source directory and allow you to compile only specific proto files
    Sergei Ivanov
    @sergei-ivanov
    so normally you should not try to reference proto files outside of your module directory (i.e. via ../project2/...)
    you don't do it with java, because it goes against maven conventions, and the same principle applies to protos
    the plugin handles dependencies automatically for you
    @cliveseldon that probably answers your question too
    if you go into the github repository for maven plugin, there are lots of examples under src/it that demonstrate dependency handling and other features
    Sergei Ivanov
    @sergei-ivanov
    the only possible caveat is packages: protobuf compiler can be quite picky about these when importing, so please make sure that you have a directory structure under src/main/proto that reflects package declarations in your protos
    for example, if you have package com.acme in your proto file, it must be placed inside src/main/proto/com/acme subdirectory, otherwise you are going to have a lot of trouble with unresolved imports
    uruloki85
    @uruloki85
    many thanks @sergei-ivanov , it makes totally sense but my requirements forced me to do that (reference proto files outside my project)
    Sergei Ivanov
    @sergei-ivanov
    Are your other projects maven projects too?
    uruloki85
    @uruloki85
    Nope, they aren't. They are just 2 proto files designed by other people.
    Sergei Ivanov
    @sergei-ivanov
    But when you refer to ../project2/src/main/proto it looks like another maven project
    uruloki85
    @uruloki85
    But it isn't
    Sergei Ivanov
    @sergei-ivanov
    Ok, looks like it only pretends to be one then :)
    Duke Jake Morgan
    @TheMasteredPanda
    Anyone available to tend to my problem? xolstice/protobuf-maven-plugin#38
    Thanks in advance.
    Sergei Ivanov
    @sergei-ivanov
    I answered there
    bkuhhirte
    @bkuhhirte
    I just started using this plugin and curious if anyone else has tried to use it in conjunction protoc-gen-swagger?
    In other words, as I generate my stubs and unravel the dependent .proto files from other JARs, can I generate the swagger.json without going back to the CLI?
    Sergei Ivanov
    @sergei-ivanov
    Can you please provide any links or examples?
    Amal Janardhanan
    @amalj_twitter
    I have around 1000+ protobuf schema files. When I tried to compile, I am getting "/protoBufSchemas/target/protoc-plugins/protoc-3.0.2-osx-x86_64.exe": error=7, Argument list too long". Any help with this please ?
    Sergei Ivanov
    @sergei-ivanov
    The only way around it at the moment is to split up your plugin execution into a few smaller executions, each using includes and excludes to compile a smaller chunk of proto files at a time.
    Sergei Ivanov
    @sergei-ivanov
    @amalj_twitter there is a pending PR that will address this issue for protoc version 3.5.0 and higher
    Hopefully the new version of the plugin will be released pretty soon
    thinkerou
    @thinkerou
    Hi, I have one java project(name: X) which uses one proto jar dependency package, and the project X have not src/main/proto directory or have any proto file on src/main/proto directory. When I compile the project X which not generate target/protoc-dependencies, but I hope it have, because I want to use the whole files on target/protoc-dependencies directory to generate descriptor set. How shold I do? thanks!
    Sergei Ivanov
    @sergei-ivanov
    Hi,
    I assume that you do not have any control over the dependency jar? Or do you?
    thinkerou
    @thinkerou
    Usually, proto files as jar package are depended by other java project. I only read the proto files on the dependency proto jar. (sorry for my english)
    Sergei Ivanov
    @sergei-ivanov
    No worries, I think I understand your situation. I don’t think there’s a way for the maven plugin to generate anything if it has no .proto files in the current project. Ideally the project that contains .proto files would also generate java classes and protobuf descriptor(s) and distribute them as artifacts. But there are ways to work around that if you have no control over the dependency project.
    thinkerou
    @thinkerou
    thanks, I understand your mean. can plugin add one optional param, like createTemporaryProtoFileDirectory? I really need to use/read the dependecny proto jar. As the above said, when my project have proto file/directory, but I want to check/read proto definition which depended the current project.
    Sergei Ivanov
    @sergei-ivanov
    I am generally against adding extra features to the plugin for handling marginal cases. Usually it can be achieved by using the existing solutions. There must be a way to use maven-dependency-plugin to unpack the protos into the target directory in the early phase of the build lifecycle. And then point protobuf-maven-plugin to that directory as a source.
    I am currently typing from my phone, which makes it difficult to produce a proper example. But I hope you’ll be able to figure it out. If you are stuck, drop me a note here, and I may be able to help you later in the day. But try it yourself first please.
    thinkerou
    @thinkerou
    OK, thanks a lot, I will try it first!
    thinkerou
    @thinkerou
    @sergei-ivanov use maven-dependency-plugin can solve my question, thanks again!
    Sergei Ivanov
    @sergei-ivanov
    No worries, I am glad that I could point you in the right direction.
    Have a nice day!
    Wenwei Hu
    @wenweihu86
    <plugin>
    <groupId>org.xolstice.maven.plugins</groupId>
    <artifactId>protobuf-maven-plugin</artifactId>
    <version>0.6.1</version>
    <configuration>
    <clearOutputDirectory>false</clearOutputDirectory>
    </configuration>
    <executions>
    <execution>
    <goals>
    <goal>compile</goal>
    <goal>test-compile</goal>
    </goals>
    </execution>
    </executions>
    <dependencies>
    <dependency>
    <groupId>com.google.protobuf</groupId>
    <artifactId>protobuf-java</artifactId>
    <version>2.5.0</version>
    </dependency>
    </dependencies>
    </plugin>