Is it possible to compile grunt project from maven?

后端 未结 9 1288
滥情空心
滥情空心 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:28

    Can be done with exec-maven-plugin.

    Define a script and dependency to grunt-cli in your package.json:

    ...
      "scripts": {
        "build": "./node_modules/.bin/grunt install"
      },
      "devDependencies": {
      "grunt-cli": "^1.2.0",
    ...
    

    In your pom, add the commands to run:

            
                org.codehaus.mojo
                exec-maven-plugin
                X.Y.Z
                
                    
                        exec-npm-install
                        generate-sources
                        
                            ${project.basedir}
                            npm
                            
                                install
                            
                        
                        
                            exec
                        
                    
                    
                        exec-grunt-install
                        generate-sources
                        
                            ${project.basedir}
                            npm
                            
                                run
                                build
                            
                        
                        
                            exec
                        
                    
                
            
    

    It will now run on mvn package

提交回复
热议问题