blob: f315b5ebcdc0c819a29c5f5f2d084f62d878a241 [file] [log] [blame]
"""
Copyright 2018-present Open Networking Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
"""
Rules to build the ONOS GUI 2
The GUI2 Angular 7 elements are built here with Angular CLI 'ng'
Some work is being done in the Bazel community to integrate Bazel and
Angular 7, (Angular Buildtools Convergence -
https://docs.google.com/document/d/1OlyiUnoTirUj4gecGxJeZBcjHcFr36RvLsvpBl2mxA8/preview)
but it is in the very early stages (Aug'18) and not yet fit
for production and at present it works as a replacement for Angular CLI
(which is not desirable).
There are plans to extend Bazel it to work with Angular CLI, and if works
well this Bazel file may be rearchiteced in future.
Bazel and npm are incompatibe in how they deal with files. npm likes to
follow links to get back to the original canonical path names, and bazel
uses links extensively when populating the sandbox. To get around these
problems, the rules that follow use filegroups to specify the files as
dependencies and then use a genrule to convert the files into a tar ball.
Once the tar ball is unrolled into the sandbox, the links are broken, but
the build is still hermetic since those files are referred to as dependencies in the genrule.
"""
load("//tools/build/bazel:jdk_genrule.bzl", genrule = "jdk_genrule")
COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [
"@javax_ws_rs_api//jar",
"@servlet_api//jar",
"@jetty_websocket//jar",
"@jetty_websocket_api//jar",
"@jetty_util//jar",
"@jersey_media_multipart//jar",
"@jersey_server//jar",
"@jersey_hk2//jar",
"//utils/rest:onlab-rest",
"//core/store/serializers:onos-core-serializers",
]
TEST_DEPS = TEST + [
"//core/api:onos-api-tests",
"//drivers/default:onos-drivers-default",
]
"""
Builds the java jar for the java code provided by the GUI2
"""
osgi_jar_with_tests(
name = "_onos-gui2-base-jar",
srcs =
glob([
"src/main/java/**",
]) + [
"//web/gui:onos-gui-java-for-gui2",
],
exclude_tests = [
"org.onosproject.ui.impl.AbstractUiImplTest",
"org.onosproject.ui.impl.topo.model.AbstractTopoModelTest",
],
karaf_command_packages = [
"org.onosproject.ui.impl.cli",
"org.onosproject.ui.impl.topo",
],
suppress_checkstyle = True,
test_deps = TEST_DEPS,
web_context = "/onos/ui",
deps = COMPILE_DEPS,
)
"""
Builds the tar ball for the ONOS GUI2
"""
genrule(
name = "onos-web-gui2",
srcs = [
"//web/gui2/src/main/webapp:prodapp",
":_onos-gui2-base-jar",
"//web/gui:onos-gui-lion-for-gui2",
"//web/gui2/src/main/webapp:WEB-INF/web.xml",
],
outs = ["onos-gui2.jar"],
cmd = " ROOT=`pwd` &&" +
" mkdir -p web/gui2/WEB-INF/classes/org/onosproject/ui/ &&" +
" cd web/gui2 &&" +
" jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" +
" unzip -q $$ROOT/$(location //web/gui:onos-gui-lion-for-gui2) web/gui/src/main/resources/**/* &&" +
" mv web/gui/src/main/resources/org/onosproject/ui/lion* WEB-INF/classes/org/onosproject/ui/ &&" +
" cp -R $$ROOT/$(location //web/gui2/src/main/webapp:prodapp)/* WEB-INF/classes/ &&" +
" mv $$ROOT/$(location //web/gui2/src/main/webapp:WEB-INF/web.xml) WEB-INF &&" +
" find . -type f -exec touch -t 202001010001 {} \; &&" +
" jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/web.xml WEB-INF/classes OSGI-INF/*.xml",
output_to_bindir = 1,
visibility = ["//visibility:public"],
)
onos_app(
category = "Graphical User Interface",
description = "ONOS GUI2 - a reengineered version of the original ONOS GUI " +
"based on the latest Angular framework components",
title = "ONOS GUI2",
url = "http://onosproject.org",
)