2014-02-17 4 views
0

Привет, я работаю с ворчанием и Maven.grunt не работает с использованием плагина maven

используется плагин для запуска Grunt

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.2.1</version> 
    <executions> 
     <execution> 
      <phase>${basedir}/scripts/gruntFiles</phase> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <executable>grunt</executable> 
    </configuration> 
</plugin> 

этот плагин не работает, чтобы начать хрюкать, когда я запустить Maven проекта.

Grunt файл: -

var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest; 

module.exports = function (grunt) { 
    require('load-grunt-tasks')(grunt); 
    require('time-grunt')(grunt); 

    grunt.initConfig({ 
     yeoman: { 
      // configurable paths 
      app: require('./bower.json').appPath || 'app', 
      dist: 'src/main/webapp/resources/dist' 
     }, 
     watch: { 
      compass: { 
       files: ['src/main/scss/{,*/}*.{scss,sass}'], 
       tasks: ['compass:server', 'autoprefixer'] 
      }, 
      styles: { 
       files: ['src/main/webapp/styles/{,*/}*.css'], 
       tasks: ['copy:styles', 'autoprefixer'] 
      }, 
      livereload: { 
       options: { 
        livereload: 35729 
       }, 
       files: [ 
        'src/main/webapp/resources/scripts/rrh/authoring/basket_app/directives/templates/*.html', 
        '.tmp/styles/**/*.css', 
        '{.tmp/,}src/main/webapp/resources/scripts/**/*.js', 
        'src/main/webapp/resources/images/**/*.{png,jpg,jpeg,gif,webp,svg}' 
       ] 
      } 
     }, 

     pkg: grunt.file.readJSON('package.json'), 

     // Define our source and build folders 
     js_directives_path_rrh_ui: "../rrh/rrh-ui/directives", 
     js_src_path_home_rrh: "../rrh", 

     //output folder path 
     js_output_folder_path: "../gruntOutputFiles", 

     // Grunt Tasks 
     concat: { 
      options:{ 
       separator: ';', 
       mangle: false, 
       compress: true, linenos: false, 
      }, 
      // used for home page internal js files 
      js: { 
       src: ['<%= js_src_path_home_rrh %>/common/rrh-common.js', 
         '<%= js_src_path_home_rrh %>/rrh-ui/directives/RrhUiDirectives.js' 
        ], 
       dest: '<%= js_output_folder_path %>/home_app.js' 
      }, 
     }, 
     uglify: { 
      options:{ 
       mangle: false, 
       compress: true, linenos: false, 
       banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version + "\\n" %>' 
      }, 
      // used for home page internal js files 
      js: { 
       src: '<%= concat.js.dest %>', 
       dest:'<%= js_output_folder_path %>/home_app.min.js' 
      }, 
     }); 

    grunt.loadNpmTasks('grunt-contrib-uglify'); 
    grunt.loadNpmTasks('grunt-contrib-concat'); 

    grunt.registerTask('server', function (target) { 
     grunt.task.run([ 
      'concat', 
      'uglify', 
      'watch' 
     ]); 
    }); 

    grunt.registerTask('build', [ 
     'concat', 
     'uglify', 
    ]); 

    grunt.registerTask('default', [ 
     'build' 
    ]); 
}; 

Пожалуйста, помогите запустить его ..

+1

Что значит «не работает»? Кроме того, я уверен, что конфигурация неверна. Он должен быть одним из фаз жизненного цикла Maven: http://maven.apache.org/ref/3.1.1/maven-core/lifecycles.html –

+0

Не только уверен, что ваше определение ' ..' просто неправильно. – khmarbaise

+0

да, вы обряд ... что это должно быть? пожалуйста, сделайте это правильно –

ответ

1

вот статья, которая описывает, как настроить Maven для работы с ворчанием: http://addyosmani.com/blog/making-maven-grunt/

также включает в себя пример сценария установки:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.2.1</version> 
    <executions> 
    <execution> 
     <phase>prepare-package</phase> 
     <goals> 
     <goal>exec</goal> 
     </goals> 
    </execution> 
    </executions> 
    <configuration> 
    <executable>grunt</executable> 
    </configuration> 
</plugin> 
0

По моему опыту, плагин frontend maven - это лучший плагин для этого типа процесса сборки/развертывания. https://github.com/eirslett/frontend-maven-plugin.

<plugin> 
    <groupId>com.github.eirslett</groupId> 
    <artifactId>frontend-maven-plugin</artifactId> 
    <version>...</version> 

    <!-- optional --> 
    <configuration> 
     <workingDirectory>src/main/frontend</workingDirectory> 
    </configuration> 

    <execution> 
    <id>grunt build</id> 
    <goals> 
     <goal>grunt</goal> 
    </goals> 

    <!-- optional: the default phase is "generate-resources" --> 
    <phase>generate-resources</phase> 

    <configuration> 
     <!-- optional: if not specified, it will run Grunt's default 
     task (and you can remove this whole <configuration> section.) --> 
     <arguments>build</arguments> 
    </configuration> 
</execution> 
</plugin> 

Одна вещь, чтобы быть в курсе этого является загрузит узел для системы она выполняется на, так что если у вас есть другой ОС на сервере сборки, вам необходимо убедиться, что это версия вы проверили управление версиями, ваша локальная версия (для меня OSX) должна поддерживаться локально в вашем проекте.

Смежные вопросы