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", |
| 118 | "@nodejs//:bin/node.js", |
| 119 | "@nodejs//:bin/nodejs/bin/node", |
| 120 | "@nodejs//:bin/nodejs/bin/npm", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 121 | "//web/gui2-fw-lib:onos-gui2-fw-npm-install", |
| 122 | "//web/gui2-fw-lib:onos-gui2-fw-ng-build", |
| 123 | "//web/gui2-fw-lib:gui2_fw_lib_ext_css", |
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", |
| 127 | ], |
| 128 | outs = [ |
| 129 | "onos-gui2-ng-build-prod.log", |
| 130 | "onos-gui2-ng-build.jar", |
| 131 | ], |
| 132 | cmd = "ROOT=`pwd` &&" + |
| 133 | " export HOME=. &&" + |
| 134 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
| 135 | " NODE=$(location @nodejs//:bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 136 | " INSTALL_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 137 | " 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] | 138 | " mkdir -p web/gui2 && cd web/gui2 &&" + |
| 139 | " jar xf ../../$(location :_web_app_all) &&" + |
| 140 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 141 | " tar xf $$ROOT/$${FWLIB_FILES[0]} &&" + |
| 142 | " mv package/ node_modules/gui2-fw-lib/ &&" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 143 | # Add in modules from external packages |
| 144 | " FM_GUI2_LIB_FILES=($(locations //apps/faultmanagement/fm-gui2-lib:fm-gui2-lib-build)) &&" + # An array of filenames - sorted by time created |
| 145 | " tar xf $$ROOT/$${FM_GUI2_LIB_FILES[0]} &&" + |
| 146 | " mv package/ node_modules/fm-gui2-lib/ &&" + |
| 147 | # End of add in modules from external packages |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 148 | " mkdir -p src/main/webapp/app/fw &&" + |
| 149 | " (cd src/main/webapp/app/fw &&" + |
| 150 | " 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] | 151 | " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" + |
Thomas Vachuska | 0c19e65 | 2018-08-28 10:57:07 -0700 | [diff] [blame] | 152 | " 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] | 153 | " node -v > ../../$(location onos-gui2-ng-build-prod.log) &&" + |
| 154 | " npm -v >> ../../$(location onos-gui2-ng-build-prod.log) &&" + |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 155 | " ng version >> ../../$(location onos-gui2-ng-build-prod.log) &&" + |
| 156 | " ng build --extract-css --prod --preserve-symlinks" + |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 157 | " --base-href /onos/ui2/ --deploy-url /onos/ui2/ >> $$ROOT/$(location onos-gui2-ng-build-prod.log) 2>&1 ||" + |
| 158 | " if [ $$? -eq 0 ]; then echo 'Successfully ran build';" + |
| 159 | " else " + |
| 160 | " echo 'Error running \'ng build\' on \'//web/gui2:_onos-gui2-ng-build\'. \\\n" + |
| 161 | " See bazel-genfiles/web/gui2/onos-gui2-ng-build-prod.log for more details' >&2;" + |
| 162 | #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" + |
| 163 | " exit 1;" + |
| 164 | " fi;" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 165 | " 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] | 166 | message = "Angular CLI 7 build", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 167 | ) |
| 168 | |
| 169 | """ |
| 170 | Run 'ng test' to run Angular test and 'ng lint' for checkstyle |
| 171 | See bazel-genfiles/web/gui2/onos-gui2-ng-lint.log or |
| 172 | bazel-genfiles/web/gui2/onos-gui2-ng-test.log for details of the Angular CLI output |
| 173 | """ |
| 174 | |
| 175 | genrule( |
| 176 | name = "_onos-gui2-ng-test-genrule", |
| 177 | srcs = [ |
| 178 | "@nodejs//:bin/npm", |
| 179 | "@nodejs//:bin/node", |
| 180 | "@nodejs//:bin/node.js", |
| 181 | "@nodejs//:bin/nodejs/bin/node", |
| 182 | "@nodejs//:bin/nodejs/bin/npm", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 183 | "//web/gui2-fw-lib:onos-gui2-fw-npm-install", |
| 184 | "//web/gui2-fw-lib:onos-gui2-fw-ng-build", |
| 185 | "//web/gui2-fw-lib:gui2_fw_lib_ext_css", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 186 | ":_web_app_all", |
| 187 | ":_web_app_tests", |
| 188 | ":_angular_all", |
| 189 | ], |
| 190 | outs = [ |
| 191 | "onos-gui2-ng-ver.log", |
| 192 | "onos-gui2-ng-lint.log", |
| 193 | "onos-gui2-ng-test.log", |
| 194 | ], |
| 195 | cmd = " ROOT=`pwd` &&" + |
| 196 | " export HOME=. &&" + |
| 197 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
| 198 | " NODE=$(location @nodejs//:bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 199 | " INSTALL_FILES=($(locations //web/gui2-fw-lib:onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 200 | " 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] | 201 | " mkdir -p web/gui2 &&" + |
| 202 | " cd web/gui2 &&" + |
| 203 | " jar xf ../../$(location :_angular_all) &&" + |
| 204 | " jar xf ../../$(location :_web_app_all) &&" + |
| 205 | " jar xf ../../$(location :_web_app_tests) &&" + |
| 206 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 207 | " tar xf $$ROOT/$${FWLIB_FILES[0]} &&" + |
| 208 | " mv package/ node_modules/gui2-fw-lib/ &&" + |
| 209 | " mkdir -p src/main/webapp/app/fw &&" + |
| 210 | " (cd src/main/webapp/app/fw &&" + |
| 211 | " 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] | 212 | " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" + |
Thomas Vachuska | 0c19e65 | 2018-08-28 10:57:07 -0700 | [diff] [blame] | 213 | " 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] | 214 | " node -v > ../../$(location onos-gui2-ng-ver.log) &&" + |
| 215 | " npm -v >> ../../$(location onos-gui2-ng-ver.log) &&" + |
Sean Condon | 50855cf | 2018-12-23 15:37:42 +0000 | [diff] [blame] | 216 | " ng version >> ../../$(location onos-gui2-ng-ver.log);" + |
| 217 | " ng lint > ../../$(location onos-gui2-ng-lint.log) 2>&1 ||" + |
| 218 | " if [ $$? -eq 0 ]; then echo 'Successfully ran lint';" + |
| 219 | " else " + |
| 220 | " echo 'Error running \'ng lint\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" + |
| 221 | " See bazel-genfiles/web/gui2/onos-gui2-ng-lint.log for more details' >&2;" + |
| 222 | " exit 1;" + |
| 223 | " fi;" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 224 | " if [ -f /usr/bin/chromium-browser ]; then " + # Add to this for Mac and Chrome |
| 225 | " export CHROME_BIN=/usr/bin/chromium-browser; " + |
| 226 | " elif [ -f /opt/google/chrome/chrome ]; then " + |
| 227 | " export CHROME_BIN=/opt/google/chrome/chrome; " + |
| 228 | " else " + |
| 229 | " MSG='Warning: Step onos-gui2-ng-test skipped because \\n" + |
| 230 | " no binary for ChromeHeadless browser was found at /usr/bin/chromium-browser. \\n" + |
| 231 | " Install Google Chrome or Chromium Browser to allow this step to run.';" + |
| 232 | " echo -e $$MSG >&2;" + |
| 233 | " echo -e $$MSG > ../../$(location onos-gui2-ng-test.log);" + |
| 234 | " exit 0;" + |
| 235 | " fi;" + |
| 236 | " ng test --preserve-symlinks --code-coverage --browsers=ChromeHeadless" + |
| 237 | " --watch=false > ../../$(location onos-gui2-ng-test.log) 2>&1 ||" + |
| 238 | " if [ $$? -eq 0 ]; then echo 'Successfully ran tests';" + |
| 239 | " else " + |
| 240 | " echo 'Error running \'ng test\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" + |
| 241 | " See bazel-genfiles/web/gui2/onos-gui2-ng-test.log for more details' >&2;" + |
| 242 | #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" + |
| 243 | " exit 1;" + |
| 244 | " fi;", |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 245 | message = "Angular CLI 7 lint and test", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 246 | ) |
| 247 | |
| 248 | """ |
| 249 | Make a jar file of all the webapp files. Useful for breaking symblic links in the sandbox |
| 250 | """ |
| 251 | |
| 252 | genrule( |
| 253 | name = "_web_app_all", |
| 254 | srcs = glob( |
| 255 | [ |
| 256 | "src/main/webapp/**", |
| 257 | ], |
| 258 | exclude = [ |
| 259 | "src/main/webapp/**/*.spec.ts", # Don't track tests here |
| 260 | "src/main/webapp/tests/**", |
| 261 | "src/main/webapp/node_modules/**", |
| 262 | "src/main/webapp/dist/**", |
| 263 | "src/main/webapp/doc/**", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 264 | "src/main/webapp/app/fw/**", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 265 | ], |
| 266 | ), |
| 267 | outs = ["web_app_all.jar"], |
| 268 | cmd = "cd web/gui2 &&" + |
| 269 | " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" + |
| 270 | " jar Mcf ../../$@ src/main/webapp", |
| 271 | ) |
| 272 | |
| 273 | """ |
| 274 | Make a jar file of all the webapp test (*.spec.ts) files. |
| 275 | """ |
| 276 | |
| 277 | genrule( |
| 278 | name = "_web_app_tests", |
| 279 | srcs = glob( |
| 280 | [ |
| 281 | "src/main/webapp/**/*.spec.ts", |
| 282 | ], |
| 283 | exclude = [ |
| 284 | "src/main/webapp/tests/**", |
| 285 | "src/main/webapp/node_modules/**", |
| 286 | "src/main/webapp/dist/**", |
| 287 | "src/main/webapp/doc/**", |
| 288 | ], |
| 289 | ), |
| 290 | outs = ["web_app_tests.jar"], |
| 291 | cmd = "cd web/gui2 &&" + |
| 292 | " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" + |
| 293 | " jar Mcf ../../$@ src/main/webapp", |
| 294 | ) |
| 295 | |
| 296 | """ |
| 297 | Make a jar file of all the supporting files. Useful for breaking symblic links in the sandbox |
| 298 | """ |
| 299 | |
| 300 | genrule( |
| 301 | name = "_angular_all", |
| 302 | srcs = [ |
| 303 | ":_e2e_test_files", |
| 304 | ":_root_level_files", |
| 305 | ], |
| 306 | outs = ["angular_all.jar"], |
| 307 | cmd = " cd web/gui2 && jar Mcf ../../$@ .", |
| 308 | ) |
| 309 | |
| 310 | """ |
| 311 | Builds the java jar for the java code provided by the GUI2 |
| 312 | """ |
| 313 | |
| 314 | osgi_jar_with_tests( |
| 315 | name = "_onos-gui2-base-jar", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 316 | srcs = |
| 317 | glob([ |
| 318 | "src/main/java/**", |
| 319 | ]) + [ |
| 320 | "//web/gui:onos-gui-java-for-gui2", |
| 321 | ], |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 322 | exclude_tests = [ |
| 323 | "org.onosproject.ui.impl.AbstractUiImplTest", |
| 324 | "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest", |
| 325 | ], |
| 326 | karaf_command_packages = [ |
| 327 | "org.onosproject.ui.impl.cli", |
| 328 | "org.onosproject.ui.impl.topo", |
| 329 | ], |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 330 | suppress_checkstyle = True, |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 331 | test_deps = TEST_DEPS, |
| 332 | web_context = "/onos/ui2", |
| 333 | deps = COMPILE_DEPS, |
| 334 | ) |
| 335 | |
| 336 | """ |
| 337 | Builds the tar ball for the ONOS GUI2 |
| 338 | """ |
| 339 | |
| 340 | genrule( |
| 341 | name = "onos-gui2", |
| 342 | srcs = [ |
| 343 | ":_onos-gui2-ng-build", |
| 344 | ":_onos-gui2-base-jar", |
| 345 | ":_web_inf_classes_files", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 346 | "//web/gui:onos-gui-lion-for-gui2", |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 347 | "src/main/webapp/WEB-INF/web.xml", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 348 | ], |
| 349 | outs = ["onos-gui2.jar"], |
| 350 | cmd = " ROOT=`pwd` &&" + |
| 351 | " mkdir -p web/gui2/WEB-INF/classes &&" + |
| 352 | " cd web/gui2 &&" + |
| 353 | " BUILD_FILES=($(locations :_onos-gui2-ng-build)) &&" + # An array of filenames - sorted by time created |
| 354 | " for i in $(locations :_web_inf_classes_files); do cp $$ROOT/$$i ./WEB-INF/classes/; done &&" + |
| 355 | " (cd WEB-INF/classes && jar xf $$ROOT/$${BUILD_FILES[1]}) &&" + |
| 356 | " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 357 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-lion-for-gui2) web/gui/src/main/resources/**/* &&" + |
| 358 | " mv web/gui/src/main/resources/org/onosproject/ui/lion* WEB-INF/classes/org/onosproject/ui/ &&" + |
| 359 | " mv web/gui/src/main/resources/core WEB-INF/classes/ &&" + |
| 360 | " find . -type f -exec touch -t 201901200000 {} \; &&" + |
| 361 | " 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] | 362 | output_to_bindir = 1, |
| 363 | visibility = ["//visibility:public"], |
| 364 | ) |
| 365 | |
| 366 | """ |
| 367 | Wrap the genrule for testing in a test |
| 368 | """ |
| 369 | |
| 370 | sh_test( |
| 371 | name = "onos-gui2-ng-tests", |
| 372 | size = "small", |
| 373 | srcs = [ |
| 374 | ":ng-test.sh", |
| 375 | ], |
| 376 | data = [ |
| 377 | ":_onos-gui2-ng-test-genrule", |
| 378 | ], |
| 379 | deps = [ |
| 380 | "@bazel_tools//tools/bash/runfiles", |
| 381 | ], |
| 382 | ) |