Skip to content

Commit d685eef

Browse files
Paulo Grácioradcortez
authored andcommitted
Added NPM support for Grunt dependencies.
Added Bower support for Java Script dependencies. Added Grunt support for build automation. Removed manual dependencies.
1 parent 0b5e737 commit d685eef

12 files changed

Lines changed: 222 additions & 9784 deletions

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "src/main/webapp/lib/bower"
3+
}

Gruntfile.js

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
5+
// Load grunt tasks automatically
6+
require('load-grunt-tasks')(grunt);
7+
8+
/*
9+
* Time how long grunt tasks take to run, this might be important when having complex builds that take forever.
10+
* For now just to show how fancy grunt is.
11+
*/
12+
require('time-grunt')(grunt);
13+
14+
// init required configurations for each task.
15+
grunt.initConfig({
16+
17+
// Project settings
18+
config: {
19+
path: {
20+
webapp: {
21+
root: 'src/main/webapp'
22+
},
23+
temp: {
24+
root: 'temp'
25+
},
26+
build: {
27+
root: 'build'
28+
}
29+
}
30+
},
31+
32+
// From grunt-contrib-clean
33+
clean: {
34+
build: [
35+
'<%= config.path.temp.root %>',
36+
'<%= config.path.build.root %>'
37+
]
38+
},
39+
40+
// From grunt-bower-install-simple. Downloads the web dependencies.
41+
"bower-install-simple": {
42+
options: {
43+
color: true,
44+
production: false
45+
}
46+
},
47+
48+
// From grunt-wiredep. Automatically inject Bower components into the HTML file
49+
wiredep: {
50+
target: {
51+
src: '<%= config.path.webapp.root %>/index.html',
52+
ignorePath: '<%= config.path.webapp.root %>'
53+
}
54+
},
55+
56+
// From grunt-contrib-concat. This is usefull when we have more than one css file, not the case now...
57+
/*
58+
concat: {
59+
styles: {
60+
src: [
61+
'<%= config.path.webapp.root %>/css/style.css',
62+
],
63+
dest: '<%= config.path.temp.root %>/concat/css/application.css'
64+
}
65+
},
66+
*/
67+
68+
// From grunt-contrib-copy. Copies remaining files to places other tasks can use
69+
copy: {
70+
build: {
71+
files: [
72+
{
73+
src: '<%= config.path.webapp.root %>/index.html',
74+
dest: '<%= config.path.build.root %>/index.html'
75+
}
76+
]
77+
}
78+
},
79+
80+
// From grunt-contrib-htmlmin. Minifies index.html file.
81+
htmlmin: {
82+
prod: {
83+
options: {
84+
collapseBooleanAttributes: true,
85+
collapseWhitespace: true,
86+
removeComments: true,
87+
removeCommentsFromCDATA: true,
88+
removeEmptyAttributes: true,
89+
removeOptionalTags: true,
90+
removeRedundantAttributes: true,
91+
useShortDoctype: true
92+
},
93+
files: [
94+
{
95+
expand: true,
96+
cwd: '<%= config.path.build.root %>',
97+
src: ['index.html'],
98+
dest: '<%= config.path.build.root %>'
99+
}
100+
]
101+
}
102+
},
103+
104+
// From grunt-usemin. Reads HTML for usemin blocks to enable smart builds
105+
useminPrepare: {
106+
html: '<%= config.path.webapp.root %>/index.html',
107+
options: {
108+
staging: '<%= config.path.temp.root %>',
109+
root: '<%= config.path.webapp.root %>',
110+
dest: '<%= config.path.build.root %>'
111+
}
112+
},
113+
114+
// From grunt-usemin.
115+
usemin: {
116+
html: '<%= config.path.build.root %>/index.html'
117+
},
118+
119+
// From grunt-contrib-uglify.
120+
uglify: {
121+
options: {
122+
mangle: false
123+
}
124+
}
125+
}
126+
);
127+
128+
// Task: Build production version ready for deployment
129+
grunt.registerTask('build', [
130+
'clean:build',
131+
'bower-install-simple',
132+
//'concat:styles',
133+
'wiredep',
134+
'useminPrepare',
135+
'concat:generated',
136+
'cssmin',
137+
'uglify',
138+
'copy:build',
139+
'usemin',
140+
'htmlmin'
141+
]);
142+
143+
grunt.registerTask('default', [
144+
'build'
145+
]);
146+
};

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44

