Is it possible to compile grunt project from maven?

后端 未结 9 1305
滥情空心
滥情空心 2021-01-30 16:55

I\'m trying to execute grunt tasks from within maven without needing to install Node.js or anything. This is because I wan\'t my artifact to be packaged by Jenkins and I can\'t

9条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 17:08

    This is a full copy/paste solution which work in 2017 using frontend-maven-plugin for front build, and maven-war-plugin to build the war.

    What it does ? install npm, bower grunt,and everything you need, then run npm install, bower install and finally grunt build.

    You can remove/add replace the steps you want, for me it's a full 30 sec install/build library and project.

    
      ...
    
    
    
        
            
            
                com.github.eirslett
                frontend-maven-plugin
            
        
    
    
    
        
            
                
                    org.apache.maven.plugins
                    maven-war-plugin
                    2.4
                    
                        src/main/webapp/YourFrontJsFolder/dist
                        YouWarName
                        false
                        node_modules/**
                        system
                        
                            
                                WebContent/WEB-INF
                                WEB-INF
                                
                                    **/*.jar
                                    **/*.jsp
                                
                            
                        
                    
                
    
                
                    org.apache.maven.plugins
                    maven-compiler-plugin
                    3.3
                    
                        1.7
                        1.7
                        Cp1252
                    
                
            
        
    
        YourAppName
    
    
    
        
            release
            
                
                    
                        com.github.eirslett
                        frontend-maven-plugin
                        
                            
                                
                                install node and npm
                                
                                    install-node-and-npm
                                
                                
                                generate-resources
    
                                
                                    v7.6.0
                                
                            
    
                            
                                npm install
                                
                                    npm
                                
    
                                
                                generate-resources
    
                                
                                    install
                                
                            
    
                            
                                bower install
                                
                                    bower
                                
    
                                
                                    
                                    install
                                
                            
    
                            
                                grunt build
                                
                                    grunt
                                
    
                                
                                generate-resources
    
                                
                                    
                                    build
                                
                            
                        
    
                        
                            target
                            src/main/webapp/YourFrontJsFolder
                        
                    
                
            
        
        
            debug
            
                true
            
        
        
            IDE
            
                
                    m2e.version
                
            
            
                
                target-ide
            
        
    
    

    Then you can Run as -> Maven build ..., with goal clean install and profile release

提交回复
热议问题