Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | """ |
| 16 | |
| 17 | """ |
| 18 | Rules to build the ONOS GUI 2 |
| 19 | |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 20 | The GUI2 Angular 7 elements are built here with Angular CLI 'ng' |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 21 | Some work is being done in the Bazel community to integrate Bazel and |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 22 | Angular 7, (Angular Buildtools Convergence - |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 23 | https://docs.google.com/document/d/1OlyiUnoTirUj4gecGxJeZBcjHcFr36RvLsvpBl2mxA8/preview) |
| 24 | but it is in the very early stages (Aug'18) and not yet fit |
| 25 | for production and at present it works as a replacement for Angular CLI |
| 26 | (which is not desirable). |
| 27 | |
| 28 | There are plans to extend Bazel it to work with Angular CLI, and if works |
| 29 | well this Bazel file may be rearchiteced in future. |
| 30 | |
| 31 | Bazel and npm are incompatibe in how they deal with files. npm likes to |
| 32 | follow links to get back to the original canonical path names, and bazel |
| 33 | uses links extensively when populating the sandbox. To get around these |
| 34 | problems, the rules that follow use filegroups to specify the files as |
| 35 | dependencies and then use a genrule to convert the files into a tar ball. |
| 36 | Once the tar ball is unrolled into the sandbox, the links are broken, but |
| 37 | the build is still hermetic since those files are referred to as dependencies in the genrule. |
| 38 | """ |
| 39 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 40 | load("//tools/build/bazel:jdk_genrule.bzl", genrule = "jdk_genrule") |
| 41 | |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 42 | COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [ |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 43 | "@javax_ws_rs_api//jar", |
| 44 | "@servlet_api//jar", |
| 45 | "@jetty_websocket//jar", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 46 | "@jetty_websocket_api//jar", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 47 | "@jetty_util//jar", |
| 48 | "@jersey_media_multipart//jar", |
| 49 | "@jersey_server//jar", |
Ray Milkey | 427e975 | 2018-11-15 16:34:48 -0800 | [diff] [blame] | 50 | "@jersey_hk2//jar", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 51 | "//utils/rest:onlab-rest", |
| 52 | "//core/store/serializers:onos-core-serializers", |
| 53 | ] |
| 54 | |
| 55 | TEST_DEPS = TEST + [ |
| 56 | "//core/api:onos-api-tests", |
| 57 | "//drivers/default:onos-drivers-default", |
| 58 | ] |
| 59 | |
| 60 | """ |
| 61 | Files that get put at the top level of the tar ball |
| 62 | """ |
| 63 | |
| 64 | filegroup( |
| 65 | name = "_root_level_files", |
| 66 | srcs = |
| 67 | [ |
| 68 | ":angular.json", |
| 69 | ":karma.conf.js", |
| 70 | ":package.json", |
| 71 | ":package-lock.json", |
| 72 | ":protractor.conf.js", |
| 73 | ":src/main/tsconfig.json", |
| 74 | ":src/main/tslint.json", |
| 75 | ":tsconfig.json", |
| 76 | ], |
| 77 | ) |
| 78 | |
| 79 | filegroup( |
| 80 | name = "_e2e_test_files", |
| 81 | srcs = [ |
| 82 | ":e2e/app.e2e-spec.ts", |
| 83 | ":e2e/app.po.ts", |
| 84 | ":e2e/tsconfig.e2e.json", |
| 85 | ], |
| 86 | ) |
| 87 | |
| 88 | """ |
| 89 | Files that get put into the WEB-INF directory of the tar ball |
| 90 | """ |
| 91 | |
| 92 | filegroup( |
| 93 | name = "_web_inf_classes_files", |
| 94 | srcs = |
| 95 | [ |
| 96 | ":src/main/webapp/error.html", |
| 97 | ":src/main/webapp/login.html", |
| 98 | ":src/main/webapp/nav.html", |
| 99 | ":src/main/webapp/not-ready.html", |
Sean Condon | 55c3053 | 2018-10-29 12:26:57 +0000 | [diff] [blame] | 100 | ":src/main/webapp/onos.global.css", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 101 | ], |
| 102 | ) |
| 103 | |
| 104 | """ |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 105 | Run ng build to create outputs in production mode |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 106 | See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-build-prod.log for details of the Angular CLI output |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 107 | |
| 108 | To avoid the overhead of having several "npm install" invocations, we just do |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 109 | it once in the //web/gui2-fw-lib which is really the core for the whole Angular 7 |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 110 | structure in ONOS. This copies files in to node_modules, but because the gui2-fw-lib |
| 111 | has not been generated at that time we copy it in separately below with the 'tar' cmd |
| 112 | and then 'mv' |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 113 | """ |
| 114 | |
| 115 | genrule( |
| 116 | name = "_onos-gui2-ng-build", |
| 117 | srcs = [ |
| 118 | "@nodejs//:bin/npm", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 119 | "@nodejs//:bin/nodejs/bin/node", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 120 | "//web/gui2-fw-lib:onos-gui2-fw-npm-install", |
| 121 | "//web/gui2-fw-lib:onos-gui2-fw-ng-build", |
| 122 | "//web/gui2-fw-lib:gui2_fw_lib_ext_css", |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 123 | "//web/gui2-topo-lib:gui2-topo-lib-build", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 124 | "//apps/faultmanagement/fm-gui2-lib:fm-gui2-lib-build", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 125 | ":_root_level_files", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 126 | ":_web_app_all", |
Boyuan Yan | 6b23b38 | 2019-06-04 11:59:35 -0700 | [diff] [blame] | 127 | "//apps/roadm/web/roadm-gui:roadm-gui-lib-build", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 128 | ], |
| 129 | outs = [ |
| 130 | "onos-gui2-ng-build-prod.log", |
| 131 | "onos-gui2-ng-build.jar", |
| 132 | ], |
| 133 | cmd = "ROOT=`pwd` &&" + |
| 134 | " export HOME=. &&" + |
| 135 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame^] | 136 | " NODE=$(location @nodejs//:bin/nodejs/bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 137 | " INSTALL_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 138 | " FWLIB_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-ng-build)) &&" + # An array of filenames - sorted by time created |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 139 | " mkdir -p web/gui2 && cd web/gui2 &&" + |
| 140 | " jar xf ../../$(location :_web_app_all) &&" + |
| 141 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 142 | " tar xf $$ROOT/$${FWLIB_FILES[0]} &&" + |
| 143 | " mv package/ node_modules/gui2-fw-lib/ &&" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 144 | # Add in modules from external packages |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 145 | " GUI2_TOPO_LIB_FILES=($(locations //web/gui2-topo-lib:gui2-topo-lib-build)) &&" + # An array of filenames - sorted by time created |
| 146 | " tar xf $$ROOT/$${GUI2_TOPO_LIB_FILES[0]} &&" + |
| 147 | " mv package/ node_modules/gui2-topo-lib/ &&" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 148 | " FM_GUI2_LIB_FILES=($(locations //apps/faultmanagement/fm-gui2-lib:fm-gui2-lib-build)) &&" + # An array of filenames - sorted by time created |
| 149 | " tar xf $$ROOT/$${FM_GUI2_LIB_FILES[0]} &&" + |
| 150 | " mv package/ node_modules/fm-gui2-lib/ &&" + |
Boyuan Yan | 6b23b38 | 2019-06-04 11:59:35 -0700 | [diff] [blame] | 151 | " ROADM_GUI_LIB_FILES=($(locations //apps/roadm/web/roadm-gui:roadm-gui-lib-build)) &&" + # An array of filenames - sorted by time created |
| 152 | " tar xf $$ROOT/$${ROADM_GUI_LIB_FILES[0]} &&" + |
| 153 | " mv package/ node_modules/roadm-gui-lib/ &&" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 154 | # End of add in modules from external packages |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 155 | " mkdir -p src/main/webapp/app/fw &&" + |
| 156 | " (cd src/main/webapp/app/fw &&" + |
| 157 | " jar xf $$ROOT/$(location //web/gui2-fw-lib:gui2_fw_lib_ext_css)) &&" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 158 | " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" + |
Thomas Vachuska | 0c19e65 | 2018-08-28 10:57:07 -0700 | [diff] [blame] | 159 | " export PATH=$$ROOT/$$(dirname $${NODE}):$$ROOT/web/gui2/node_modules/@angular/cli/bin:$$PATH &&" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 160 | " node -v > ../../$(location onos-gui2-ng-build-prod.log) &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame^] | 161 | " $$ROOT/$(location @nodejs//:bin/npm) version >> ../../$(location onos-gui2-ng-build-prod.log) &&" + |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 162 | " ng version >> ../../$(location onos-gui2-ng-build-prod.log) &&" + |
| 163 | " ng build --extract-css --prod --preserve-symlinks" + |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 164 | " --base-href /onos/ui/ --deploy-url /onos/ui/ >> $$ROOT/$(location onos-gui2-ng-build-prod.log) 2>&1 ||" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 165 | " if [ $$? -eq 0 ]; then echo 'Successfully ran build';" + |
| 166 | " else " + |
| 167 | " echo 'Error running \'ng build\' on \'//web/gui2:_onos-gui2-ng-build\'. \\\n" + |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 168 | " See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-build-prod.log for more details' >&2;" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 169 | #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" + |
| 170 | " exit 1;" + |
| 171 | " fi;" + |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 172 | " cp -r node_modules/gui2-fw-lib/assets src/main/webapp/dist &&" + |
| 173 | " cd src/main/webapp/dist &&" + |
| 174 | " jar Mcf $$ROOT/$(location onos-gui2-ng-build.jar) .", |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame^] | 175 | message = "Angular CLI 8 build", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 176 | ) |
| 177 | |
| 178 | """ |
| 179 | Run 'ng test' to run Angular test and 'ng lint' for checkstyle |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 180 | See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-lint.log or |
| 181 | bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-test.log for details of the Angular CLI output |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 182 | """ |
| 183 | |
| 184 | genrule( |
| 185 | name = "_onos-gui2-ng-test-genrule", |
| 186 | srcs = [ |
| 187 | "@nodejs//:bin/npm", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 188 | "@nodejs//:bin/nodejs/bin/node", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 189 | "//web/gui2-fw-lib:onos-gui2-fw-npm-install", |
| 190 | "//web/gui2-fw-lib:onos-gui2-fw-ng-build", |
| 191 | "//web/gui2-fw-lib:gui2_fw_lib_ext_css", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 192 | ":_web_app_all", |
| 193 | ":_web_app_tests", |
| 194 | ":_angular_all", |
| 195 | ], |
| 196 | outs = [ |
| 197 | "onos-gui2-ng-ver.log", |
| 198 | "onos-gui2-ng-lint.log", |
| 199 | "onos-gui2-ng-test.log", |
| 200 | ], |
| 201 | cmd = " ROOT=`pwd` &&" + |
| 202 | " export HOME=. &&" + |
| 203 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame^] | 204 | " NODE=$(location @nodejs//:bin/nodejs/bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 205 | " INSTALL_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 206 | " FWLIB_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-ng-build)) &&" + # An array of filenames - sorted by time created |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 207 | " mkdir -p web/gui2 &&" + |
| 208 | " cd web/gui2 &&" + |
| 209 | " jar xf ../../$(location :_angular_all) &&" + |
| 210 | " jar xf ../../$(location :_web_app_all) &&" + |
| 211 | " jar xf ../../$(location :_web_app_tests) &&" + |
| 212 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 213 | " tar xf $$ROOT/$${FWLIB_FILES[0]} &&" + |
| 214 | " mv package/ node_modules/gui2-fw-lib/ &&" + |
| 215 | " mkdir -p src/main/webapp/app/fw &&" + |
| 216 | " (cd src/main/webapp/app/fw &&" + |
| 217 | " jar xf $$ROOT/$(location //web/gui2-fw-lib:gui2_fw_lib_ext_css)) &&" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 218 | " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" + |
Thomas Vachuska | 0c19e65 | 2018-08-28 10:57:07 -0700 | [diff] [blame] | 219 | " export PATH=$$ROOT/$$(dirname $${NODE}):$$ROOT/web/gui2/node_modules/@angular/cli/bin:$$PATH &&" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 220 | " node -v > ../../$(location onos-gui2-ng-ver.log) &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame^] | 221 | " $$ROOT/$(location @nodejs//:bin/npm) -v >> ../../$(location onos-gui2-ng-ver.log) &&" + |
Sean Condon | 50855cf | 2018-12-23 15:37:42 +0000 | [diff] [blame] | 222 | " ng version >> ../../$(location onos-gui2-ng-ver.log);" + |
| 223 | " ng lint > ../../$(location onos-gui2-ng-lint.log) 2>&1 ||" + |
| 224 | " if [ $$? -eq 0 ]; then echo 'Successfully ran lint';" + |
| 225 | " else " + |
| 226 | " echo 'Error running \'ng lint\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" + |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 227 | " See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-lint.log for details' >&2;" + |
| 228 | " cat ../../$(location onos-gui2-ng-lint.log) >&2 ||" + |
Sean Condon | 50855cf | 2018-12-23 15:37:42 +0000 | [diff] [blame] | 229 | " exit 1;" + |
| 230 | " fi;" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 231 | " if [ -f /usr/bin/chromium-browser ]; then " + # Add to this for Mac and Chrome |
| 232 | " export CHROME_BIN=/usr/bin/chromium-browser; " + |
| 233 | " elif [ -f /opt/google/chrome/chrome ]; then " + |
| 234 | " export CHROME_BIN=/opt/google/chrome/chrome; " + |
| 235 | " else " + |
| 236 | " MSG='Warning: Step onos-gui2-ng-test skipped because \\n" + |
| 237 | " no binary for ChromeHeadless browser was found at /usr/bin/chromium-browser. \\n" + |
| 238 | " Install Google Chrome or Chromium Browser to allow this step to run.';" + |
| 239 | " echo -e $$MSG >&2;" + |
| 240 | " echo -e $$MSG > ../../$(location onos-gui2-ng-test.log);" + |
| 241 | " exit 0;" + |
| 242 | " fi;" + |
| 243 | " ng test --preserve-symlinks --code-coverage --browsers=ChromeHeadless" + |
| 244 | " --watch=false > ../../$(location onos-gui2-ng-test.log) 2>&1 ||" + |
| 245 | " if [ $$? -eq 0 ]; then echo 'Successfully ran tests';" + |
| 246 | " else " + |
| 247 | " echo 'Error running \'ng test\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" + |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 248 | " See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-test.log for more details' >&2;" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 249 | #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" + |
| 250 | " exit 1;" + |
| 251 | " fi;", |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame^] | 252 | message = "Angular CLI 8 lint and test", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 253 | ) |
| 254 | |
| 255 | """ |
| 256 | Make a jar file of all the webapp files. Useful for breaking symblic links in the sandbox |
| 257 | """ |
| 258 | |
| 259 | genrule( |
| 260 | name = "_web_app_all", |
| 261 | srcs = glob( |
| 262 | [ |
| 263 | "src/main/webapp/**", |
| 264 | ], |
| 265 | exclude = [ |
| 266 | "src/main/webapp/**/*.spec.ts", # Don't track tests here |
| 267 | "src/main/webapp/tests/**", |
| 268 | "src/main/webapp/node_modules/**", |
| 269 | "src/main/webapp/dist/**", |
| 270 | "src/main/webapp/doc/**", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 271 | "src/main/webapp/app/fw/**", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 272 | ], |
| 273 | ), |
| 274 | outs = ["web_app_all.jar"], |
| 275 | cmd = "cd web/gui2 &&" + |
| 276 | " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" + |
| 277 | " jar Mcf ../../$@ src/main/webapp", |
| 278 | ) |
| 279 | |
| 280 | """ |
| 281 | Make a jar file of all the webapp test (*.spec.ts) files. |
| 282 | """ |
| 283 | |
| 284 | genrule( |
| 285 | name = "_web_app_tests", |
| 286 | srcs = glob( |
| 287 | [ |
| 288 | "src/main/webapp/**/*.spec.ts", |
| 289 | ], |
| 290 | exclude = [ |
| 291 | "src/main/webapp/tests/**", |
| 292 | "src/main/webapp/node_modules/**", |
| 293 | "src/main/webapp/dist/**", |
| 294 | "src/main/webapp/doc/**", |
| 295 | ], |
| 296 | ), |
| 297 | outs = ["web_app_tests.jar"], |
| 298 | cmd = "cd web/gui2 &&" + |
| 299 | " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" + |
| 300 | " jar Mcf ../../$@ src/main/webapp", |
| 301 | ) |
| 302 | |
| 303 | """ |
| 304 | Make a jar file of all the supporting files. Useful for breaking symblic links in the sandbox |
| 305 | """ |
| 306 | |
| 307 | genrule( |
| 308 | name = "_angular_all", |
| 309 | srcs = [ |
| 310 | ":_e2e_test_files", |
| 311 | ":_root_level_files", |
| 312 | ], |
| 313 | outs = ["angular_all.jar"], |
| 314 | cmd = " cd web/gui2 && jar Mcf ../../$@ .", |
| 315 | ) |
| 316 | |
| 317 | """ |
| 318 | Builds the java jar for the java code provided by the GUI2 |
| 319 | """ |
| 320 | |
| 321 | osgi_jar_with_tests( |
| 322 | name = "_onos-gui2-base-jar", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 323 | srcs = |
| 324 | glob([ |
| 325 | "src/main/java/**", |
| 326 | ]) + [ |
| 327 | "//web/gui:onos-gui-java-for-gui2", |
| 328 | ], |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 329 | exclude_tests = [ |
| 330 | "org.onosproject.ui.impl.AbstractUiImplTest", |
| 331 | "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest", |
| 332 | ], |
| 333 | karaf_command_packages = [ |
| 334 | "org.onosproject.ui.impl.cli", |
| 335 | "org.onosproject.ui.impl.topo", |
| 336 | ], |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 337 | suppress_checkstyle = True, |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 338 | test_deps = TEST_DEPS, |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 339 | web_context = "/onos/ui", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 340 | deps = COMPILE_DEPS, |
| 341 | ) |
| 342 | |
| 343 | """ |
| 344 | Builds the tar ball for the ONOS GUI2 |
| 345 | """ |
| 346 | |
| 347 | genrule( |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 348 | name = "onos-web-gui2", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 349 | srcs = [ |
| 350 | ":_onos-gui2-ng-build", |
| 351 | ":_onos-gui2-base-jar", |
| 352 | ":_web_inf_classes_files", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 353 | "//web/gui:onos-gui-lion-for-gui2", |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 354 | "//web/gui:onos-gui-data-for-gui2", |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 355 | "src/main/webapp/WEB-INF/web.xml", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 356 | ], |
| 357 | outs = ["onos-gui2.jar"], |
| 358 | cmd = " ROOT=`pwd` &&" + |
| 359 | " mkdir -p web/gui2/WEB-INF/classes &&" + |
| 360 | " cd web/gui2 &&" + |
| 361 | " BUILD_FILES=($(locations :_onos-gui2-ng-build)) &&" + # An array of filenames - sorted by time created |
| 362 | " for i in $(locations :_web_inf_classes_files); do cp $$ROOT/$$i ./WEB-INF/classes/; done &&" + |
| 363 | " (cd WEB-INF/classes && jar xf $$ROOT/$${BUILD_FILES[1]}) &&" + |
| 364 | " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 365 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-lion-for-gui2) web/gui/src/main/resources/**/* &&" + |
| 366 | " mv web/gui/src/main/resources/org/onosproject/ui/lion* WEB-INF/classes/org/onosproject/ui/ &&" + |
| 367 | " mv web/gui/src/main/resources/core WEB-INF/classes/ &&" + |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 368 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-data-for-gui2) web/gui/src/main/webapp/data/**/* &&" + |
| 369 | " mv web/gui/src/main/webapp/data WEB-INF/classes/ &&" + |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 370 | " find . -type f -exec touch -t 201903200000 {} \; &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 371 | " jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/web.xml WEB-INF/classes OSGI-INF/*.xml", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 372 | output_to_bindir = 1, |
| 373 | visibility = ["//visibility:public"], |
| 374 | ) |
| 375 | |
| 376 | """ |
| 377 | Wrap the genrule for testing in a test |
| 378 | """ |
| 379 | |
| 380 | sh_test( |
| 381 | name = "onos-gui2-ng-tests", |
| 382 | size = "small", |
| 383 | srcs = [ |
| 384 | ":ng-test.sh", |
| 385 | ], |
| 386 | data = [ |
| 387 | ":_onos-gui2-ng-test-genrule", |
| 388 | ], |
| 389 | deps = [ |
| 390 | "@bazel_tools//tools/bash/runfiles", |
| 391 | ], |
| 392 | ) |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 393 | |
| 394 | onos_app( |
| 395 | category = "Graphical User Interface", |
| 396 | description = "ONOS GUI2 - a reengineered version of the original ONOS GUI " + |
| 397 | "based on the latest Angular framework components", |
| 398 | title = "ONOS GUI2", |
| 399 | url = "http://onosproject.org", |
| 400 | ) |