Initial build system

This commit is contained in:
Rashid Khan 2013-11-15 14:35:13 -07:00 committed by Boaz Leskes
parent 161c1d1de9
commit 1d7390f5cc
16 changed files with 183 additions and 34 deletions

4
.gitignore vendored
View file

@ -12,4 +12,6 @@
/lib
/kibana
/node_modules
/dist
/build
/packages
/.aws-config.json

View file

@ -4,39 +4,44 @@ module.exports = function (grunt) {
var config = {
pkg: grunt.file.readJSON('package.json'),
baseDir: './kibana',
srcDir: 'kibana/src',
destDir: 'dist',
tempDir: 'tmp'
baseDir: './kibana',
srcDir: 'kibana/src',
buildDir: 'build',
packageDir: 'packages',
destDir: 'build/_site',
tempDir: 'tmp',
port: {
dev : '"9200"',
dist : "(window.location.port !== '' ? ':'+window.location.port : '')"
}
};
// load plugins
require('load-grunt-tasks')(grunt);
// load task definitions
grunt.loadTasks('tasks');
// Utility function to load plugin settings into config
// Utility function to load plugin settings into the above config object
function loadConfig(config,path) {
require('glob').sync('*', {cwd: path}).forEach(function(option) {
var key = option.replace(/\.js$/,'');
// Merge duplicate plugin configs. It is your responsibility to avoid naming collisions
// in tasks
config[key] = config[key] || {};
grunt.util._.extend(config[key], require(path + option)(config));
grunt.util._.extend(config[key], require(path + option)(config,grunt));
});
// technically not required
return config;
}
// Merge that object with what with whatever we have here
loadConfig(config,'./tasks/options/');
// load plugins
require('load-grunt-tasks')(grunt);
// Load Kibana tasks if they exist. Should probably want the user if they don't.
if (grunt.file.exists(config.baseDir)) {
grunt.loadTasks(config.baseDir+'/tasks');
loadConfig(config,config.baseDir+'/tasks/options/');
grunt.task.renameTask('build', 'build-kibana');
}
// Load Marvel tasks. Identical task names will override kibana tasks
grunt.loadTasks('tasks');
loadConfig(config,'./tasks/options/');
// pass the config to grunt
grunt.initConfig(config);

View file

@ -4,7 +4,7 @@
*/
define(['settings'],
function (Settings) {
"use strict";
return new Settings({
@ -18,7 +18,7 @@ function (Settings) {
* elasticsearch host
* @type {String}
*/
elasticsearch: "http://"+window.location.hostname+(window.location.port !== '' ? ':'+window.location.port : ''),
elasticsearch: "http://"+window.location.hostname+":"+@@port,
/**
* The default ES index to use for storing Kibana specific object
@ -34,14 +34,22 @@ function (Settings) {
*/
panel_names: [
'histogram',
'map',
'pie',
'table',
'filtering',
'timepicker',
'text',
'fields',
'hits',
'dashcontrol',
'column',
'derivequeries',
'trends',
'query'
'bettermap',
'query',
'terms',
'sparklines'
]
});
});

View file

@ -3,8 +3,8 @@
"name": "Elasticsearch",
"company": "Elasticsearch BV"
},
"name": "elasticsearch-marvel",
"version": "0.0.1",
"name": "marvel",
"version": "0.1.0-SNAPSHOT",
"repository": {
"type": "git",
"url": "http://github.com/elasticsearch/elasticsearch-marvel.git"
@ -15,7 +15,6 @@
"grunt-contrib": "~0.8.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-string-replace": "~0.2.4",
"grunt-contrib-compress": "~0.5.2",
"grunt-git": "~0.1.6",
"grunt-s3": "~0.2.0-alpha.2",
@ -30,7 +29,11 @@
"grunt-contrib-uglify": "~0.2.4",
"load-grunt-tasks": "~0.2.0",
"glob": "~3.2.7",
"grunt-contrib-symlink": "~0.2.0"
"grunt-contrib-symlink": "~0.2.0",
"grunt-replace": "~0.5.1",
"grunt-string-replace": "~0.2.4",
"grunt-shell": "~0.6.0",
"grunt-contrib-connect": "~0.5.0"
},
"license": "Apache License"
}

10
tasks/build_task.js Normal file
View file

@ -0,0 +1,10 @@
module.exports = function(grunt) {
grunt.registerTask('build', [
'clean:setup',
'shell:maven_clean',
'shell:maven_package',
'setup',
'build-kibana',
'copy:plugin_to_marvel',
]);
};

View file

