How do I get Eclipse to resolve classes generated with Maven 2?

前端 未结 9 885
日久生厌
日久生厌 2020-12-12 22:11

I\'m using Google Protocol Buffers to generate some Java classes for my project. Using Maven 2 and its \"antrun\" plugin, these classes are freshly generated before compile,

9条回答
  •  天命终不由人
    2020-12-12 22:25

    m2eclipse supports this. First, add the path to your build path:

    
        org.codehaus.mojo
        build-helper-maven-plugin
        1.8
        
            
                add-source
                generate-sources
                
                    add-source
                
                
                    
                        ${project.build.directory}/generated-sources/java/
                    
                
            
        
    
    

    Second, add support for that to m2e:

    
        
            
                org.eclipse.m2e
                lifecycle-mapping
                1.0.0
                
                    
                          
                            
                              
                                org.codehaus.mojo
                                build-helper-maven-plugin
                                [1.0,)
                                
                                  parse-version
                                  add-source
                                  maven-version
                                  add-resource
                                  add-test-resource
                                  add-test-source
                                
                              
                              
                                
                                  true
                                  true
                                
                              
                            
                        
                    
                
            
        
    
    

    The second step might not be necessary, if your eclipse installation has installed the "org.eclipse.m2e.discovery.lifecyclemapping.buildhelper.xml" plugin. This plugin is available via Window -> Preferences -> Maven -> Discovery. Currently, that does not work here at Eclipse Kepler, therefore, I fetched the JAR (linked from the xml shown in the Catalog URL) and extracted the fragments from org.eclipse.m2e.discovery.lifecyclemapping.buildhelper.xml by hand.

提交回复
热议问题