Integrate Protocol Buffers into Maven2 build

前端 未结 9 770
悲哀的现实
悲哀的现实 2021-01-30 02:18

I\'m experimenting with Protocol Buffers in an existing, fairly vanilla Maven 2 project. Currently, I invoke a shell script every time I need to update my generated sources. Thi

9条回答
  •  温柔的废话
    2021-01-30 03:02

    The accepted answer encouraged me to get the Google-provided plugin to work. I merged the branch mentioned in my question into a checkout of 2.2.0 source code, built and installed/deployed the plugin, and was able to use it in my project as follows:

      
        
          
            com.google.protobuf.tools
            maven-protoc-plugin
            0.0.1
            
              
                generate-sources
                
                  compile
                
                generate-sources
                
                  ${basedir}/src/main/protobuf/
                  
                    **/*.proto
                  
                
              
            
            
              /usr/local/bin/protoc
            
          
        
      
    

    Note that I changed the plugin's version to 0.0.1 (no -SNAPSHOT) in order to make it go into my non-snapshot thirdparty Nexus repository. YMMV. The takeaway is that this plugin will be usable once it's no longer necessary to jump through hoops in order to get it going.

提交回复
热议问题