|
| 1 | +module.exports = function(grunt) { |
| 2 | + |
| 3 | + /** |
| 4 | + * The directory used to produce outputs. |
| 5 | + * |
| 6 | + * @property {String} |
| 7 | + */ |
| 8 | + var TARGET_DIRECTORY = 'target'; |
| 9 | + |
| 10 | + grunt.initConfig( |
| 11 | + { |
| 12 | + |
| 13 | + /** |
| 14 | + * Reads the 'package.json' file and puts it content into a 'pkg' Javascript object. |
| 15 | + */ |
| 16 | + pkg : grunt.file.readJSON('package.json'), |
| 17 | + |
| 18 | + /** |
| 19 | + * Clean task. |
| 20 | + */ |
| 21 | + clean : ['target'], |
| 22 | + |
| 23 | + /** |
| 24 | + * Copy task. |
| 25 | + */ |
| 26 | + copy : { |
| 27 | + |
| 28 | + /** |
| 29 | + * Copy test resource files to the target. |
| 30 | + */ |
| 31 | + 'test-resources' : { |
| 32 | + files : [ |
| 33 | + { |
| 34 | + cwd: 'src/test/resources', |
| 35 | + expand: true, |
| 36 | + src: '**', |
| 37 | + dest: 'target/test-resources/' |
| 38 | + } |
| 39 | + ] |
| 40 | + } |
| 41 | + |
| 42 | + }, /* Copy task */ |
| 43 | + |
| 44 | + /** |
| 45 | + * PHPDocumentor Task. |
| 46 | + */ |
| 47 | + phpdocumentor : { |
| 48 | + |
| 49 | + options : { |
| 50 | + directory : 'src/main/php', |
| 51 | + target : 'target/reports/phpdocumentor' |
| 52 | + }, |
| 53 | + |
| 54 | + /** |
| 55 | + * Target used to generate the PHP documentation of the project. |
| 56 | + */ |
| 57 | + generate : {} |
| 58 | + |
| 59 | + }, /* PHPDocumentor Task */ |
| 60 | + |
| 61 | + /** |
| 62 | + * PHPUnit Task. |
| 63 | + */ |
| 64 | + phpunit : { |
| 65 | + |
| 66 | + classes: { |
| 67 | + dir: 'src/test/php' |
| 68 | + }, |
| 69 | + |
| 70 | + options: { |
| 71 | + configuration : 'phpunit.xml', |
| 72 | + |
| 73 | + // This is used to prevent PHPUnit to fail with a 'zend_mm_heap corrupted' error |
| 74 | + // see: http://stackoverflow.com/questions/14597468/how-to-diagnose-these-php-code-coverage-segmentation-and-zend-mm-heap-corrupted |
| 75 | + d: 'zend.enable_gc=0'//, |
| 76 | + //group : 'PushwooshTest' |
| 77 | + |
| 78 | + } |
| 79 | + |
| 80 | + } /* PHPUnit Task */ |
| 81 | + |
| 82 | + } |
| 83 | + |
| 84 | + ); /* Grunt initConfig call */ |
| 85 | + |
| 86 | + // Load the Grunt Plugins |
| 87 | + grunt.loadNpmTasks('grunt-contrib-clean'); |
| 88 | + grunt.loadNpmTasks('grunt-contrib-copy'); |
| 89 | + grunt.loadNpmTasks('grunt-phpdocumentor'); |
| 90 | + grunt.loadNpmTasks('grunt-phpunit'); |
| 91 | + |
| 92 | + /** |
| 93 | + * Task used to create the project documentation. |
| 94 | + */ |
| 95 | + grunt.registerTask('generate-documentation', ['phpdocumentor:generate' ]); |
| 96 | + |
| 97 | + /** |
| 98 | + * Task used to execute the project tests. |
| 99 | + */ |
| 100 | + grunt.registerTask('test', ['copy:test-resources', 'phpunit']); |
| 101 | + |
| 102 | + /** |
| 103 | + * Default task, this task executes the following actions : |
| 104 | + * - Clean the previous target folder |
| 105 | + */ |
| 106 | + grunt.registerTask('default', ['clean', 'test', 'generate-documentation']); |
| 107 | + |
| 108 | +}; |
0 commit comments