Commit f08ae561 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Merge branch 'new-build-system'

libarsnova-js now utilizes Grunt to perform builds, NPM for development
dependencies and Bower for browser dependencies. Maven builds are no
longer possible. Additionally the directory tree has been flattened.

The new build system supports builds using grunt-amd-build instead of
the Dojo build system which includes the RequireJS loader instead of
Dojo's. It is also possible preforming builds w/o a loader at all.
parents cedc3964 b6c8c9bf
/.classpath
/.project
/.settings
/bower_components
/build
/node_modules
/target
[submodule "vendor/dojotoolkit.org/dojo"]
path = vendor/dojotoolkit.org/dojo
url = https://github.com/dojo/dojo.git
[submodule "vendor/dojotoolkit.org/util"]
path = vendor/dojotoolkit.org/util
url = https://github.com/dojo/util.git
[submodule "vendor/sitepen.com/dstore"]
path = vendor/sitepen.com/dstore
url = https://github.com/SitePen/dstore.git
/* global module: true */
module.exports = function (grunt) {
"use strict";
// The final output directory.
var outdir = "build/";
// A temporary directory used by amdserialize to output the processed modules.
var tmpdir = outdir + "tmp/";
// The grunt.config property populated by amdserialize, containing the
// list of files to include in the layer.
var outprop = "amdoutput";
// The requirejs baseUrl.
var baseUrl = "./";
grunt.initConfig({
// The loader config should go here.
amdloader: {
baseUrl: baseUrl,
// Enable build of requirejs-text/text
inlineText: true,
// Here goes the config for the amd plugins build process (has, i18n, ecma402...).
config: {
},
packages: [
{
name: "dojo",
location: "bower_components/dojo"
},
{
name: "dstore",
location: "bower_components/dstore"
},
{
name: "libarsnova",
location: "src"
}
]
},
// The common build config
amdbuild: {
// dir is the output directory.
dir: tmpdir,
// List of plugins that the build should not try to resolve at build time.
runtimePlugins: [],
// List of layers to build.
layers: [{
name: "libarsnova/libarsnova",
include: [
"dojo/_base/window",
"dojo/request/xhr",
"dojo/selector/_loader",
"libarsnova/audienceQuestion",
"libarsnova/auth",
"libarsnova/feedback",
"libarsnova/lecturerQuestion",
"libarsnova/session",
"libarsnova/socket"
],
includeShallow: [
// Only the modules listed here (ie. NOT their dependencies) will be added to the layer.
],
exclude: [
// Modules and layers listed here, and their dependencies, will NOT be in the layer.
],
excludeShallow: [
// Only the modules listed here (ie. NOT their dependencies) will NOT be in the layer.
]
}]
},
amdreportjson: {
dir: outdir
},
dojo: {
dist: {
options: {
dojo: tmpdir + "builddeps/dojo/dojo.js",
profile: "build.profile.js",
package: ".",
releaseDir: tmpdir
}
}
},
// Erase previous build.
clean: {
build: [outdir],
tmp: [tmpdir]
},
// Copy the plugin files to the real output directory.
copy: {
plugins: {
expand: true,
cwd: tmpdir,
src: "<%= " + outprop + ".plugins.rel %>",
dest: outdir,
dot: true
},
dojoreport: {
expand: true,
cwd: tmpdir,
src: "build-report.txt",
dest: outdir
}
},
symlink: {
dojo: {
files: [
{
src: "bower_components/dojo",
dest: tmpdir + "builddeps/dojo"
},
{
src: "node_modules/dojo-util",
dest: tmpdir + "builddeps/util"
}
]
}
},
// Config to allow uglify to generate the layer.
uglify: {
options: {
sourceMap: true
},
amd: {
options: {
banner: "<%= " + outprop + ".header%>"
},
src: "<%= " + outprop + ".modules.abs %>",
dest: outdir + "libarsnova.js"
},
requirejs: {
options: {
banner: "<%= " + outprop + ".header%>"
},
src: ["bower_components/requirejs/require.js", "<%= " + outprop + ".modules.abs %>"],
dest: outdir + "libarsnova.js"
},
dojo: {
src: tmpdir + "libarsnova/libarsnova.js",
dest: outdir + "libarsnova.js"
}
},
jshint: {
src: [
"*.js",
"src/**/*.js",
"tests/**/*.js"
],
options: {
jshintrc: ".jshintrc"
}
},
shell: {
bowerdeps: {
command: [
"bower install",
"bower update"
].join(";")
}
}
});
// The main build task.
grunt.registerTask("amdbuild", function (amdloader) {
var name = this.name,
layers = grunt.config(name).layers,
uglifyTask = grunt.config("amdbuild").includeLoader ? "requirejs" : "amd"
;
layers.forEach(function (layer) {
grunt.task.run("amddepsscan:" + layer.name + ":" + name + ":" + amdloader);
grunt.task.run("amdserialize:" + layer.name + ":" + name + ":" + amdloader + ":" + outprop);
grunt.task.run("uglify:" + uglifyTask);
grunt.task.run("copy:plugins");
});
});
grunt.registerTask("includerequirejs", function (amdloader) {
grunt.config("amdbuild.includeLoader", true);
});
grunt.registerTask("build", function (amdloader) {
grunt.log.writeln("Please use one of the following tasks to build libarsnova:");
grunt.log.writeln("* build:dojo This build includes the Dojo loader [default]");
grunt.log.writeln("* build:requirejs This build includes the RequireJS loader");
grunt.log.writeln("* build:amd This build includes no loader");
});
grunt.loadNpmTasks("grunt-amd-build");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-symlink");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-dojo");
grunt.loadNpmTasks("grunt-shell");
grunt.registerTask("build:amd", ["clean", "jshint", "shell:bowerdeps", "amdbuild:amdloader", "amdreportjson:amdbuild", "clean:tmp"]);
grunt.registerTask("build:requirejs", ["includerequirejs", "build:amd"]);
grunt.registerTask("build:dojo", ["clean", "jshint", "shell:bowerdeps", "symlink:dojo", "dojo:dist", "uglify:dojo", "copy:dojoreport", "clean:tmp"]);
grunt.registerTask("default", ["build:dojo"]);
};
{
"name": "libarsnova-js",
"version": "1.0.0-alpha",
"description": "libarsnova is a client library for the Audience Response System ARSnova which transparently handles communication with the backend API.",
"authors": [
"Daniel Gerhardt <code@dgerhardt.net>"
],
"license": "LGPL-3.0+",
"keywords": [
"arsnova",
"education",
"classroom",
"audience",
"response",
"system",
"feedback",
"voting",
"survey",
"poll",
"question",
"peer",
"instruction",
"rest",
"websocket"
],
"ignore": [
"**/.*",
"bower_components",
"node_modules",
"tests",
"vendor"
],
"dependencies": {
"dojo": "1.10",
"dstore": "master",
"requirejs": "2.1"
}
}
/* Dojo application profile for production */
var profile = (function () {
"use strict";
var dojoPath = "vendor/dojotoolkit.org/";
var versionFilePath = "target/tmp/dojo/version/";
return {
basePath: "../../..",
basePath: "./",
action: "release",
mini: true,
layerOptimize: "closure",
layerOptimize: false,
cssOptimize: "comments",
stripConsole: "all",
selectorEngine: "lite",
defaultConfig: {
async: true,
baseUrl: "app/",
paths: {
"dojo": "../lib/dojotoolkit.org/dojo",
"dstore": "../lib/sitepen.com/dstore"
},
baseUrl: "src",
hasCache: {
"config-selectorEngine": "lite"
}
......@@ -29,38 +21,31 @@ var profile = (function () {
packages: [
{
name: "dojo",
location: dojoPath + "dojo"
location: "bower_components/dojo"
},
{
name: "dstore",
location: "vendor/sitepen.com/dstore"
},
{
name: "arsnova-api",
location: "src/main/websources/lib/thm.de/arsnova/api"
},
{
name: "arsnova-api-version",
location: versionFilePath,
main: "version"
location: "bower_components/dstore"
}
],
layers: {
"dojo/dojo": {
"dojo/dojo":{
customBase: true,
include: []
},
"libarsnova/libarsnova": {
customBase: true, // do not add dojo/main automatically
boot: true,
include: [
"dojo/request/xhr",
"arsnova-api/audienceQuestion",
"arsnova-api/auth",
"arsnova-api/feedback",
"arsnova-api/lecturerQuestion",
"arsnova-api/session",
"arsnova-api/socket",
"arsnova-api-version"
"libarsnova/audienceQuestion",
"libarsnova/auth",
"libarsnova/feedback",
"libarsnova/lecturerQuestion",
"libarsnova/session",
"libarsnova/socket"
]
}
},
......
......@@ -20,12 +20,10 @@ var dojoConfig = {
<script>
require(
[
"arsnova-api-version",
"arsnova-api/globalConfig",
"arsnova-api/auth"
"libarsnova/globalConfig",
"libarsnova/auth"
],
function (version, globalConfig, auth) {
console.log("version", version);
function (globalConfig, auth) {
console.log("globalConfig", globalConfig.get());
console.log("services", auth.getServices());
}
......
{
"name": "libarsnova",
"version": "1.0.0-alpha",
"description": "libarsnova is a client library for the Audience Response System ARSnova which transparently handles communication with the backend API.",
"author": {
"name": "Daniel Gerhardt",
"email": "code@dgerhardt.net",
"url": "http://dgerhardt.net"
},
"license": "LGPL-3.0+",
"keywords": [
"arsnova",
"education",
"classroom",
"audience",
"response",
"system",
"feedback",
"voting",
"survey",
"poll",
"question",
"peer",
"instruction",
"rest",
"websocket"
],
"repository": {
"type": "git",
"url": "https://github.com/thm-projects/libarsnova-js.git"
},
"directories": {
"lib": "src",
"example": "examples"
},
"devDependencies": {
"bower": "~1",
"dojo-util": "git://github.com/dojo/util.git#1.10.1",
"grunt": "~0.4.5",
"grunt-amd-build": "~0.7.6",
"grunt-dojo": "0.3",
"grunt-contrib-clean": "0.6",
"grunt-contrib-copy": "0.6",
"grunt-contrib-jshint": "0.10",
"grunt-contrib-symlink": "0.3",
"grunt-contrib-uglify": "0.6",
"grunt-shell": "0.7",
"intern": "2.1"
},
"dojoBuild": "src/libarsnova.profile.js"
}
......@@ -4,10 +4,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.thm.arsnova</groupId>
<artifactId>libarsnova-js</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0-alpha</version>
<packaging>war</packaging>
<name>libarsnova-js</name>
<description>libarsnova-js is a client library for JavaScript applications handling the communication (REST and Socket.IO) with the ARSnova backend.</description>
<description>libarsnova-js is a JavaScript client library for the Audience Response System ARSnova which transparently handles communication with the backend API.</description>
<url>http://link.audience-response.org/libarsnova-js-website</url>
<inceptionYear>2013</inceptionYear>
......@@ -29,7 +29,7 @@
<role>architect</role>
<role>developer</role>
</roles>
<url>http://www.dgerhardt.net</url>
<url>http://dgerhardt.net</url>
<email>code@dgerhardt.net</email>
</developer>
</developers>
......@@ -47,19 +47,6 @@
<sonar.language>js</sonar.language>
</properties>
<repositories>
<repository>
<id>thmrepo</id>
<name>THM Maven Repository</name>
<url>http://maven.mni.thm.de/content/repositories</url>
</repository>
<repository>
<id>thmreposnapshots</id>
<name>THM Maven Snapshot Repository</name>
<url>http://maven.mni.thm.de/content/repositories/snapshots</url>
</repository>
</repositories>
<scm>
<url>https://github.com/thm-projects/arsnova-presenter</url>
<connection>scm:git:https://github.com/thm-projects/arsnova-presenter.git</connection>
......@@ -77,7 +64,7 @@
</ciManagement>
<build>
<sourceDirectory>src/main/websources</sourceDirectory>
<sourceDirectory>${basedir}/src</sourceDirectory>
<plugins>
<plugin>
......@@ -122,75 +109,32 @@
</executions>
<configuration>
<failOnError>true</failOnError>
<configFile>src/main/config/jshint.conf.json</configFile>
<configFile>.jshintrc</configFile>
<directories>
<directory>src/main</directory>
<directory>src</directory>
</directories>
</configuration>
</plugin>
<plugin>
<groupId>com.googlecode.jslint4java</groupId>
<artifactId>jslint4java-maven-plugin</artifactId>
<version>2.0.5</version>
<configuration>
<failOnError>true</failOnError>
<options>
<browser>true</browser>
<devel>true</devel>
<white>true</white>
<predef>require, define</predef>
</options>
<includes>
<include>**/*.js</include>
</includes>
<sourceFolders>
<sourceFolder>${basedir}/src/main</sourceFolder>
</sourceFolders>
</configuration>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="libarsnova-js makes use of the Grunt for building. Please install Node.js if not yet installed and the following commands:" />
<echo message=" $ npm install" />
<echo message=" $ grunt" />
<fail message="libarsnova-js cannot be built by Maven. Please use Grunt instead." />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>env-prod</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>env</name>
<value>prod</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>run-build-script</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>src/main/scripts/build.sh</executable>
<workingDirectory>${basedir}</workingDirectory>
<arguments>
<argument>prod</argument>
<argument>${outputDir}</argument>
<argument>${project.version}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
......@@ -18,12 +18,12 @@
define(
[
"dojo/_base/declare",
"arsnova-api/store/RestQueryCache",
"arsnova-api/globalConfig",
"arsnova-api/session",
"arsnova-api/socket",
"arsnova-api/model/AudienceQuestion",
"arsnova-api/model/audienceQuestionPropertyMap"
"libarsnova/store/RestQueryCache",
"libarsnova/globalConfig",
"libarsnova/session",
"libarsnova/socket",
"libarsnova/model/AudienceQuestion",
"libarsnova/model/audienceQuestionPropertyMap"
],
function (declare, RestQueryCache, globalConfig, sessionModel, socket, AudienceQuestion, audienceQuestionPropertyMap) {
"use strict";
......
......@@ -20,7 +20,7 @@ define(
"dojo/string",
"dojo/request",
"dojo/Deferred",
"arsnova-api/globalConfig"
"libarsnova/globalConfig"
],
function (string, request, Deferred, globalConfig) {
"use strict";
......
......@@ -17,7 +17,7 @@
*/
define(
[
"arsnova-api/socket"
"libarsnova/socket"
],
function (socket) {
"use strict";
......
......@@ -22,16 +22,16 @@ define(
"dojo/Deferred",
"dojo/when",
"dojo/Stateful",
"arsnova-api/store/RestQueryCache",
"arsnova-api/globalConfig",
"arsnova-api/session",
"arsnova-api/socket",
"arsnova-api/model/LecturerQuestion",
"arsnova-api/model/lecturerQuestionPropertyMap",
"arsnova-api/model/AnswerChoiceSummary",
"arsnova-api/model/answerChoiceSummaryPropertyMap",
"arsnova-api/