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 | |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 40 | COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [ |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 41 | "@javax_ws_rs_api//jar", |
| 42 | "@servlet_api//jar", |
| 43 | "@jetty_websocket//jar", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 44 | "@jetty_websocket_api//jar", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 45 | "@jetty_util//jar", |
| 46 | "@jersey_media_multipart//jar", |
| 47 | "@jersey_server//jar", |
Ray Milkey | 427e975 | 2018-11-15 16:34:48 -0800 | [diff] [blame] | 48 | "@jersey_hk2//jar", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 49 | "//utils/rest:onlab-rest", |
| 50 | "//core/store/serializers:onos-core-serializers", |
| 51 | ] |
| 52 | |
| 53 | TEST_DEPS = TEST + [ |
| 54 | "//core/api:onos-api-tests", |
| 55 | "//drivers/default:onos-drivers-default", |
| 56 | ] |
| 57 | |
| 58 | """ |
| 59 | Files that get put at the top level of the tar ball |
| 60 | """ |
| 61 | |
| 62 | filegroup( |
| 63 | name = "_root_level_files", |
| 64 | srcs = |
| 65 | [ |
| 66 | ":angular.json", |
| 67 | ":karma.conf.js", |
| 68 | ":package.json", |
| 69 | ":package-lock.json", |
| 70 | ":protractor.conf.js", |
| 71 | ":src/main/tsconfig.json", |
| 72 | ":src/main/tslint.json", |
| 73 | ":tsconfig.json", |
| 74 | ], |
| 75 | ) |
| 76 | |
| 77 | filegroup( |
| 78 | name = "_e2e_test_files", |
| 79 | srcs = [ |
| 80 | ":e2e/app.e2e-spec.ts", |
| 81 | ":e2e/app.po.ts", |
| 82 | ":e2e/tsconfig.e2e.json", |
| 83 | ], |
| 84 | ) |
| 85 | |
| 86 | """ |
| 87 | Files that get put into the WEB-INF directory of the tar ball |
| 88 | """ |
| 89 | |
| 90 | filegroup( |
| 91 | name = "_web_inf_classes_files", |
| 92 | srcs = |
| 93 | [ |
| 94 | ":src/main/webapp/error.html", |
| 95 | ":src/main/webapp/login.html", |
| 96 | ":src/main/webapp/nav.html", |
| 97 | ":src/main/webapp/not-ready.html", |
Sean Condon | 55c3053 | 2018-10-29 12:26:57 +0000 | [diff] [blame] | 98 | ":src/main/webapp/onos.global.css", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 99 | ], |
| 100 | ) |
| 101 | |
| 102 | """ |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 103 | Run ng build to create outputs in production mode |
| 104 | See bazel-genfiles/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] | 105 | |
| 106 | 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] | 107 | 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] | 108 | structure in ONOS. This copies files in to node_modules, but because the gui2-fw-lib |
| 109 | has not been generated at that time we copy it in separately below with the 'tar' cmd |
| 110 | and then 'mv' |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 111 | """ |
| 112 | |
| 113 | genrule( |
| 114 | name = "_onos-gui2-ng-build", |
| 115 | srcs = [ |
| 116 | "@nodejs//:bin/npm", |
| 117 | "@nodejs//:bin/node", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 118 | "@nodejs//:bin/nodejs/bin/node", |
| 119 | "@nodejs//:bin/nodejs/bin/npm", |
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 | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 123 | "//apps/faultmanagement/fm-gui2-lib:fm-gui2-lib-build", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 124 | ":_root_level_files", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 125 | ":_web_app_all", |
| 126 | ], |
| 127 | outs = [ |
| 128 | "onos-gui2-ng-build-prod.log", |
| 129 | "onos-gui2-ng-build.jar", |
| 130 | ], |
| 131 | cmd = "ROOT=`pwd` &&" + |
| 132 | " export HOME=. &&" + |
| 133 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
| 134 | " NODE=$(location @nodejs//:bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 135 | " INSTALL_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 136 | " 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] | 137 | " mkdir -p web/gui2 && cd web/gui2 &&" + |
| 138 | " jar xf ../../$(location :_web_app_all) &&" + |
| 139 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 140 | " tar xf $$ROOT/$${FWLIB_FILES[0]} &&" + |
| 141 | " mv package/ node_modules/gui2-fw-lib/ &&" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 142 | # Add in modules from external packages |
| 143 | " FM_GUI2_LIB_FILES=($(locations //apps/faultmanagement/fm-gui2-lib:fm-gui2-lib-build)) &&" + # An array of filenames - sorted by time created |
| 144 | " tar xf $$ROOT/$${FM_GUI2_LIB_FILES[0]} &&" + |
| 145 | " mv package/ node_modules/fm-gui2-lib/ &&" + |
| 146 | # End of add in modules from external packages |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 147 | " mkdir -p src/main/webapp/app/fw &&" + |
| 148 | " (cd src/main/webapp/app/fw &&" + |
| 149 | " 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] | 150 | " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" + |
Thomas Vachuska | 0c19e65 | 2018-08-28 10:57:07 -0700 | [diff] [blame] | 151 | " 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] | 152 | " node -v > ../../$(location onos-gui2-ng-build-prod.log) &&" + |
| 153 | " npm -v >> ../../$(location onos-gui2-ng-build-prod.log) &&" + |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 154 | " ng version >> ../../$(location onos-gui2-ng-build-prod.log) &&" + |
| 155 | " ng build --extract-css --prod --preserve-symlinks" + |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame^] | 156 | " --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] | 157 | " if [ $$? -eq 0 ]; then echo 'Successfully ran build';" + |
| 158 | " else " + |
| 159 | " echo 'Error running \'ng build\' on \'//web/gui2:_onos-gui2-ng-build\'. \\\n" + |
| 160 | " See bazel-genfiles/web/gui2/onos-gui2-ng-build-prod.log for more details' >&2;" + |
| 161 | #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" + |
| 162 | " exit 1;" + |
| 163 | " fi;" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 164 | " cd src/main/webapp/dist && jar Mcf $$ROOT/$(location onos-gui2-ng-build.jar) .", |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 165 | message = "Angular CLI 7 build", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 166 | ) |
| 167 | |
| 168 | """ |
| 169 | Run 'ng test' to run Angular test and 'ng lint' for checkstyle |
| 170 | See bazel-genfiles/web/gui2/onos-gui2-ng-lint.log or |
| 171 | bazel-genfiles/web/gui2/onos-gui2-ng-test.log for details of the Angular CLI output |
| 172 | """ |
| 173 | |
| 174 | genrule( |
| 175 | name = "_onos-gui2-ng-test-genrule", |
| 176 | srcs = [ |
| 177 | "@nodejs//:bin/npm", |
| 178 | "@nodejs//:bin/node", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 179 | "@nodejs//:bin/nodejs/bin/node", |
| 180 | "@nodejs//:bin/nodejs/bin/npm", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 181 | "//web/gui2-fw-lib:onos-gui2-fw-npm-install", |
| 182 | "//web/gui2-fw-lib:onos-gui2-fw-ng-build", |
| 183 | "//web/gui2-fw-lib:gui2_fw_lib_ext_css", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 184 | ":_web_app_all", |
| 185 | ":_web_app_tests", |
| 186 | ":_angular_all", |
| 187 | ], |
| 188 | outs = [ |
| 189 | "onos-gui2-ng-ver.log", |
| 190 | "onos-gui2-ng-lint.log", |
| 191 | "onos-gui2-ng-test.log", |
| 192 | ], |
| 193 | cmd = " ROOT=`pwd` &&" + |
| 194 | " export HOME=. &&" + |
| 195 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
| 196 | " NODE=$(location @nodejs//:bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 197 | " INSTALL_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 198 | " 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] | 199 | " mkdir -p web/gui2 &&" + |
| 200 | " cd web/gui2 &&" + |
| 201 | " jar xf ../../$(location :_angular_all) &&" + |
| 202 | " jar xf ../../$(location :_web_app_all) &&" + |
| 203 | " jar xf ../../$(location :_web_app_tests) &&" + |
| 204 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 205 | " tar xf $$ROOT/$${FWLIB_FILES[0]} &&" + |
| 206 | " mv package/ node_modules/gui2-fw-lib/ &&" + |
| 207 | " mkdir -p src/main/webapp/app/fw &&" + |
| 208 | " (cd src/main/webapp/app/fw &&" + |
| 209 | " 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] | 210 | " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" + |
Thomas Vachuska | 0c19e65 | 2018-08-28 10:57:07 -0700 | [diff] [blame] | 211 | " 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] | 212 | " node -v > ../../$(location onos-gui2-ng-ver.log) &&" + |
| 213 | " npm -v >> ../../$(location onos-gui2-ng-ver.log) &&" + |
Sean Condon | 50855cf | 2018-12-23 15:37:42 +0000 | [diff] [blame] | 214 | " ng version >> ../../$(location onos-gui2-ng-ver.log);" + |
| 215 | " ng lint > ../../$(location onos-gui2-ng-lint.log) 2>&1 ||" + |
| 216 | " if [ $$? -eq 0 ]; then echo 'Successfully ran lint';" + |
| 217 | " else " + |
| 218 | " echo 'Error running \'ng lint\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" + |
| 219 | " See bazel-genfiles/web/gui2/onos-gui2-ng-lint.log for more details' >&2;" + |
| 220 | " exit 1;" + |
| 221 | " fi;" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 222 | " if [ -f /usr/bin/chromium-browser ]; then " + # Add to this for Mac and Chrome |
| 223 | " export CHROME_BIN=/usr/bin/chromium-browser; " + |
| 224 | " elif [ -f /opt/google/chrome/chrome ]; then " + |
| 225 | " export CHROME_BIN=/opt/google/chrome/chrome; " + |
| 226 | " else " + |
| 227 | " MSG='Warning: Step onos-gui2-ng-test skipped because \\n" + |
| 228 | " no binary for ChromeHeadless browser was found at /usr/bin/chromium-browser. \\n" + |
| 229 | " Install Google Chrome or Chromium Browser to allow this step to run.';" + |
| 230 | " echo -e $$MSG >&2;" + |
| 231 | " echo -e $$MSG > ../../$(location onos-gui2-ng-test.log);" + |
| 232 | " exit 0;" + |
| 233 | " fi;" + |
| 234 | " ng test --preserve-symlinks --code-coverage --browsers=ChromeHeadless" + |
| 235 | " --watch=false > ../../$(location onos-gui2-ng-test.log) 2>&1 ||" + |
| 236 | " if [ $$? -eq 0 ]; then echo 'Successfully ran tests';" + |
| 237 | " else " + |
| 238 | " echo 'Error running \'ng test\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" + |
| 239 | " See bazel-genfiles/web/gui2/onos-gui2-ng-test.log for more details' >&2;" + |
| 240 | #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" + |
| 241 | " exit 1;" + |
| 242 | " fi;", |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 243 | message = "Angular CLI 7 lint and test", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 244 | ) |
| 245 | |
| 246 | """ |
| 247 | Make a jar file of all the webapp files. Useful for breaking symblic links in the sandbox |
| 248 | """ |
| 249 | |
| 250 | genrule( |
| 251 | name = "_web_app_all", |
| 252 | srcs = glob( |
| 253 | [ |
| 254 | "src/main/webapp/**", |
| 255 | ], |
| 256 | exclude = [ |
| 257 | "src/main/webapp/**/*.spec.ts", # Don't track tests here |
| 258 | "src/main/webapp/tests/**", |
| 259 | "src/main/webapp/node_modules/**", |
| 260 | "src/main/webapp/dist/**", |
| 261 | "src/main/webapp/doc/**", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 262 | "src/main/webapp/app/fw/**", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 263 | ], |
| 264 | ), |
| 265 | outs = ["web_app_all.jar"], |
| 266 | cmd = "cd web/gui2 &&" + |
| 267 | " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" + |
| 268 | " jar Mcf ../../$@ src/main/webapp", |
| 269 | ) |
| 270 | |
| 271 | """ |
| 272 | Make a jar file of all the webapp test (*.spec.ts) files. |
| 273 | """ |
| 274 | |
| 275 | genrule( |
| 276 | name = "_web_app_tests", |
| 277 | srcs = glob( |
| 278 | [ |
| 279 | "src/main/webapp/**/*.spec.ts", |
| 280 | ], |
| 281 | exclude = [ |
| 282 | "src/main/webapp/tests/**", |
| 283 | "src/main/webapp/node_modules/**", |
| 284 | "src/main/webapp/dist/**", |
| 285 | "src/main/webapp/doc/**", |
| 286 | ], |
| 287 | ), |
| 288 | outs = ["web_app_tests.jar"], |
| 289 | cmd = "cd web/gui2 &&" + |
| 290 | " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" + |
| 291 | " jar Mcf ../../$@ src/main/webapp", |
| 292 | ) |
| 293 | |
| 294 | """ |
| 295 | Make a jar file of all the supporting files. Useful for breaking symblic links in the sandbox |
| 296 | """ |
| 297 | |
| 298 | genrule( |
| 299 | name = "_angular_all", |
| 300 | srcs = [ |
| 301 | ":_e2e_test_files", |
| 302 | ":_root_level_files", |
| 303 | ], |
| 304 | outs = ["angular_all.jar"], |
| 305 | cmd = " cd web/gui2 && jar Mcf ../../$@ .", |
| 306 | ) |
| 307 | |
| 308 | """ |
| 309 | Builds the java jar for the java code provided by the GUI2 |
| 310 | """ |
| 311 | |
| 312 | osgi_jar_with_tests( |
| 313 | name = "_onos-gui2-base-jar", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 314 | srcs = |
| 315 | glob([ |
| 316 | "src/main/java/**", |
| 317 | ]) + [ |
| 318 | "//web/gui:onos-gui-java-for-gui2", |
| 319 | ], |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 320 | exclude_tests = [ |
| 321 | "org.onosproject.ui.impl.AbstractUiImplTest", |
| 322 | "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest", |
| 323 | ], |
| 324 | karaf_command_packages = [ |
| 325 | "org.onosproject.ui.impl.cli", |
| 326 | "org.onosproject.ui.impl.topo", |
| 327 | ], |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 328 | suppress_checkstyle = True, |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 329 | test_deps = TEST_DEPS, |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame^] | 330 | web_context = "/onos/ui", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 331 | deps = COMPILE_DEPS, |
| 332 | ) |
| 333 | |
| 334 | """ |
| 335 | Builds the tar ball for the ONOS GUI2 |
| 336 | """ |
| 337 | |
| 338 | genrule( |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame^] | 339 | name = "onos-web-gui2", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 340 | srcs = [ |
| 341 | ":_onos-gui2-ng-build", |
| 342 | ":_onos-gui2-base-jar", |
| 343 | ":_web_inf_classes_files", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 344 | "//web/gui:onos-gui-lion-for-gui2", |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 345 | "//web/gui:onos-gui-data-for-gui2", |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 346 | "src/main/webapp/WEB-INF/web.xml", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 347 | ], |
| 348 | outs = ["onos-gui2.jar"], |
| 349 | cmd = " ROOT=`pwd` &&" + |
| 350 | " mkdir -p web/gui2/WEB-INF/classes &&" + |
| 351 | " cd web/gui2 &&" + |
| 352 | " BUILD_FILES=($(locations :_onos-gui2-ng-build)) &&" + # An array of filenames - sorted by time created |
| 353 | " for i in $(locations :_web_inf_classes_files); do cp $$ROOT/$$i ./WEB-INF/classes/; done &&" + |
| 354 | " (cd WEB-INF/classes && jar xf $$ROOT/$${BUILD_FILES[1]}) &&" + |
| 355 | " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 356 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-lion-for-gui2) web/gui/src/main/resources/**/* &&" + |
| 357 | " mv web/gui/src/main/resources/org/onosproject/ui/lion* WEB-INF/classes/org/onosproject/ui/ &&" + |
| 358 | " mv web/gui/src/main/resources/core WEB-INF/classes/ &&" + |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 359 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-data-for-gui2) web/gui/src/main/webapp/data/**/* &&" + |
| 360 | " mv web/gui/src/main/webapp/data WEB-INF/classes/ &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 361 | " find . -type f -exec touch -t 201901200000 {} \; &&" + |
| 362 | " 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] | 363 | output_to_bindir = 1, |
| 364 | visibility = ["//visibility:public"], |
| 365 | ) |
| 366 | |
| 367 | """ |
| 368 | Wrap the genrule for testing in a test |
| 369 | """ |
| 370 | |
| 371 | sh_test( |
| 372 | name = "onos-gui2-ng-tests", |
| 373 | size = "small", |
| 374 | srcs = [ |
| 375 | ":ng-test.sh", |
| 376 | ], |
| 377 | data = [ |
| 378 | ":_onos-gui2-ng-test-genrule", |
| 379 | ], |
| 380 | deps = [ |
| 381 | "@bazel_tools//tools/bash/runfiles", |
| 382 | ], |
| 383 | ) |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame^] | 384 | |
| 385 | onos_app( |
| 386 | category = "Graphical User Interface", |
| 387 | description = "ONOS GUI2 - a reengineered version of the original ONOS GUI " + |
| 388 | "based on the latest Angular framework components", |
| 389 | title = "ONOS GUI2", |
| 390 | url = "http://onosproject.org", |
| 391 | ) |