blob: 4a42328d927783714f06d84dc9a5491eee00cf0e [file] [log] [blame]
Sean Condon49e15be2018-05-16 16:58:29 +01001NODE_VERSION = "v8.11.1"
Sean Condon83fc39f2018-04-19 18:56:13 +01002
3COMPILE_DEPS = [
4 '//lib:CORE_DEPS',
5 '//lib:JACKSON',
6 '//lib:KRYO',
7 '//lib:javax.ws.rs-api',
8 '//lib:servlet-api',
9 '//lib:jetty-websocket',
10 '//lib:jetty-util',
11 '//lib:jersey-media-multipart',
12 '//lib:org.apache.karaf.shell.console',
13 '//cli:onos-cli',
14 '//lib:jersey-server',
15 '//incubator/api:onos-incubator-api',
16 '//incubator/net:onos-incubator-net',
17 '//utils/rest:onlab-rest',
18 '//core/store/serializers:onos-core-serializers',
Sean Condon49e15be2018-05-16 16:58:29 +010019 ':node-release-' + NODE_VERSION,
20 ':node-bin-' + NODE_VERSION,
Sean Condon83fc39f2018-04-19 18:56:13 +010021 '//web/gui2:onos-web-gui2-build',
22]
23
24TEST_DEPS = [
25 '//lib:TEST',
26 '//core/api:onos-api-tests',
27 '//drivers/default:onos-drivers-default',
28]
29
30include_defs('//bucklets/node.bucklet')
31
Sean Condon49e15be2018-05-16 16:58:29 +010032fetch_node(version = NODE_VERSION)
Sean Condon83fc39f2018-04-19 18:56:13 +010033
34genrule(
35 name = 'onos-web-gui2-build',
36 srcs = glob([
Yuta HIGUCHI2ff911b2018-05-22 14:33:43 -070037 '**/*.json',
Sean Condon83fc39f2018-04-19 18:56:13 +010038 'src/main/webapp/**/*.ts',
39 'src/main/webapp/**/*.html',
40 'src/main/webapp/**/*.css',
Sean Condon49e15be2018-05-16 16:58:29 +010041 'src/main/webapp/**/*.png',
42 '*.js',
43 'e2e/**/*'
Sean Condon83fc39f2018-04-19 18:56:13 +010044 ], excludes = [
45 'dist/**/*',
46 'node_modules/**/*',
47 'src/main/webapp/dist/**/*'
48 ]),
49 bash =
50#To avoid any older 'NodeJS' installations it is necessary to use only the one
51# associated with this project - Angular 6 won't work on older releases
Sean Condon49e15be2018-05-16 16:58:29 +010052 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
Sean Condon83fc39f2018-04-19 18:56:13 +010053 + 'echo $PATH;'
Sean Condon49e15be2018-05-16 16:58:29 +010054 + '$(location :node-bin-' + NODE_VERSION + ')/bin/node -v;'
55 + 'ORIGPATH="$SRCDIR";'
56 + 'cd $(location :node-bin-' + NODE_VERSION + ')/bin &&'
Sean Condon83fc39f2018-04-19 18:56:13 +010057 + 'ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm5 &&'
58 + 'cd $ORIGPATH &&'
59# The symlink to npm is not always created properly by the BUCK job that
60# untars it. It's safer to have our own symlink 'npm5'
61 + 'npm5 -v;'
62 + 'npm5 install -g @angular/cli@6.0.0 2>&1;'
Sean Condon83fc39f2018-04-19 18:56:13 +010063 + 'npm5 install 2>&1;'
64 + 'ng -v;'
Sean Condona00bf382018-06-23 07:54:01 +010065# Build it in production mode - optimization is turned off because of Angular CLI 6.0.x bug https://github.com/angular/angular-cli/issues/7799
66 + 'ng build --extract-css --prod --optimization=false --preserve-symlinks --base-href /onos/ui2/dist/ --deploy-url /onos/ui2/dist/ --output-path="$OUT" 2>&1',
Sean Condon83fc39f2018-04-19 18:56:13 +010067 out = 'dist',
68 visibility = [ 'PUBLIC' ],
69)
70
Sean Condon49e15be2018-05-16 16:58:29 +010071genrule(
72 name = 'onos-web-gui2-test',
73 srcs = [],
74 bash =
75 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
76 + 'ORIGPATH="$SRCDIR";'
77 + 'ORIGOUTPUT=\$(echo $ORIGPATH|cut -d\'_\' -f 1 );'
78 + 'cd $(location :onos-web-gui2-build)/../../onos-web-gui2-build__srcs;'
79 # The sym linked karma.conf.js will mean that 'karma-jasmine' won't be found
80 + 'cp karma.conf.js karma.conflocal.js;'
81 + 'pwd > "$OUT";'
82 + 'npm5 -v >> "$OUT";'
83 + 'ng -v >> "$OUT";'
84 + 'if [ -f /usr/bin/chromium-browser ]; then export CHROME_BIN=/usr/bin/chromium-browser; fi;'
85 + 'echo $CHROME_BIN >> "$OUT";'
86 # No point using PhantonJS as the browser because it's not compatible with ES6
87 # Install either chrome or chromium-browser on the machine
88 + 'ng test --preserve-symlinks --karma-config=karma.conflocal.js --code-coverage --browsers=ChromeHeadless --watch=false >> "$OUT" 2>&1 || '
89 + 'if [ $? -eq 0 ]; then echo "Successfully ran tests";'
Sean Condon83775682018-05-27 18:59:59 +010090 + 'else '
91 + ' if grep -q CHROME_BIN $ORIGOUTPUT/onos-web-gui2-test-log.txt ; then '
92 + ' echo "Warning: Step onos-web-gui2-test (test of Angular code) skipped because no binary for ChromeHeadless browser was found on your platform." >&2;'
93 + ' echo "Install Google Chrome or Chromium Browser to allow this step to run." >&2;'
94 + ' else '
95 + ' echo "Error running \'ng test\' on \'//web/gui2:onos-web-gui2-test\'. See $ORIGOUTPUT/onos-web-gui2-test-log.txt for more details" >&2;'
Sean Condon2a61ac22018-07-10 09:53:06 +010096 + ' tail -n 100 $OUT >&2;'
97 + ' exit 1;'
Sean Condon83775682018-05-27 18:59:59 +010098 + ' fi;'
Sean Condon49e15be2018-05-16 16:58:29 +010099 + 'fi;',
100 out = 'onos-web-gui2-test-log.txt',
101)
102
103genrule(
104 name = 'onos-web-gui2-lint',
105 srcs = [],
106 bash =
107 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
108 + 'cd $(location :onos-web-gui2-build)/../../onos-web-gui2-build__srcs;'
Sean Condon28ecc5f2018-06-25 12:50:16 +0100109 + 'ng lint >> "$OUT" 2>&1 || '
110 + 'if [ $? -eq 0 ]; then echo "Successfully ran lint";'
111 + 'else '
112 + ' cat $OUT >&2;'
113 + ' exit 1;'
114 + 'fi;',
Sean Condon49e15be2018-05-16 16:58:29 +0100115 out = 'onos-web-gui2-lint-log.txt',
116)
117
118genrule(
119 name = 'onos-web-gui2-compodoc',
120 srcs = [],
121 bash =
122 'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
123 + 'cd $(location :onos-web-gui2-build) && cd ../.. && cd onos-web-gui2-build__srcs;'
124 + 'pwd;'
125 + 'npm5 -v;'
126 + 'npm5 install -g @compodoc/compodoc 2>&1;'
127 + 'npm5 run compodoc -- -V;'
128# TODO This does not pick up on sym linked files - issue raised with authors
129 + 'npm5 run compodoc -- -d "$OUT"',
130 out = 'documentation',
131)
132
Sean Condon83fc39f2018-04-19 18:56:13 +0100133osgi_jar_with_tests (
134 name = 'onos-gui2',
135 deps = COMPILE_DEPS,
136 test_deps = TEST_DEPS,
Sean Condon49e15be2018-05-16 16:58:29 +0100137 resources = [
138 ':onos-web-gui2-build'
139 ],
Sean Condon83fc39f2018-04-19 18:56:13 +0100140 resources_root = '.',
Sean Condon49e15be2018-05-16 16:58:29 +0100141 test_resources = [
142 ':onos-web-gui2-test',
143 ':onos-web-gui2-lint'
144 ],
145 test_resources_root = '.',
Sean Condon83fc39f2018-04-19 18:56:13 +0100146 web_context = '/onos/ui2',
147 do_javadocs = False,
148)
Sean Condon49e15be2018-05-16 16:58:29 +0100149
150onos_app (
151 title = 'ONOS GUI v2 Application',
152 category = 'GUI',
153 url = 'http://onosproject.org',
154 description = 'ONOS GUI v2 based on Angular 6',
155 included_bundles = ['//web/gui2:onos-gui2'],
Sean Condon2a61ac22018-07-10 09:53:06 +0100156)