/*global module */
module.exports = function (grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),

		jshint: {
			src: [
				"**/*.js", "!{node_modules,ViewStack/transitions}/**", "!**/themes/**", "!*/css/*.js"
			],
			options: {
				jshintrc: ".jshintrc"
			}
		},

		// Task for compiling less files into CSS files
		less : {
			// Compile less code for each widget
			widgets : {
				files: [
					{
						expand: true,
						src: ["*/themes/*/*.less", "list/*/themes/*/*.less", "!**/variables.less",
						      "!{dijit,mobile}/themes/*/*.less", "*/css/*.less",
							 "ViewStack/transitions/*.less"],
						ext: ".css"
					}
				]
			}
		},

		// Convert CSS files to JS files
		cssToJs : {
			src: [
				"*/themes/*/*.css", "list/*/themes/*/*.css",
				"!{dijit,mobile}/themes/*/*.css", "ViewStack/transitions/*.css"
			],
			options: {
				remove: true	// remove intermediate CSS files, generated from LESS files in less step
			}
		},

		// Copied from grunt web site but not tested
		uglify: {
			options: {
				banner: "/*! <%= pkg.name %> <%= grunt.template.today('yyyy-mm-dd') %> */\n"
			},
			build: {
				src: "src/<%= pkg.name %>.js",
				dest: "build/<%= pkg.name %>.min.js"
			}
		},
		
		intern: {
			local: {
				options: {
					runType: "runner",
					config: "tests/intern.local",
					reporters: ["runner"]
				}
			},
			"local.android": {
				options: {
					runType: "runner",
					config: "tests/intern.local.android",
					reporters: ["runner"]
				}
			},
			"local.ios": {
				options: {
					runType: "runner",
					config: "tests/intern.local.ios",
					reporters: ["runner"]
				}
			},
			remote: {
				options: {
					runType: "runner",
					config: "tests/intern",
					reporters: ["runner"]
				}
			}
		},
		
		"jsdoc-amddcl": {
			deliteful: {
				files: [
					{
						args: [
							"-c",
							"./node_modules/jsdoc-amddcl/conf.json"
						],
						src: [
							".",
							"./README.md",
							"./package.json"
						],
						imports: [
							"../delite/out"
						]
					},
					{
						args: [
							"-X",
							"-c",
							"./node_modules/jsdoc-amddcl/conf.json"
						],
						src: [
							".",
							"./README.md",
							"./package.json"
						],
						dest: "./out/doclets.json",
						imports: [
							"../delite/out"
						]
					}
				]
			}
		}
	});

	// Load plugins
	grunt.loadNpmTasks("intern");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-less");
	grunt.loadNpmTasks("grunt-contrib-uglify");
	grunt.loadNpmTasks("jsdoc-amddcl");
	grunt.loadTasks("../delite/themes/tasks");// Custom cssToJs task to convert CSS to JS

	// Aliases
	grunt.registerTask("default", ["less", "cssToJs"]);
	grunt.registerTask("jsdoc", "jsdoc-amddcl");
	
	// Testing.
	// always specify the target e.g. grunt test:remote, grunt test:remote
	// then add on any other flags afterwards e.g. console, lcovhtml
	var testTaskDescription = "Run this task instead of the intern task directly! \n" +
		"Always specify the test target e.g. \n" +
		"grunt test:local\n" +
		"grunt test:local.android\n" +
		"grunt test:local.ios\n" +
		"grunt test:remote\n\n" +
		"Add any optional reporters via a flag e.g. \n" +
		"grunt test:local:console\n" +
		"grunt test:local:lcovhtml\n" +
		"grunt test:local:console:lcovhtml";
	grunt.registerTask("test", testTaskDescription, function (target) {
		function addReporter(reporter) {
			var property = "intern." + target + ".options.reporters",
				value = grunt.config.get(property);
			if (value.indexOf(reporter) !== -1) {
				return;
			}
			value.push(reporter);
			grunt.config.set(property, value);
		}
		if (this.flags.lcovhtml) {
			addReporter("lcovhtml");
		}

		if (this.flags.console) {
			addReporter("console");
		}
		grunt.task.run("intern:" + target);
	});
};
@@ -1821,16 +1821,11 @@
 %09%09%09d
-eliteful
+ocs
 : %7B%0A
@@ -1848,91 +1848,8 @@
 %09%09%7B%0A
-%09%09%09%09%09%09args: %5B%0A%09%09%09%09%09%09%09%22-c%22,%0A%09%09%09%09%09%09%09%22./node_modules/jsdoc-amddcl/conf.json%22%0A%09%09%09%09%09%09%5D,%0A
 %09%09%09%09
@@ -1982,102 +1982,78 @@
 %09%09%09%7D
-,
 %0A%09%09%09%09
-%09%7B
+%5D
 %0A%09%09%09
-%09%09%09args: %5B
+%7D,%0A%09%09%09export: %7B
 %0A%09%09%09%09
-%09%09%09%22-X%22,%0A%09%09%09%09%09%09%09%22-c%22,%0A%09%09%09%09%09%09%09%22./node_modules/jsdoc-amddcl/conf.json
+files: %5B%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09args: %5B%0A%09%09%09%09%09%09%09%22-X
 %22%0A%09%09

Change upon jsdoc-amddcl/pull/23 and more cleanup.