Gruntfile.js revision 5003b4008868032decd27b09f87bc1222ce1b783
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg/**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * The contents of this file are subject to the terms of the Common Development and
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Distribution License (the License). You may not use this file except in compliance with the
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * License.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg *
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * specific language governing permission and limitations under the License.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg *
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * When distributing Covered Software, include this CDDL Header Notice in each file and include
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Header, with the fields enclosed by brackets [] replaced by your own identifying
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * information: "Portions copyright [year] [name of copyright owner]".
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg *
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copyright 2015 ForgeRock AS.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg/* global module, require, process */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgvar _ = require("lodash"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenSrcPath = "/src/main/js";
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgfunction mavenProjectSource (projectDir) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg projectDir + mavenSrcPath,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg projectDir + "/src/main/resources"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ];
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg}
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgfunction mavenProjectTestSource (projectDir) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg projectDir + "/src/test/js",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg projectDir + "/src/test/resources"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ];
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg}
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgmodule.exports = function (grunt) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg var compositionDirectory = "target/composed",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compiledDirectory = "target/compiled",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg forgeRockCommonsDirectory = process.env.FORGEROCK_UI_SRC + "/forgerock-ui-commons",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg forgeRockUiDirectory = process.env.FORGEROCK_UI_SRC + "/forgerock-ui-user",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg amCommonsDirectory = "../openam-ui-common",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg targetVersion = grunt.option("target-version") || "dev",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg buildCompositionDirs = _.flatten([
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "target/dependencies",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg // When building, dependencies are downloaded and expanded by Maven
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "target/dependencies-expanded/forgerock-ui-user",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "target/dependencies-expanded/openam-ui-common",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg // This must come last so that it overwrites any conflicting files!
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectSource(".")
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg watchCompositionDirs = _.flatten([
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg // When watching, we want to get the dependencies directly from the source
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectSource(forgeRockCommonsDirectory),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectSource(forgeRockUiDirectory),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectSource(amCommonsDirectory),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg // This must come last so that it overwrites any conflicting files!
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectSource(".")
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg testInputDirectory = _.flatten([
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compiledDirectory,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectTestSource("."),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mavenProjectTestSource(amCommonsDirectory),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "target/test-classes/lib"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg nonCompiledFiles = [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.html",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.ico",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.json",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.png",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.js",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.eot",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.svg",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.woff",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.woff2",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "**/*.otf",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "css/bootstrap-3.3.5-custom.css"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg serverDeployDirectory = process.env.OPENAM_HOME + "/XUI",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg testDeployDirectory = process.env.OPENAM_HOME + "/../openam-test";
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.initConfig({
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg copy: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copy all the sources and resources from this project and all dependencies into the composition directory.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg *
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * TODO: This copying shouldn't really be necessary, but is required because the dependencies are all over
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * the place. If we move to using npm for our dependencies, this can be greatly simplified.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compose: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: buildCompositionDirs.map(function (dir) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg expand: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg cwd: dir,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: ["**"],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: compositionDirectory
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg };
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg })
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copy files that do not need to be compiled into the compiled directory.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compiled: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: [{
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg expand: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg cwd: compositionDirectory,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: nonCompiledFiles.concat([
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "!main.js", // Output by r.js
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "!index.html" // Output by grunt-text-replace
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: compiledDirectory
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }]
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg eslint: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Check the JavaScript source code for common mistakes and style issues.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg lint: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: "." + mavenSrcPath + "/**/*.js",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg options: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg format: require.resolve("eslint-formatter-warning-summary")
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg less: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Compile LESS source code into minified CSS files.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compile: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: compositionDirectory + "/css/styles.less",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: compiledDirectory + "/css/styles.css",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg options: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compress: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg plugins: [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg new (require("less-plugin-clean-css"))({})
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg relativeUrls: true
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Run qunit tests.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg qunit: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg test: testDeployDirectory + "/qunit.html"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg replace: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Include the version of AM in the index file.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg *
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * This is needed to force the browser to refetch JavaScript files when a new version of AM is deployed.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg buildNumber: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: compositionDirectory + "/index.html",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: compiledDirectory + "/index.html",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg replacements: [{
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg from: "${version}",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg to: targetVersion
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }]
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg requirejs: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Concatenate and uglify the JavaScript.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compile: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg options: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg baseUrl: compositionDirectory,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg mainConfigFile: compositionDirectory + "/main.js",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg out: compiledDirectory + "/main.js",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg include: ["main"],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg preserveLicenseComments: false,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg generateSourceMaps: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg optimize: "uglify2",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg // These files are excluded from optimization so that the UI can be customized without having to
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg // repackage it.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg excludeShallow: [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "config/AppConfiguration",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "config/ThemeConfiguration"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Sync is used when watching to speed up the build.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg sync: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copy all the sources and resources from this project and all dependencies into the composition directory.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compose: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: watchCompositionDirs.map(function (dir) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg cwd: dir,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: ["**"],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: compositionDirectory
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg };
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compareUsing: "md5"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copy files that do not need to be compiled into the compiled directory.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg *
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Note that this also copies main.js because the requirejs step is not being performed when watching (it
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * is too slow).
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compiled: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: [{
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg cwd: compositionDirectory,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: nonCompiledFiles.concat([
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "!index.html" // Output by grunt-text-replace
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: compiledDirectory
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compareUsing: "md5"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copy the compiled files to the server deploy directory.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg server: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: [{
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg cwd: compiledDirectory,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: ["**"],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: serverDeployDirectory
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg verbose: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compareUsing: "md5" // Avoids spurious syncs of touched, but otherwise unchanged, files (e.g. CSS)
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copy the compiled files, along with the test source files and dependencies, to the server deploy
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * directory.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg testServer: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: testInputDirectory.map(function (inputDirectory) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg cwd: inputDirectory,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg src: ["**"],
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg dest: testDeployDirectory
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg };
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg verbose: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg compareUsing: "md5" // Avoids spurious syncs of touched, but otherwise unchanged, files (e.g. CSS)
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg watch: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Redeploy whenever any source files change.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg source: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: watchCompositionDirs.map(function (dir) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return dir + "/**";
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg tasks: ["deploy"]
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Deploy and run the tests whenever any source files change.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg test: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg files: watchCompositionDirs.map(function (dir) {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg return dir + "/**";
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg tasks: ["test"]
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg },
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Generates OS notifications when the watch passes or fails.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg notify_hooks: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg options: {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg enabled: true,
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg title: "OpenAM XUI Tests"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg }
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg });
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-contrib-copy");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-contrib-less");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-contrib-qunit");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-contrib-requirejs");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-contrib-watch");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-eslint");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-notify");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-sync");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.loadNpmTasks("grunt-text-replace");
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Resync the compiled directory and deploy and run the tests.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.registerTask("test", [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "sync:compose",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "replace",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "sync:compiled",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "sync:testServer",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "qunit"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Resync the compiled directory and deploy to the web server.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.registerTask("deploy", [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "sync:compose",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "less",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "replace",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "sync:compiled",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "sync:server"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg /**
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Rebuild the compiled directory. Maven then packs this directory into the final archive artefact.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg */
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.registerTask("build", [
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "copy:compose",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "eslint",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "requirejs",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "less",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "replace",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg "copy:compiled"
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg ]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.registerTask("dev", ["copy:compose", "deploy", "watch"]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.registerTask("prod", ["build"]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg grunt.registerTask("default", ["dev"]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg};