Sure thing!

Gruntfile.js:

module.exports = function(grunt){
  
  require('google-closure-compiler').grunt(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    'closure-compiler': {
      my_target: {
        files: {
          'target/full.js': ['js/**.js']
        },
        options: {
          js: [
            'node_modules/google-closure-library/**.js', 
            '!node_modules/google-closure-library/**_test.js', 
            '!node_modules/google-closure-library/**_perf.js', 
            '!node_modules/google-closure-library/**tester.js', 
            
'!node_modules/google-closure-library/**promise/testsuiteadapter.js', 
            '!node_modules/google-closure-library/**osapi/osapi.js', 
            '!node_modules/google-closure-library/**svgpan/svgpan.js', 
            '!node_modules/google-closure-library/**alltests.js', 
            '!node_modules/google-closure-library/**node_modules**.js', 
            '!node_modules/google-closure-library/**protractor_spec.js', 
            '!node_modules/google-closure-library/**protractor.conf.js', 
            
'!node_modules/google-closure-library/**browser_capabilities.js', 
            '!node_modules/google-closure-library/doc/**.js', 
            'node_modules/google-protobuf/**.js',
            'js/missing-google-crap/message.js',
            'js/missing-google-crap/map.js',
            'js/person.js'
          ],
          compilation_level: 'SIMPLE',
          language_in: 'ECMASCRIPT5',
          create_source_map: 'target/full.js.map'
          
        }
      }
    }
  });


  grunt.registerTask('default', ['closure-compiler']);
}


The javascript is generated via Maven, so here is the command we are using:

            <plugin>
                   <groupId>com.github.os72</groupId>
                   <artifactId>protoc-jar-maven-plugin</artifactId>
                   <version>3.0.0</version>
                   <executions>
                       <execution>
                           <phase>generate-sources</phase>
                           <goals>
                               <goal>run</goal>
                           </goals>
                           <configuration>
                               <protocVersion>3.0.0</protocVersion> 
                               <inputDirectories>
                                   <include>src/main/resources/proto</include>
                               </inputDirectories>
                               <outputTargets>
                                   <outputTarget>
                                       <type>java</type>
                                       <addSources>none</addSources>
                                       
<outputDirectory>src/main/gen</outputDirectory>
                                   </outputTarget>
                                   <outputTarget>
                                                                
<type>descriptor</type>
                                        <addSources>none</addSources>
                                        
<outputDirectory>src/main/resources/protoDesc/</outputDirectory>
                                   </outputTarget>
                                   <outputTarget>
                                                <type>js</type>
                                                <addSources>none</addSources>
                                                
<outputDirectory>src/main/resources/js/</outputDirectory>
                                   </outputTarget>
                               </outputTargets>                
                           </configuration>
                       </execution>
                   </executions>
                </plugin>




On Wednesday, February 15, 2017 at 9:40:03 AM UTC-9, Adam Cozzette wrote:
>
> If you could share your gruntfile that would be great. I would be 
> interested to know in particular the protoc command used to generate the 
> Javascript. Also it would be good to verify that the generated code for 
> that proto did not somehow get pulled into the protobuf build and end up 
> being part of the actual protobuf library.
>
> On Wed, Feb 15, 2017 at 9:10 AM, <[email protected] <javascript:>> wrote:
>
>> I've got some javascript generated from protoc and I'm trying to compile 
>> all those files together with closure-compiler so I can use them in a 
>> client app.
>>
>> I'm using Grunt and closure compiler and can provide my gruntfile and 
>> generated javascript if it would help.
>>
>> My problem is that the closure compiler gives me a namespace error for 
>> each type defined in the protobuf.
>>
>> ERROR - namespace 
>> "proto.gov.noaa.alaskafisheries.demoperson.protos.Person" cannot be 
>> provided twice
>> goog.provide('proto.gov.noaa.alaskafisheries.demoperson.protos.Person');
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> And so on for each type defined in the .proto.
>>
>> So far as I can tell these are only provided once in the generated file, 
>> and I've pared down my compilation attempt to that single file + the 
>> closure library and protobuf library files.
>>
>> I've googled the heck out of it and I'm stumped.  I've gotten everything 
>> working with https://github.com/dcodeIO/ProtoBuf.js/ but I'd like to be 
>> able to use google's generated code rather than bring in another library 
>> just for the javascript client.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to