@ -1,4 +1,3 @@
module.exports = function(grunt) {
grunt.registerTask('default', [
]);
grunt.registerTask('default', []);
};

View file

@ -1,7 +1,7 @@
module.exports = function(config) {
return {
on_start: ['<%= destDir %>', '<%= tempDir %>'],
temp: ['<%= tempDir %>'],
setup: ['<%= baseDir %>']
setup: ['<%= destDir %>','<%= baseDir %>','<%= buildDir %>'],
default_dashboard: ['<%= srcDir %>/app/dashboards/default.json'],
dist: ['<%= destDir %>']
};
};

30
tasks/options/compress.js Normal file
View file

@ -0,0 +1,30 @@
module.exports = function(config) {
return {
zip: {
options: {
archive: '<%= packageDir %>/<%= pkg.name %>-<%= pkg.version %>.zip'
},
files : [
{
expand: true,
cwd: '<%= buildDir %>',
src: ['**/*'],
dest: ''
}
]
},
tgz: {
options: {
archive: '<%= packageDir %>/<%= pkg.name %>-<%= pkg.version %>.tar.gz'
},
files : [
{
expand: true,
cwd: '<%= buildDir %>',
src: ['**/*'],
dest: ''
}
]
}
};
};

View file

@ -1,10 +1,10 @@
module.exports = function(config) {
return {
// copy source to temp, we will minify in place for the dist build
marvel_config: {
cwd: '.',
src: ['config.js'],
dest: '<%= baseDir %>/src/'
plugin_to_marvel: {
cwd: 'target',
expand: true,
src: ['<%= pkg.name %>-<%= pkg.version %>.jar'],
dest: '<%= buildDir %>'
}
};
};

31
tasks/options/replace.js Normal file
View file

@ -0,0 +1,31 @@
module.exports = function(config) {
return {
// copy source to temp, we will minify in place for the dist build
dev_marvel_config: {
options: {
patterns: [
{
match: 'port',
replacement: '<%= port.dev %>',
}
]
},
files: [
{expand: true, flatten: true, src: ['./config.js'], dest: 'src/'}
]
},
dist_marvel_config: {
options: {
patterns: [
{
match: 'port',
replacement: '<%= port.dist %>',
}
]
},
files: [
{expand: true, flatten: true, src: ['./config.js'], dest: 'src/'}
]
}
};
};

19
tasks/options/s3.js Normal file
View file

@ -0,0 +1,19 @@
module.exports = function(config) {
return {
release: {
bucket: 'download.elasticsearch.org',
access: 'private',
//debug: true, // uncommment to prevent actual upload
upload: [
{
src: '<%= packageDir %>/<%= pkg.name %>-<%= pkg.version %>.zip',
dest: 'elasticsearch/<%= pkg.name %>/<%= pkg.name %>-<%= pkg.version %>.zip',
},
{
src: '<%= packageDir %>/<%= pkg.name %>-<%= pkg.version %>.tar.gz',
dest: 'elasticsearch/<%= pkg.name %>/<%= pkg.name %>-<%= pkg.version %>.tar.gz',
}
]
}
};
};

16
tasks/options/shell.js Normal file
View file

@ -0,0 +1,16 @@
module.exports = function(config) {
return {
maven_clean: {
command: 'mvn clean',
options: {
stdout: true
}
},
maven_package: {
command: 'mvn package',
options: {
stdout: true
}
}
}
};

View file

@ -10,6 +10,10 @@ module.exports = function(config) {
src: 'dashboards',
dest: '<%= baseDir %>/src/app/dashboards/marvel'
},
{
src: 'dashboards/overview.json',
dest: '<%= baseDir %>/src/app/dashboards/default.json'
}
]
}
};

7
tasks/package_task.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = function(grunt) {
grunt.registerTask('package', [
'build',
'compress:zip',
'compress:tgz'
]);
};

14
tasks/release_task.js Normal file
View file

@ -0,0 +1,14 @@
module.exports = function(grunt) {
grunt.registerTask('release', [
'package',
'release:load_s3_config',
's3:release'
]);
grunt.registerTask('release:load_s3_config', function () {
var config = grunt.file.readJSON('.aws-config.json');
grunt.config('s3.options', {
key: config.key,
secret: config.secret
});
});
};

View file

@ -2,7 +2,8 @@ module.exports = function(grunt) {
grunt.registerTask('setup', [
'clean:setup',
'gitclone:kibana',
'copy:marvel_config',
'clean:default_dashboard',
'replace:dev_marvel_config',
'symlink'
]);
};