Adding GUI2 to the Bazel build system
Change-Id: Ieb39ade1a8713a50fdf885e2bb43f53f8f725ea8
diff --git a/web/gui2/BUILD b/web/gui2/BUILD
new file mode 100644
index 0000000..c50c654
--- /dev/null
+++ b/web/gui2/BUILD
@@ -0,0 +1,353 @@
+"""
+ 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 6 elements are built here with Angular CLI 'ng'
+ Some work is being done in the Bazel community to integrate Bazel and
+ Angular 6, (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.
+"""
+
+COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + [
+ "@javax_ws_rs_api//jar",
+ "@servlet_api//jar",
+ "@jetty_websocket//jar",
+ "@jetty_util//jar",
+ "@jersey_media_multipart//jar",
+ "@jersey_server//jar",
+ "//utils/rest:onlab-rest",
+ "//core/store/serializers:onos-core-serializers",
+]
+
+TEST_DEPS = TEST + [
+ "//core/api:onos-api-tests",
+ "//drivers/default:onos-drivers-default",
+]
+
+"""
+ Files that get put at the top level of the tar ball
+"""
+
+filegroup(
+ name = "_root_level_files",
+ srcs =
+ [
+ ":angular.json",
+ ":karma.conf.js",
+ ":package.json",
+ ":package-lock.json",
+ ":protractor.conf.js",
+ ":src/main/tsconfig.json",
+ ":src/main/tslint.json",
+ ":tsconfig.json",
+ ],
+)
+
+filegroup(
+ name = "_e2e_test_files",
+ srcs = [
+ ":e2e/app.e2e-spec.ts",
+ ":e2e/app.po.ts",
+ ":e2e/tsconfig.e2e.json",
+ ],
+)
+
+"""
+ Files that get put into the WEB-INF directory of the tar ball
+"""
+
+filegroup(
+ name = "_web_inf_classes_files",
+ srcs =
+ [
+ ":src/main/webapp/error.html",
+ ":src/main/webapp/login.html",
+ ":src/main/webapp/nav.html",
+ ":src/main/webapp/not-ready.html",
+ ":src/main/webapp/onos.theme.css",
+ ],
+)
+
+"""
+ Install npm packages listed in package.json in web/gui2
+ See bazel-genfiles/web/gui2/onos-gui2-npm-install.log for details of the 'npm install'
+"""
+
+genrule(
+ name = "_onos-gui2-npm-install",
+ srcs = [
+ "@nodejs//:bin/npm",
+ "@nodejs//:bin/node",
+ "@nodejs//:bin/node.js",
+ "@nodejs//:bin/nodejs/bin/node",
+ "@nodejs//:bin/nodejs/bin/npm",
+ ":_root_level_files",
+ ],
+ outs = [
+ "onos-gui2-npm-install.jar",
+ "onos-gui2-npm-install.log",
+ ],
+ cmd = " ROOT=`pwd` &&" +
+ " export HOME=. &&" +
+ " export XDG_CONFIG_HOME=$(@D)/config &&" + # npm config cache to the sandbox
+ " export BABEL_DISABLE_CACHE=1 &&" + # turn off babel cache
+ " NPM=$$ROOT/$(location @nodejs//:bin/npm) &&" +
+ " mkdir -p web/gui2 &&" +
+ " cd web/gui2 &&" +
+ " $$NPM install --no-cache --loglevel=error > $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" +
+ " jar Mcf $$ROOT/$(location onos-gui2-npm-install.jar) . &&" +
+ " touch $$ROOT/$(location onos-gui2-npm-install.log)", # to get the log always as the 2nd file
+ visibility = ["//visibility:public"],
+)
+
+"""
+ Run ng build to create outputs in production mode
+ See bazel-genfiles/web/gui2/onos-gui2-ng-build-prod.log for details of the Angular CLI output
+"""
+
+genrule(
+ name = "_onos-gui2-ng-build",
+ srcs = [
+ "@nodejs//:bin/npm",
+ "@nodejs//:bin/node",
+ "@nodejs//:bin/node.js",
+ "@nodejs//:bin/nodejs/bin/node",
+ "@nodejs//:bin/nodejs/bin/npm",
+ ":_onos-gui2-npm-install",
+ ":_web_app_all",
+ ],
+ outs = [
+ "onos-gui2-ng-build-prod.log",
+ "onos-gui2-ng-build.jar",
+ ],
+ cmd = "ROOT=`pwd` &&" +
+ " export HOME=. &&" +
+ " export XDG_CONFIG_HOME=$(@D)/config &&" +
+ " NODE=$(location @nodejs//:bin/node) &&" +
+ " INSTALL_FILES=($(locations :_onos-gui2-npm-install)) &&" + # An array of filenames - sorted by time created
+ " mkdir -p web/gui2 && cd web/gui2 &&" +
+ " jar xf ../../$(location :_web_app_all) &&" +
+ " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" +
+ " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" +
+ " export PATH=$$ROOT/$${NODE::-5}:$$ROOT/web/gui2/node_modules/@angular/cli/bin:$$PATH &&" +
+ " node -v > ../../$(location onos-gui2-ng-build-prod.log) &&" +
+ " npm -v >> ../../$(location onos-gui2-ng-build-prod.log) &&" +
+ " ng -v >> ../../$(location onos-gui2-ng-build-prod.log) &&" +
+ # Build it in production mode - optimization is turned off because of Angular CLI 6.0.x bug https://github.com/angular/angular-cli/issues/7799
+ " ng build --extract-css --prod --optimization=false --preserve-symlinks --base-href /onos/ui2/ --deploy-url /onos/ui2/ >> $$ROOT/$(location onos-gui2-ng-build-prod.log) 2>&1 &&" +
+ " cd src/main/webapp/dist && jar Mcf $$ROOT/$(location onos-gui2-ng-build.jar) .",
+ message = "Angular CLI 6 build",
+)
+
+"""
+ Run 'ng test' to run Angular test and 'ng lint' for checkstyle
+ See bazel-genfiles/web/gui2/onos-gui2-ng-lint.log or
+ bazel-genfiles/web/gui2/onos-gui2-ng-test.log for details of the Angular CLI output
+"""
+
+genrule(
+ name = "_onos-gui2-ng-test-genrule",
+ srcs = [
+ "@nodejs//:bin/npm",
+ "@nodejs//:bin/node",
+ "@nodejs//:bin/node.js",
+ "@nodejs//:bin/nodejs/bin/node",
+ "@nodejs//:bin/nodejs/bin/npm",
+ ":_onos-gui2-npm-install",
+ ":_web_app_all",
+ ":_web_app_tests",
+ ":_angular_all",
+ ],
+ outs = [
+ "onos-gui2-ng-ver.log",
+ "onos-gui2-ng-lint.log",
+ "onos-gui2-ng-test.log",
+ ],
+ cmd = " ROOT=`pwd` &&" +
+ " export HOME=. &&" +
+ " export XDG_CONFIG_HOME=$(@D)/config &&" +
+ " NODE=$(location @nodejs//:bin/node) &&" +
+ " INSTALL_FILES=($(locations :_onos-gui2-npm-install)) &&" + # An array of filenames - sorted by time created
+ " mkdir -p web/gui2 &&" +
+ " cd web/gui2 &&" +
+ " jar xf ../../$(location :_angular_all) &&" +
+ " jar xf ../../$(location :_web_app_all) &&" +
+ " jar xf ../../$(location :_web_app_tests) &&" +
+ " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" +
+ " chmod +x $$ROOT/web/gui2/node_modules/@angular/cli/bin/ng &&" +
+ " export PATH=$$ROOT/$${NODE::-5}:$$ROOT/web/gui2/node_modules/@angular/cli/bin:$$PATH &&" +
+ " node -v > ../../$(location onos-gui2-ng-ver.log) &&" +
+ " npm -v >> ../../$(location onos-gui2-ng-ver.log) &&" +
+ " ng -v >> ../../$(location onos-gui2-ng-ver.log) &&" +
+ " ng lint > ../../$(location onos-gui2-ng-lint.log);" +
+ " if [ -f /usr/bin/chromium-browser ]; then " + # Add to this for Mac and Chrome
+ " export CHROME_BIN=/usr/bin/chromium-browser; " +
+ " elif [ -f /opt/google/chrome/chrome ]; then " +
+ " export CHROME_BIN=/opt/google/chrome/chrome; " +
+ " else " +
+ " MSG='Warning: Step onos-gui2-ng-test skipped because \\n" +
+ " no binary for ChromeHeadless browser was found at /usr/bin/chromium-browser. \\n" +
+ " Install Google Chrome or Chromium Browser to allow this step to run.';" +
+ " echo -e $$MSG >&2;" +
+ " echo -e $$MSG > ../../$(location onos-gui2-ng-test.log);" +
+ " exit 0;" +
+ " fi;" +
+ " ng test --preserve-symlinks --code-coverage --browsers=ChromeHeadless" +
+ " --watch=false > ../../$(location onos-gui2-ng-test.log) 2>&1 ||" +
+ " if [ $$? -eq 0 ]; then echo 'Successfully ran tests';" +
+ " else " +
+ " echo 'Error running \'ng test\' on \'//web/gui2:onos-gui2-ng-test\'. \\\n" +
+ " See bazel-genfiles/web/gui2/onos-gui2-ng-test.log for more details' >&2;" +
+ #" tail -n 100 ../../$(location onos-gui2-ng-test.log) >&2;" +
+ " exit 1;" +
+ " fi;",
+ message = "Angular CLI 6 lint and test",
+)
+
+"""
+ Make a jar file of all the webapp files. Useful for breaking symblic links in the sandbox
+"""
+
+genrule(
+ name = "_web_app_all",
+ srcs = glob(
+ [
+ "src/main/webapp/**",
+ ],
+ exclude = [
+ "src/main/webapp/**/*.spec.ts", # Don't track tests here
+ "src/main/webapp/tests/**",
+ "src/main/webapp/node_modules/**",
+ "src/main/webapp/dist/**",
+ "src/main/webapp/doc/**",
+ ],
+ ),
+ outs = ["web_app_all.jar"],
+ cmd = "cd web/gui2 &&" +
+ " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" +
+ " jar Mcf ../../$@ src/main/webapp",
+)
+
+"""
+ Make a jar file of all the webapp test (*.spec.ts) files.
+"""
+
+genrule(
+ name = "_web_app_tests",
+ srcs = glob(
+ [
+ "src/main/webapp/**/*.spec.ts",
+ ],
+ exclude = [
+ "src/main/webapp/tests/**",
+ "src/main/webapp/node_modules/**",
+ "src/main/webapp/dist/**",
+ "src/main/webapp/doc/**",
+ ],
+ ),
+ outs = ["web_app_tests.jar"],
+ cmd = "cd web/gui2 &&" +
+ " find src/main/webapp -type f -exec touch -t 201808280000 {} \; &&" +
+ " jar Mcf ../../$@ src/main/webapp",
+)
+
+"""
+ Make a jar file of all the supporting files. Useful for breaking symblic links in the sandbox
+"""
+
+genrule(
+ name = "_angular_all",
+ srcs = [
+ ":_e2e_test_files",
+ ":_root_level_files",
+ ],
+ outs = ["angular_all.jar"],
+ cmd = " cd web/gui2 && jar Mcf ../../$@ .",
+)
+
+"""
+ Builds the java jar for the java code provided by the GUI2
+"""
+
+osgi_jar_with_tests(
+ name = "_onos-gui2-base-jar",
+ exclude_tests = [
+ "org.onosproject.ui.impl.AbstractUiImplTest",
+ "org.onosproject.ui.impl.topo.model.AbstractTopoModelTest",
+ ],
+ test_deps = TEST_DEPS,
+ web_context = "/onos/ui2",
+ deps = COMPILE_DEPS,
+)
+
+"""
+ Builds the tar ball for the ONOS GUI2
+"""
+
+genrule(
+ name = "onos-gui2",
+ srcs = [
+ ":_onos-gui2-ng-build",
+ ":_onos-gui2-base-jar",
+ ":_web_inf_classes_files",
+ ],
+ outs = ["onos-gui2.jar"],
+ cmd = " ROOT=`pwd` &&" +
+ " mkdir -p web/gui2/WEB-INF/classes &&" +
+ " cd web/gui2 &&" +
+ " BUILD_FILES=($(locations :_onos-gui2-ng-build)) &&" + # An array of filenames - sorted by time created
+ " for i in $(locations :_web_inf_classes_files); do cp $$ROOT/$$i ./WEB-INF/classes/; done &&" +
+ " (cd WEB-INF/classes && jar xf $$ROOT/$${BUILD_FILES[1]}) &&" +
+ " jar xf $$ROOT/$(location :_onos-gui2-base-jar) &&" +
+ " find . -type f -exec touch -t 201808280000 {} \; &&" +
+ " jar cmf META-INF/MANIFEST.MF $$ROOT/$@ WEB-INF/classes",
+ output_to_bindir = 1,
+ visibility = ["//visibility:public"],
+)
+
+"""
+ Wrap the genrule for testing in a test
+"""
+
+sh_test(
+ name = "onos-gui2-ng-tests",
+ size = "small",
+ srcs = [
+ ":ng-test.sh",
+ ],
+ data = [
+ ":_onos-gui2-ng-test-genrule",
+ ],
+ deps = [
+ "@bazel_tools//tools/bash/runfiles",
+ ],
+)
diff --git a/web/gui2/ng-test.sh b/web/gui2/ng-test.sh
new file mode 100755
index 0000000..0970a5a
--- /dev/null
+++ b/web/gui2/ng-test.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+set -euo pipefail
+# --- begin runfiles.bash initialization ---
+if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ if [[ -f "$0.runfiles_manifest" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
+ elif [[ -f "$0.runfiles/MANIFEST" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
+ elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ fi
+fi
+
+if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+
+# --- end runfiles.bash initialization ---
+echo "Test results for Angular CLI commands run in onos-gui2-ng-tests outputs at:"
+ls $(rlocation org_onosproject_onos/web/gui2/onos-gui2-ng-ver.log)
+ls $(rlocation org_onosproject_onos/web/gui2/onos-gui2-ng-lint.log)
+ls $(rlocation org_onosproject_onos/web/gui2/onos-gui2-ng-test.log)
+
diff --git a/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java b/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java
new file mode 100644
index 0000000..643e597
--- /dev/null
+++ b/web/gui2/src/main/java/org/onosproject/ui/impl/DummyClass.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+package org.onosproject.ui.impl;
+
+/**
+ * A dummy class to satisfy Bazel build.
+ * Since all classes implementing the REST interface to the GUI framework for GUI2
+ * are in the /web/gui project, no classes are needed here.
+ */
+public final class DummyClass {
+ private static final String DUMMY_ATTRIBUTE = "test";
+
+ private DummyClass() {
+ //Hidden
+ }
+
+ static String getDummyAttribute() {
+ return DUMMY_ATTRIBUTE;
+ }
+}
diff --git a/web/gui2/src/main/java/org/onosproject/ui/impl/MainIndexResource.java b/web/gui2/src/main/java/org/onosproject/ui/impl/MainIndexResource.java
deleted file mode 100644
index 377bc44..0000000
--- a/web/gui2/src/main/java/org/onosproject/ui/impl/MainIndexResource.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2015-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.
- */
-package org.onosproject.ui.impl;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import org.onlab.osgi.ServiceNotFoundException;
-import org.onosproject.rest.AbstractInjectionResource;
-import org.onosproject.ui.UiExtensionService;
-import org.onosproject.ui.UiPreferencesService;
-import org.onosproject.ui.UiSessionToken;
-import org.onosproject.ui.UiTokenService;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.SecurityContext;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.SequenceInputStream;
-
-import static com.google.common.collect.ImmutableList.of;
-import static com.google.common.io.ByteStreams.toByteArray;
-
-/**
- * Resource for serving the dynamically composed index.html.
- */
-@Path("/")
-public class MainIndexResource extends AbstractInjectionResource {
-
- private static final String INDEX = "dist/index.html";
- private static final String NOT_READY = "not-ready.html";
-
- private static final String INJECT_USER_START = "<!-- {INJECTED-USER-START} -->";
- private static final String INJECT_USER_END = "<!-- {INJECTED-USER-END} -->";
-
- private static final String INJECT_CSS_START = "<!-- {INJECTED-STYLESHEETS-START} -->";
- private static final String INJECT_CSS_END = "<!-- {INJECTED-STYLESHEETS-END} -->";
-
- private static final String INJECT_JS_START = "<!-- {INJECTED-JAVASCRIPT-START} -->";
- private static final String INJECT_JS_END = "<!-- {INJECTED-JAVASCRIPT-END} -->";
-
- private static final byte[] SCRIPT_START = "\n<script>\n".getBytes();
- private static final byte[] SCRIPT_END = "</script>\n\n".getBytes();
-
- @Context
- private SecurityContext ctx;
-
- @GET
- @Produces(MediaType.TEXT_HTML)
- public Response getMainIndex() throws IOException {
- ClassLoader classLoader = getClass().getClassLoader();
- UiExtensionService service;
- UiTokenService tokens;
-
- try {
- service = get(UiExtensionService.class);
- tokens = get(UiTokenService.class);
-
- } catch (ServiceNotFoundException e) {
- return Response.ok(classLoader.getResourceAsStream(NOT_READY)).build();
- }
-
- InputStream indexTemplate = classLoader.getResourceAsStream(INDEX);
- String index = new String(toByteArray(indexTemplate));
-
- int p0s = split(index, 0, INJECT_USER_START) - INJECT_USER_START.length();
- int p0e = split(index, p0s, INJECT_USER_END);
- int p1s = split(index, p0e, INJECT_JS_START) - INJECT_JS_START.length();
- int p1e = split(index, p1s, INJECT_JS_END);
- int p2s = split(index, p1e, INJECT_CSS_START) - INJECT_CSS_START.length();
- int p2e = split(index, p2s, INJECT_CSS_END);
- int p3s = split(index, p2e, null);
-
-
- // FIXME: use global opaque auth token to allow secure failover
-
- // for now, just use the user principal name...
- String userName = ctx.getUserPrincipal().getName();
-
- // get a session token to use for UI-web-socket authentication
- UiSessionToken token = tokens.issueToken(userName);
-
- String auth = "var onosUser='" + userName + "',\n" +
- " onosAuth='" + token + "';\n";
-
- StreamEnumeration streams =
- new StreamEnumeration(of(stream(index, 0, p0s),
- new ByteArrayInputStream(SCRIPT_START),
- stream(auth, 0, auth.length()),
- userPreferences(userName),
- userConsoleLog(userName),
- new ByteArrayInputStream(SCRIPT_END),
- stream(index, p0e, p1s),
- includeJs(service),
- stream(index, p1e, p2s),
- includeCss(service),
- stream(index, p2e, p3s)));
-
- return Response.ok(new SequenceInputStream(streams)).build();
- }
-
- private InputStream userConsoleLog(String userName) {
- String code = "console.log('Logging in as user >" + userName + "<');\n";
- return new ByteArrayInputStream(code.getBytes());
- }
-
- // Produces an input stream including user preferences.
- private InputStream userPreferences(String userName) {
- UiPreferencesService service = get(UiPreferencesService.class);
- ObjectNode prefs = mapper().createObjectNode();
- service.getPreferences(userName).forEach(prefs::set);
- String string = "var userPrefs = " + prefs.toString() + ";\n";
- return new ByteArrayInputStream(string.getBytes());
- }
-
- // Produces an input stream including JS injections from all extensions.
- private InputStream includeJs(UiExtensionService service) {
- Builder<InputStream> builder = ImmutableList.builder();
- service.getExtensions().forEach(ext -> {
- add(builder, ext.js());
- add(builder, new NewlineInputStream());
- });
- return new SequenceInputStream(new StreamEnumeration(builder.build()));
- }
-
- // Produces an input stream including CSS injections from all extensions.
- private InputStream includeCss(UiExtensionService service) {
- Builder<InputStream> builder = ImmutableList.builder();
- service.getExtensions().forEach(ext -> {
- add(builder, ext.css());
- add(builder, new NewlineInputStream());
- });
- return new SequenceInputStream(new StreamEnumeration(builder.build()));
- }
-
- // Safely adds the stream to the list builder only if stream is not null.
- private void add(Builder<InputStream> builder, InputStream inputStream) {
- if (inputStream != null) {
- builder.add(inputStream);
- }
- }
-
- private static final String NL = String.format("%n");
- private static final byte[] NL_BYTES = NL.getBytes();
-
- private static class NewlineInputStream extends InputStream {
- private int index = 0;
-
- @Override
- public int read() throws IOException {
- if (index == NL_BYTES.length) {
- return -1;
- }
- return NL_BYTES[index++];
- }
- }
-
-}
diff --git a/web/gui2/src/main/webapp/WEB-INF/web.xml b/web/gui2/src/main/webapp/WEB-INF/web.xml
index 041cdb6..ae8c650 100644
--- a/web/gui2/src/main/webapp/WEB-INF/web.xml
+++ b/web/gui2/src/main/webapp/WEB-INF/web.xml
@@ -22,7 +22,7 @@
<display-name>ONOS GUI 2</display-name>
<welcome-file-list>
- <welcome-file>dist/index.html</welcome-file>
+ <welcome-file>index.html</welcome-file>
</welcome-file-list>
<!--
@@ -30,7 +30,7 @@
<security-constraint>
<web-resource-collection>
<web-resource-name>Secured</web-resource-name>
- <url-pattern>/dist/index.html</url-pattern>
+ <url-pattern>/index.html</url-pattern>
</web-resource-collection>
<web-resource-collection>
<web-resource-name>Secured API</web-resource-name>
@@ -71,7 +71,7 @@
<servlet-mapping>
<servlet-name>Index Page</servlet-name>
- <url-pattern>/dist/index.html</url-pattern>
+ <url-pattern>/index.html</url-pattern>
</servlet-mapping>
<!--<servlet>-->
diff --git a/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java b/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java
index 1648002..a5ce1d9 100644
--- a/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java
+++ b/web/gui2/src/test/java/org/onosproject/ui/impl/DummyTest.java
@@ -15,8 +15,17 @@
*/
package org.onosproject.ui.impl;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
/**
* This is just a dummy file to get BUCK going.
*/
public class DummyTest {
+
+ @Test
+ public void dummyTest() {
+ assertEquals("test", DummyClass.getDummyAttribute());
+ }
}