blob: f315b5ebcdc0c819a29c5f5f2d084f62d878a241 [file] [log] [blame]
Sean Condonf6af2a52018-08-19 10:43:24 +01001"""
2 Copyright 2018-present Open Networking Foundation
Sean Condonf6af2a52018-08-19 10:43:24 +01003 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 Condonf6af2a52018-08-19 10:43:24 +01006 http://www.apache.org/licenses/LICENSE-2.0
Sean Condonf6af2a52018-08-19 10:43:24 +01007 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 Condon0c577f62018-11-18 22:40:05 +000016 The GUI2 Angular 7 elements are built here with Angular CLI 'ng'
Sean Condonf6af2a52018-08-19 10:43:24 +010017 Some work is being done in the Bazel community to integrate Bazel and
Sean Condon0c577f62018-11-18 22:40:05 +000018 Angular 7, (Angular Buildtools Convergence -
Sean Condonf6af2a52018-08-19 10:43:24 +010019 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 Condonf6af2a52018-08-19 10:43:24 +010023 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 Condonf6af2a52018-08-19 10:43:24 +010025 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 Casconed33d3b42019-06-18 12:12:36 -070034load("//tools/build/bazel:jdk_genrule.bzl", genrule = "jdk_genrule")
35
Sean Condonb2c483c2019-01-16 20:28:55 +000036COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [
Sean Condonf6af2a52018-08-19 10:43:24 +010037 "@javax_ws_rs_api//jar",
38 "@servlet_api//jar",
39 "@jetty_websocket//jar",
Sean Condonb2c483c2019-01-16 20:28:55 +000040 "@jetty_websocket_api//jar",
Sean Condonf6af2a52018-08-19 10:43:24 +010041 "@jetty_util//jar",
42 "@jersey_media_multipart//jar",
43 "@jersey_server//jar",
Ray Milkey427e9752018-11-15 16:34:48 -080044 "@jersey_hk2//jar",
Sean Condonf6af2a52018-08-19 10:43:24 +010045 "//utils/rest:onlab-rest",
46 "//core/store/serializers:onos-core-serializers",
47]
48
49TEST_DEPS = TEST + [
50 "//core/api:onos-api-tests",
51 "//drivers/default:onos-drivers-default",
52]
53
54"""
Sean Condonf6af2a52018-08-19 10:43:24 +010055 Builds the java jar for the java code provided by the GUI2
56"""
57
58osgi_jar_with_tests(
59 name = "_onos-gui2-base-jar",
Sean Condon87b78502018-09-17 20:53:24 +010060 srcs =
61 glob([
62 "src/main/java/**",
63 ]) + [
64 "//web/gui:onos-gui-java-for-gui2",
65 ],
Sean Condonb2c483c2019-01-16 20:28:55 +000066 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 Condon3c8e5582018-08-28 23:22:43 +010074 suppress_checkstyle = True,
Sean Condonf6af2a52018-08-19 10:43:24 +010075 test_deps = TEST_DEPS,
Sean Condonbf7ff4f2019-03-17 16:18:42 +000076 web_context = "/onos/ui",
Sean Condonf6af2a52018-08-19 10:43:24 +010077 deps = COMPILE_DEPS,
78)
79
80"""
81 Builds the tar ball for the ONOS GUI2
82"""
83
84genrule(
Sean Condonbf7ff4f2019-03-17 16:18:42 +000085 name = "onos-web-gui2",
Sean Condonf6af2a52018-08-19 10:43:24 +010086 srcs = [
Sean Condon98b6ddb2019-12-24 08:07:40 +000087 "//web/gui2/src/main/webapp:prodapp",
Sean Condonf6af2a52018-08-19 10:43:24 +010088 ":_onos-gui2-base-jar",
Sean Condonb2c483c2019-01-16 20:28:55 +000089 "//web/gui:onos-gui-lion-for-gui2",
Sean Condon98b6ddb2019-12-24 08:07:40 +000090 "//web/gui2/src/main/webapp:WEB-INF/web.xml",
Sean Condonf6af2a52018-08-19 10:43:24 +010091 ],
92 outs = ["onos-gui2.jar"],
93 cmd = " ROOT=`pwd` &&" +
Sean Condon98b6ddb2019-12-24 08:07:40 +000094 " mkdir -p web/gui2/WEB-INF/classes/org/onosproject/ui/ &&" +
Sean Condonf6af2a52018-08-19 10:43:24 +010095 " cd web/gui2 &&" +
Sean Condonf6af2a52018-08-19 10:43:24 +010096 " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" +
Sean Condonb2c483c2019-01-16 20:28:55 +000097 " 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 Condon98b6ddb2019-12-24 08:07:40 +000099 " 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 Condonb2c483c2019-01-16 20:28:55 +0000102 " jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/web.xml WEB-INF/classes OSGI-INF/*.xml",
Sean Condonf6af2a52018-08-19 10:43:24 +0100103 output_to_bindir = 1,
104 visibility = ["//visibility:public"],
105)
106
Sean Condonbf7ff4f2019-03-17 16:18:42 +0000107onos_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)