55
* You need JDK 7 or higher, Maven 3 and Wildfly 8 to run the application.
66

7-
* Build the code using Maven with the command: `mvn clean install``.
7+
* Build the code using Maven with the command: `mvn clean install`.
88

99
* Copy the file javaee7-angular-1.0-SNAPSHOT.war from target directory to your Wildfly installation folder /standalone/deployments
1010

1111
* Start Wildfly and go to http://localhost:8080/javaee7-angular-1.0-SNAPSHOT/
1212

13+
## Javascript Package Management ##
14+
15+
* You need NPM. Please go to http://nodejs.org/download/ to get a copy.
16+
17+
* Once NPM is installed run the command `npm install`.
18+
19+
* Run the command 'grunt' to download all the web dependencies and build an optimized version of the project.

bower.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "javaee7-angular",
3+
"version": "1.0.0",
4+
"authors": [
5+
"Roberto Cortez <radcortez@yahoo.com>",
6+
"Paulo Grácio <paulo.gracio@gmail.com>"
7+
],
8+
"description": "javaee7-angular JavaScript dependencies.",
9+
"private": true,
10+
"dependencies": {
11+
"angular": "1.2.0",
12+
"jquery": "1.9.1",
13+
"angular-bootstrap": "0.10.0",
14+
"angular-grid": "2.0.7"
15+
}
16+
}

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "javaee7-angular",
3+
"version": "1.0.0",
4+
"authors": [
5+
"Roberto Cortez <radcortez@yahoo.com>",
6+
"Paulo Grácio <paulo.gracio@gmail.com>"
7+
],
8+
"description": "javaee7-angular dependencies for Grunt.",
9+
"private": true,
10+
"devDependencies": {
11+
"load-grunt-tasks": "~0.6.0",
12+
"time-grunt": "~0.4.0",
13+
"grunt-contrib-clean": "~0.5.0",
14+
"grunt-wiredep": "~1.8.0",
15+
"grunt-contrib-htmlmin": "~0.3.0",
16+
"grunt-usemin": "~2.3.0",
17+
"grunt-contrib-copy": "~0.5.0",
18+
"grunt-contrib-concat": "~0.4.0",
19+
"grunt-contrib-uglify": "~0.5.0",
20+
"grunt-contrib-cssmin": "~0.9.0",
21+
"grunt-bower-install-simple": "~0.9.3"
22+
},
23+
"engines": {
24+
"node": ">=0.8.0"
25+
}
26+
}

src/main/webapp/index.html

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@
22
<!-- Declares the root element that allows behaviour to be modified through Angular custom HTML tags. -->
33
<html ng-app="persons">
44
<head>
5-
<title></title>
6-
<script src="lib/angular.min.js"></script>
7-
<script src="lib/jquery-1.9.1.js"></script>
8-
<script src="lib/ui-bootstrap-0.10.0.min.js"></script>
9-
<script src="lib/ng-grid.min.js"></script>
5+
<title>javaee7-angular</title>
106

11-
<script src="script/person.js"></script>
7+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
8+
9+
<!-- build:css css/third-party.css -->
10+
<!-- bower:css -->
11+
<link rel="stylesheet" href="lib/bower/angular-grid/ng-grid.css" />
12+
<!-- endbower -->
13+
<!-- endbuild -->
1214

13-
<link rel="stylesheet" type="text/css" href="lib/bootstrap.min.css"/>
14-
<link rel="stylesheet" type="text/css" href="lib/ng-grid.min.css"/>
15+
<!-- build:css css/application.css -->
1516
<link rel="stylesheet" type="text/css" href="css/style.css"/>
17+
<!-- endbuild -->
18+
19+
<!-- build:js lib/third-party.js -->
20+
<!-- bower:js -->
21+
<script src="lib/bower/jquery/jquery.js"></script>
22+
<script src="lib/bower/angular/angular.js"></script>
23+
<script src="lib/bower/angular-bootstrap/ui-bootstrap-tpls.js"></script>
24+
<script src="lib/bower/angular-grid/build/ng-grid.js"></script>
25+
<!-- endbower -->
26+
<!-- endbuild -->
27+
28+
<!-- build:js script/all.js -->
29+
<script src="script/person.js"></script>
30+
<!-- endbuild -->
1631
</head>
1732

1833
<body>

0 commit comments

Comments
 (0)