Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2018-present Open Networking Foundation |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 6 | http://www.apache.org/licenses/LICENSE-2.0 |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 7 | Unless required by applicable law or agreed to in writing, software |
| 8 | distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | See the License for the specific language governing permissions and |
| 11 | limitations under the License. |
| 12 | """ |
| 13 | |
| 14 | """ |
| 15 | Rules to build the ONOS GUI 2 |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 16 | The GUI2 Angular 7 elements are built here with Angular CLI 'ng' |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 17 | 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] | 18 | Angular 7, (Angular Buildtools Convergence - |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 19 | https://docs.google.com/document/d/1OlyiUnoTirUj4gecGxJeZBcjHcFr36RvLsvpBl2mxA8/preview) |
| 20 | but it is in the very early stages (Aug'18) and not yet fit |
| 21 | for production and at present it works as a replacement for Angular CLI |
| 22 | (which is not desirable). |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 23 | There are plans to extend Bazel it to work with Angular CLI, and if works |
| 24 | well this Bazel file may be rearchiteced in future. |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 25 | Bazel and npm are incompatibe in how they deal with files. npm likes to |
| 26 | follow links to get back to the original canonical path names, and bazel |
| 27 | uses links extensively when populating the sandbox. To get around these |
| 28 | problems, the rules that follow use filegroups to specify the files as |
| 29 | dependencies and then use a genrule to convert the files into a tar ball. |
| 30 | Once the tar ball is unrolled into the sandbox, the links are broken, but |
| 31 | the build is still hermetic since those files are referred to as dependencies in the genrule. |
| 32 | """ |
| 33 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 34 | load("//tools/build/bazel:jdk_genrule.bzl", genrule = "jdk_genrule") |
| 35 | |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 36 | COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [ |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 37 | "@javax_ws_rs_api//jar", |
| 38 | "@servlet_api//jar", |
| 39 | "@jetty_websocket//jar", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 40 | "@jetty_websocket_api//jar", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 41 | "@jetty_util//jar", |
| 42 | "@jersey_media_multipart//jar", |
| 43 | "@jersey_server//jar", |
Ray Milkey | 427e975 | 2018-11-15 16:34:48 -0800 | [diff] [blame] | 44 | "@jersey_hk2//jar", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 45 | "//utils/rest:onlab-rest", |
| 46 | "//core/store/serializers:onos-core-serializers", |
| 47 | ] |
| 48 | |
| 49 | TEST_DEPS = TEST + [ |
| 50 | "//core/api:onos-api-tests", |
| 51 | "//drivers/default:onos-drivers-default", |
| 52 | ] |
| 53 | |
| 54 | """ |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 55 | Builds the java jar for the java code provided by the GUI2 |
| 56 | """ |
| 57 | |
| 58 | osgi_jar_with_tests( |
| 59 | name = "_onos-gui2-base-jar", |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 60 | srcs = |
| 61 | glob([ |
| 62 | "src/main/java/**", |
| 63 | ]) + [ |
| 64 | "//web/gui:onos-gui-java-for-gui2", |
| 65 | ], |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 66 | exclude_tests = [ |
| 67 | "org.onosproject.ui.impl.AbstractUiImplTest", |
| 68 | "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest", |
| 69 | ], |
| 70 | karaf_command_packages = [ |
| 71 | "org.onosproject.ui.impl.cli", |
| 72 | "org.onosproject.ui.impl.topo", |
| 73 | ], |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 74 | suppress_checkstyle = True, |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 75 | test_deps = TEST_DEPS, |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 76 | web_context = "/onos/ui", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 77 | deps = COMPILE_DEPS, |
| 78 | ) |
| 79 | |
| 80 | """ |
| 81 | Builds the tar ball for the ONOS GUI2 |
| 82 | """ |
| 83 | |
| 84 | genrule( |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 85 | name = "onos-web-gui2", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 86 | srcs = [ |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 87 | "//web/gui2/src/main/webapp:prodapp", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 88 | ":_onos-gui2-base-jar", |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 89 | "//web/gui:onos-gui-lion-for-gui2", |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 90 | "//web/gui2/src/main/webapp:WEB-INF/web.xml", |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 91 | ], |
| 92 | outs = ["onos-gui2.jar"], |
| 93 | cmd = " ROOT=`pwd` &&" + |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 94 | " mkdir -p web/gui2/WEB-INF/classes/org/onosproject/ui/ &&" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 95 | " cd web/gui2 &&" + |
Sean Condon | f6af2a5 | 2018-08-19 10:43:24 +0100 | [diff] [blame] | 96 | " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 97 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-lion-for-gui2) web/gui/src/main/resources/**/* &&" + |
| 98 | " mv web/gui/src/main/resources/org/onosproject/ui/lion* WEB-INF/classes/org/onosproject/ui/ &&" + |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 99 | " cp -R $$ROOT/$(location //web/gui2/src/main/webapp:prodapp)/* WEB-INF/classes/ &&" + |
| 100 | " mv $$ROOT/$(location //web/gui2/src/main/webapp:WEB-INF/web.xml) WEB-INF &&" + |
| 101 | " find . -type f -exec touch -t 202001010001 {} \; &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 102 | " 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] | 103 | output_to_bindir = 1, |
| 104 | visibility = ["//visibility:public"], |
| 105 | ) |
| 106 | |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 107 | onos_app( |
| 108 | category = "Graphical User Interface", |
| 109 | description = "ONOS GUI2 - a reengineered version of the original ONOS GUI " + |
| 110 | "based on the latest Angular framework components", |
| 111 | title = "ONOS GUI2", |
| 112 | url = "http://onosproject.org", |
| 113 | ) |