Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing Ant build with Grunt build #65

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"onevar" : true,
"undef" : true,
"newcap" : true,
"regexp" : true,
"bitwise" : true,
"maxerr" : 50,
"indent" : 4,
"white" : false,
"nomen" : false,
"plusplus" : false
"plusplus" : true
}
17 changes: 0 additions & 17 deletions .project

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- "0.8"
- "0.12"
script:
- "ant build"
- "npm test"

- "npm install -g grunt-cli"
- "grunt build"
- "npm test"
114 changes: 114 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
module.exports = function (grunt) {
var props = grunt.file.readJSON('build/build.properties.json');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
buildnumber: {
package : {}
},
clean: {
dist: [props.dir.dist + '/*'],
'closure-compiler': [props.dir.dist + '/' + props.names.dist_min + '.report.txt']
},
copy: {
main: {
src: props.dir.src + '/wrapper.js',
dest: props.dir.dist + '/' + props.names.dist
}
},
'string-replace': {
main: {
files: [{
src: props.dir.dist + '/' + props.names.dist,
dest: props.dir.dist + '/' + props.names.dist
}],
options: {
replacements: [{
pattern: '//::LICENSE:://',
replacement: grunt.file.read(props.dir.src + '/license.txt')
},
{
pattern: '//::SIGNAL_BINDING_JS:://',
replacement: grunt.file.read(props.dir.src + '/SignalBinding.js')
},
{
pattern: '//::SIGNAL_JS:://',
replacement: grunt.file.read(props.dir.src + '/Signal.js')
},
// version number, build number/date should come after other replaces
{
pattern: new RegExp('::VERSION_NUMBER::', 'gi'), // Replace all ocurrencies
replacement: '<%= pkg.version %>'
},
{
pattern: '::BUILD_NUMBER::',
replacement: '<%= pkg.build %>'
},
{
pattern: '::BUILD_DATE::',
replacement: grunt.template.today("yyyy/mm/dd hh:MM TT")
}]
}
}
},
'closure-compiler': {
frontend: {
closurePath: 'build/closure-compiler',
js: props.dir.dist + '/' + props.names.dist,
jsOutputFile: props.dir.dist + '/' + props.names.dist_min,
options: {
compilation_level: 'SIMPLE_OPTIMIZATIONS',
externs: [
'externs.js'
]
}
}
},
jshint: {
files: [ props.dir.dist + '/' + props.names.dist ]
},
jsdoc : {
dist : {
src: [ props.dir.src + '/Signal*.js' ],
options: {
destination: "<%= pkg.directories.doc %>",
template : "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
configure : "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template/jsdoc.conf.json"
}
}
}
});

grunt.loadNpmTasks('grunt-build-number');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-closure-compiler');
grunt.loadNpmTasks('grunt-jsdoc');

grunt.registerTask('update-pkg', function(){
grunt.config.set('pkg', grunt.file.readJSON('package.json'));
});

grunt.registerTask('compile-done', function(){
grunt.log.writeln('%s built.', props.names.dist);
});

grunt.registerTask('build-done', function(){
grunt.log.writeln('Build complete.', props.names.dist);
});

grunt.registerTask('compile', function(){
grunt.log.writeln('Building %s..', props.names.dist);
grunt.task.run(['buildnumber', 'update-pkg', 'clean:dist', 'copy:main', 'string-replace:main', 'compile-done']);
});

grunt.registerTask('minify', function(){
grunt.task.run(['closure-compiler', 'clean:closure-compiler']);
});

grunt.registerTask('build', ['compile', 'jshint', 'minify', 'build-done']);
grunt.registerTask('deploy', ['build', 'jsdoc']);

};
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@ easily distributed trough npm.

## Building your own ##

This project uses [Apache Ant](http://ant.apache.org/) for the build process. If for some reason you need to build a custom version of JS-Signals install Ant and run:
This project now uses [Grunt](http://gruntjs.com/) for build process. If you need to build a custom version of JS-Signals install Grunt and run:

ant build
grunt build

This will delete all JS files inside the `dist` folder, merge/update/compress source files, validate generated code using [JSLint](http://www.jslint.com/) and copy the output to the `dist` folder.
This will delete all JS files inside the `dist` folder, merge/update/compress source files, validate generated code using [JSHint](http://gruntjs.com/) and copy the output to the `dist` folder.

There is also another ant task that runs the build task and generate
documentation (used before each deploy):
There is also a task to generate documentation based on [JSDoc3](http://usejsdoc.org/)
(used before each deploy):

ant deploy
grunt deploy

**IMPORTANT:** `dist` folder always contain the latest version, regular users should **not** need to run build task.


## Running Tests ##

The specs work on the browser and on node.js, during development you can use
Expand Down
3 changes: 0 additions & 3 deletions build/build.number

This file was deleted.

14 changes: 0 additions & 14 deletions build/build.properties

This file was deleted.

14 changes: 14 additions & 0 deletions build/build.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dir" : {
"src": "src",
"build": "build",
"dist": "dist",
"docs": "dist/docs"
},

"names" : {
"product": "signals",
"dist": "signals.js",
"dist_min": "signals.min.js"
}
}
File renamed without changes.
Loading