Index: Dev/trunk/Gruntfile.js
===================================================================
--- Dev/trunk/Gruntfile.js	(revision 466)
+++ Dev/trunk/Gruntfile.js	(revision 469)
@@ -2,128 +2,108 @@
  */
 
+var _ = require('underscore');
+
 module.exports = function(grunt) {
 
+    // TASKS
+
+    grunt.registerTask('default', ['compile']);
+    grunt.registerTask('compile', ['jshint:lint-sources'
+                                  ,'htmlhint:lint'
+                                  ,'coffeelint:lint'
+                                  ,'less:compile'
+                                  ,'usebanner:generated-css'
+                                  ,'coffee:compile'
+                                  ,'usebanner:generated-js'
+                                  ,'jshint:lint-generated'
+                                  //,'amd-check' // too smart about plugins, r.js can't find them
+                                  ]);
+    grunt.registerTask('build', ['clean:build'
+                                ,'copy:build'
+                                ,'dojo:build'
+                                ]);
+    grunt.registerTask('deploy', []);
+
+    // FILES AND FOLDERS
+    
     var srcDir   = 'src/';
     var buildDir = 'build/';
-    var developmentDir = buildDir+'development/';
-    var productionDir = buildDir+'production/';
+    var coffeeMap = grunt.file.expandMapping(
+        [ 'client/qed-client/**/*.coffee', 'server/**/*.coffee' ],
+        srcDir,
+        { cwd: srcDir, ext: '.js' });
+    var lessMap = grunt.file.expandMapping(
+        [ 'client/qed-client/css/qed.less' ],
+        srcDir,
+        { cwd: srcDir, ext: '.css' });
 
+    // TASK CONFIG
+    
     grunt.initConfig({
+        'amd-check': {
+            files: [ srcDir+'client/qed-client/**/*.js' ]
+        },
         clean: {
-            development: {
-                src: [developmentDir]
-            },
-            production: {
-                src: [productionDir]
-            }
+            build: { src: [buildDir] }
         },
         coffee: {
-            options: {
-                bare: true
-            },
-            compile: {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['client/qed-client/**/*.coffee', 'server/**/*.coffee'],
-                    dest: developmentDir,
-                    ext: '.js'
-                }]
-            }
+            options: { bare: true },
+            compile: { files: coffeeMap }
         },
         coffeelint: {
-            compile: {
-                options: require('./'+srcDir+'.coffeelint.json'),
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['client/qed-client/**/*.coffee', 'server/**.coffee']
-                }]
-            }
+            lint: { options: require('./'+srcDir+'.coffeelint.json'),
+                    files: coffeeMap }
         },
         copy: {
-            'client-deps': {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['client/dojo/**', 'client/dijit/**', 'client/dojox/**', 'client/util/**'],
-                    dest: developmentDir
-                }]
-            },
-            'server-deps': {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['node_modules/**'],
-                    dest: developmentDir
-                }]
-            },
-            compile: {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['**', '!**/*.coffee', '!**/*.less', '!node_modules/**', '!client/dojo/**', '!client/dijit/**', '!client/dojox/**', '!client/util/**' ],
-                    dest: developmentDir
-                }]
-            },
-            deploy: {
-                files: [{
-                    expand: true,
-                    cwd: developmentDir,
-                    src: ['**', '!client/*/**' ],
-                    dest: productionDir
-                }]
-            }
+            build: { files: [{ expand: true,
+                               cwd: srcDir,
+                               src: ['**', '!client/*/**' ],
+                               dest: buildDir }]}
         },
         dojo: {
-            deploy: {
-                options: {
-                    dojo: developmentDir+'client/dojo/dojo.js',
-                    profile: developmentDir+'client/client.profile.js',
-                    releaseDir: '../../../'+productionDir
-                }
-            }
+            build: { options: { dojo: srcDir+'client/dojo/dojo.js',
+                                profile: srcDir+'client/client.profile.js',
+                                releaseDir: '../../../'+buildDir }}
         },
         htmlhint: {
-            options: {
-                htmlhintrc: srcDir+".htmlhintrc"
-            },
-            compile: {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['client/*.html', 'client/qed-client/**/*.html']
-                }]
-            }
+            options: { htmlhintrc: srcDir+".htmlhintrc" },
+            lint: { files: [{ expand: true,
+                              cwd: srcDir,
+                              src: ['client/*.html', 'client/qed-client/**/*.html'] }]}
         },
         jshint: {
-            options: {
-                jshintrc: srcDir+".jshintrc"
-            },
-            compile: {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['client/qed-client/**/*.js', 'server/**.js']
-                }]
-            }
+            'lint-sources': { options: { jshintrc: srcDir+".jshintrc" },
+                              files: { src: [ srcDir+'client/qed-client/**/*.js', srcDir+'server/**/*.js' ].concat(exclude(dest(coffeeMap))) }},
+            'lint-generated': { options: { jshintrc: srcDir+".jshintrc-generated" },
+                                files: { src: dest(coffeeMap) }}
         },
         less: {
-            options: {
-                strictImports: false,
-                dumpLineNumbers: "all"
-            },
-            compile: {
-                files: [{
-                    expand: true,
-                    cwd: srcDir,
-                    src: ['client/qed-client/css/qed.less'],
-                    dest: developmentDir,
-                    ext: '.css'
-                }]
-            }
+            options: { strictImports: false,
+                       dumpLineNumbers: "all" },
+            compile: { files: lessMap }
+        },
+        requirejs: {
+            basePath: srcDir+'client/',
+            packages: [
+                { name: "dojo", location: "dojo" },
+                { name: "dijit", location: "dijit" },
+                { name: "dojox", location: "dojox" },
+                { name: "qed-client", location: "qed-client" }
+            ]
+        },
+        usebanner: {
+            'generated-css': { options: { position: 'top',
+                                          banner: '/* This CSS file is generated. All edits will be lost on recompile. */'},
+                               files: { src: dest(lessMap) }},
+            'generated-js': { options: { position: 'top',
+                                         banner: '/* This JS file is generated, All edits will be lost on recompile. */'},
+                               files: { src: dest(coffeeMap) }}
         }
     });
 
+    // LOAD TASKS
+
+    grunt.loadNpmTasks('grunt-amd-check');
+    grunt.loadNpmTasks('grunt-banner');
     grunt.loadNpmTasks('grunt-coffeelint');
     grunt.loadNpmTasks('grunt-contrib-clean');
@@ -134,18 +114,18 @@
     grunt.loadNpmTasks('grunt-dojo');
     grunt.loadNpmTasks('grunt-htmlhint');
+    grunt.loadTasks('./grunt-tasks');
 
-    // development tasks
-    grunt.registerTask('install-deps', ['copy:server-deps', 'copy:client-deps']);
-    grunt.registerTask('lint', ['jshint:compile', 'htmlhint:compile', 'coffeelint:compile']);
-    grunt.registerTask('compile', ['lint', 'less:compile', 'coffee:compile', 'copy:compile']);
-    grunt.registerTask('build', ['clean:development', 'install-deps', 'compile']);
+    // UTIL FUNCTIONS
 
-    // production tasks
-    grunt.registerTask('deploy', ['clean:production', 'copy:deploy', 'dojo:deploy']);
+    function dest(files) {
+        return _.chain(files)
+            .map(function(item){ return item.dest; })
+            .flatten()
+            .value();
+    }
 
-    // default task is quick compile
-    grunt.registerTask('default', ['compile']);
-
-    // util functions
-
+    function exclude(dest) {
+        return _.map(dest, function(dest){ return '!'+dest; });
+    }
+    
 };
