diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-03-19 19:06:42 +0600 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-03-19 19:17:10 +0600 |
commit | a918f608159c3b22079c0757a28f69db3f00f50a (patch) | |
tree | e97bcae7a1885ef6422dac433d66372a13e16f8f | |
parent | 3c3c1e3e2c091285017986c11f075f5a6d87a643 (diff) | |
download | sonarqube-a918f608159c3b22079c0757a28f69db3f00f50a.tar.gz sonarqube-a918f608159c3b22079c0757a28f69db3f00f50a.zip |
Grunt Build
-rw-r--r-- | sonar-server/.gitignore | 9 | ||||
-rw-r--r-- | sonar-server/Gruntfile.coffee | 133 | ||||
-rw-r--r-- | sonar-server/package.json | 6 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb | 41 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/javascripts/build.js | 3 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/less/sonar-colorizer.less (renamed from sonar-server/src/main/webapp/stylesheets/sonar-colorizer.less) | 0 |
6 files changed, 149 insertions, 43 deletions
diff --git a/sonar-server/.gitignore b/sonar-server/.gitignore index 2cf70342348..2f3d7426f8f 100644 --- a/sonar-server/.gitignore +++ b/sonar-server/.gitignore @@ -4,15 +4,16 @@ node/ # nodeJS dependencies node_modules/ +# build +src/main/webapp/build/ + # generated css -src/main/webapp/stylesheets/ +src/main/webapp/css/ # generated js +src/main/webapp/js/ src/main/webapp/javascripts/coding-rules/ src/main/webapp/javascripts/quality-gate/ src/main/webapp/javascripts/tests/common/ src/main/webapp/javascripts/tests/translateSpec.js -# js build -src/main/webapp/javascripts/build/ - diff --git a/sonar-server/Gruntfile.coffee b/sonar-server/Gruntfile.coffee index a1f61dd9ba0..acd131b6b9c 100644 --- a/sonar-server/Gruntfile.coffee +++ b/sonar-server/Gruntfile.coffee @@ -5,7 +5,7 @@ module.exports = (grunt) -> less: dev: files: - '<%= pkg.assets %>stylesheets/sonar.css': [ + '<%= pkg.assets %>css/sonar.css': [ '<%= pkg.assets %>less/yui-reset-font.less' '<%= pkg.assets %>less/jquery-ui.less' '<%= pkg.assets %>less/select2.less' @@ -20,6 +20,26 @@ module.exports = (grunt) -> '<%= pkg.assets %>less/navigator.less' '<%= pkg.assets %>less/*.less' ] + build: + options: + cleancss: true + files: + '<%= pkg.assets %>build/css/sonar.css': [ + '<%= pkg.assets %>less/yui-reset-font.less' + '<%= pkg.assets %>less/jquery-ui.less' + '<%= pkg.assets %>less/select2.less' + '<%= pkg.assets %>less/select2-sonar.less' + '<%= pkg.assets %>less/layout.less' + '<%= pkg.assets %>less/style.less' + '<%= pkg.assets %>less/icons.less' + '<%= pkg.assets %>less/ui.less' + '<%= pkg.assets %>less/sonar-colorizer.less' + '<%= pkg.assets %>less/dashboard.less' + '<%= pkg.assets %>less/select-list.less' + '<%= pkg.assets %>less/navigator.less' + '<%= pkg.assets %>less/*.less' + ] + coffee: dev: @@ -32,6 +52,107 @@ module.exports = (grunt) -> ] + uglify: + dev: + options: + beautify: true + files: + '<%= pkg.assets %>js/sonar.js': [ + '<%= pkg.assets %>javascripts/third-party/jquery.js' + '<%= pkg.assets %>javascripts/third-party/jquery-ui.js' + '<%= pkg.assets %>javascripts/third-party/d3.js' + '<%= pkg.assets %>javascripts/third-party/underscore.js' + '<%= pkg.assets %>javascripts/third-party/select2.js' + '<%= pkg.assets %>javascripts/select2-jquery-ui-fix.js' + '<%= pkg.assets %>javascripts/translate.js' + '<%= pkg.assets %>javascripts/widgets/widget.js' + '<%= pkg.assets %>javascripts/widgets/bubble-chart.js' + '<%= pkg.assets %>javascripts/widgets/timeline.js' + '<%= pkg.assets %>javascripts/widgets/stack-area.js' + '<%= pkg.assets %>javascripts/widgets/pie-chart.js' + '<%= pkg.assets %>javascripts/widgets/histogram.js' + '<%= pkg.assets %>javascripts/top-search.js' + '<%= pkg.assets %>javascripts/sortable.js' + '<%= pkg.assets %>javascripts/common/inputs.js' + '<%= pkg.assets %>javascripts/application.js' + '<%= pkg.assets %>javascripts/dashboard.js' + '<%= pkg.assets %>javascripts/duplication.js' + '<%= pkg.assets %>javascripts/resource.js' + '<%= pkg.assets %>javascripts/issue.js' + '<%= pkg.assets %>javascripts/recent-history.js' + ] + build: + options: + preserveComments: false # remove all comments + files: + '<%= pkg.assets %>build/js/sonar.js': [ + '<%= pkg.assets %>javascripts/third-party/jquery.js' + '<%= pkg.assets %>javascripts/third-party/jquery-ui.js' + '<%= pkg.assets %>javascripts/third-party/d3.js' + '<%= pkg.assets %>javascripts/third-party/underscore.js' + '<%= pkg.assets %>javascripts/third-party/select2.js' + '<%= pkg.assets %>javascripts/select2-jquery-ui-fix.js' + '<%= pkg.assets %>javascripts/translate.js' + '<%= pkg.assets %>javascripts/widgets/widget.js' + '<%= pkg.assets %>javascripts/widgets/bubble-chart.js' + '<%= pkg.assets %>javascripts/widgets/timeline.js' + '<%= pkg.assets %>javascripts/widgets/stack-area.js' + '<%= pkg.assets %>javascripts/widgets/pie-chart.js' + '<%= pkg.assets %>javascripts/widgets/histogram.js' + '<%= pkg.assets %>javascripts/top-search.js' + '<%= pkg.assets %>javascripts/sortable.js' + '<%= pkg.assets %>javascripts/common/inputs.js' + '<%= pkg.assets %>javascripts/application.js' + '<%= pkg.assets %>javascripts/dashboard.js' + '<%= pkg.assets %>javascripts/duplication.js' + '<%= pkg.assets %>javascripts/resource.js' + '<%= pkg.assets %>javascripts/issue.js' + '<%= pkg.assets %>javascripts/recent-history.js' + ] + + + requirejs: + options: + baseUrl: '<%= pkg.assets %>javascripts' + + paths: + 'backbone': 'third-party/backbone' + 'backbone.marionette': 'third-party/backbone.marionette' + 'handlebars': 'third-party/handlebars' + 'moment': 'third-party/moment' + 'select-list': 'common/select-list' + 'jquery.mockjax': 'third-party/jquery.mockjax' + + shim: + 'backbone.marionette': + deps: ['backbone'] + exports: 'Marionette' + 'backbone': exports: 'Backbone' + 'handlebars': exports: 'Handlebars' + 'moment': exports: 'moment' + 'select-list': exports: 'SelectList' + + qualityGate: options: + name: 'quality-gate/app' + out: '<%= pkg.assets %>build/js/quality-gate/app.js' + + codingRules: options: + name: 'coding-rules/app' + out: '<%= pkg.assets %>build/js/coding-rules/app.js' + + issues: options: + name: 'issues/app' + out: '<%= pkg.assets %>build/js/issues/app.js' + + measures: options: + name: 'measures/app' + out: '<%= pkg.assets %>build/js/measures/app.js' + + selectList: options: + name: 'common/select-list' + out: '<%= pkg.assets %>build/js/common/select-list.js' + + watch: options: spawn: false @@ -44,12 +165,20 @@ module.exports = (grunt) -> files: '<%= pkg.assets %>coffee/**/*.coffee' tasks: ['coffee:dev'] + uglify: + files: '<%= pkg.assets %>javascripts/**/*.js' + tasks: ['uglify:dev'] + + # Load grunt-contrib-* plugins grunt.loadNpmTasks 'grunt-contrib-less' grunt.loadNpmTasks 'grunt-contrib-coffee' + grunt.loadNpmTasks 'grunt-contrib-uglify' + grunt.loadNpmTasks 'grunt-contrib-requirejs' grunt.loadNpmTasks 'grunt-contrib-watch' # Define tasks - grunt.registerTask 'default', ['less:dev', 'coffee:dev'] + grunt.registerTask 'default', ['less:dev', 'coffee:dev', 'uglify:dev'] + grunt.registerTask 'build', ['less:build', 'coffee:dev', 'uglify:build', 'requirejs'] diff --git a/sonar-server/package.json b/sonar-server/package.json index 7da95cd01a6..b331bb6b3dc 100644 --- a/sonar-server/package.json +++ b/sonar-server/package.json @@ -12,8 +12,10 @@ "grunt-contrib-less": "~0.10.0", "grunt-contrib-coffee": "~0.10.1", "grunt-contrib-handlebars": "~0.7.0", - "grunt-contrib-requirejs": "~0.4.3", - "grunt-contrib-watch": "~0.5.3" + "grunt-contrib-requirejs": "^0.4.3", + "grunt-contrib-watch": "~0.5.3", + "grunt-contrib-uglify": "^0.4.0" + }, "engines": { "node": "~0.8 || ~0.10" diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb index 73203be4237..1043f454da3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb @@ -18,42 +18,15 @@ end %> <title><%= title -%></title> - <%= stylesheet_link_tag 'sonar', :media => 'all' -%> - <%= yield :style -%> - - <% if ENV['RAILS_ENV'] == 'production' %> - <%= javascript_include_tag 'sonar' -%> - <% else %> - <%= javascript_include_tag 'third-party/jquery' %> - <%= javascript_include_tag 'third-party/jquery-ui' %> - <%= javascript_include_tag 'third-party/d3' %> - <%= javascript_include_tag 'third-party/underscore' %> - <%= javascript_include_tag 'third-party/select2' %> - <%= javascript_include_tag 'select2-jquery-ui-fix' %> - - <%= javascript_include_tag 'translate' %> - <%= javascript_include_tag 'widgets/widget' %> - <%= javascript_include_tag 'widgets/bubble-chart' %> - <%= javascript_include_tag 'widgets/timeline' %> - <%= javascript_include_tag 'widgets/stack-area' %> - <%= javascript_include_tag 'widgets/pie-chart' %> - <%= javascript_include_tag 'widgets/histogram' %> - - <%= javascript_include_tag 'top-search' %> - <%= javascript_include_tag 'sortable' %> - <%= javascript_include_tag 'common/inputs' %> + <link href="<%= ApplicationController.root_context -%>/css/sonar.css" rel="stylesheet" media="all"> + <%= yield :style -%> - <%= javascript_include_tag 'application' %> - <%= javascript_include_tag 'dashboard' %> - <%= javascript_include_tag 'duplication' %> - <%= javascript_include_tag 'resource' %> - <%= javascript_include_tag 'issue' %> - <%= javascript_include_tag 'recent-history' %> - <% end %> - <script>var baseUrl = '<%= ApplicationController.root_context -%>'; - var $j = jQuery.noConflict(); - $j(document).ready(function () {$j('.open-modal').modal()}); + <script src="<%= ApplicationController.root_context -%>/js/sonar.js"></script> + <script> + var baseUrl = '<%= ApplicationController.root_context -%>'; + var $j = jQuery.noConflict(); + $j(document).ready(function () {$j('.open-modal').modal()}); </script> <%= yield :script -%> </head> diff --git a/sonar-server/src/main/webapp/javascripts/build.js b/sonar-server/src/main/webapp/javascripts/build.js index bda21470856..3f238b9080c 100644 --- a/sonar-server/src/main/webapp/javascripts/build.js +++ b/sonar-server/src/main/webapp/javascripts/build.js @@ -1,8 +1,9 @@ ({ appDir: '.', baseUrl: '.', - dir: 'DEFINED IN POM.XML', + dir: 'build', preserveLicenseComments: false, + skipDirOptimize: true, modules: [ { name: 'quality-gate/app' }, diff --git a/sonar-server/src/main/webapp/stylesheets/sonar-colorizer.less b/sonar-server/src/main/webapp/less/sonar-colorizer.less index dd924b9ea5e..dd924b9ea5e 100644 --- a/sonar-server/src/main/webapp/stylesheets/sonar-colorizer.less +++ b/sonar-server/src/main/webapp/less/sonar-colorizer.less |