blob: 94c492ef6b786637b0de7470794e4ed620705894 [file] [log] [blame]
NODE_VERSION = "v8.11.1"
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//lib:JACKSON',
'//lib:KRYO',
'//lib:javax.ws.rs-api',
'//lib:servlet-api',
'//lib:jetty-websocket',
'//lib:jetty-util',
'//lib:jersey-media-multipart',
'//lib:org.apache.karaf.shell.console',
'//cli:onos-cli',
'//lib:jersey-server',
'//incubator/api:onos-incubator-api',
'//incubator/net:onos-incubator-net',
'//utils/rest:onlab-rest',
'//core/store/serializers:onos-core-serializers',
':node-release-' + NODE_VERSION,
':node-bin-' + NODE_VERSION,
'//web/gui2:onos-web-gui2-build',
]
TEST_DEPS = [
'//lib:TEST',
'//core/api:onos-api-tests',
'//drivers/default:onos-drivers-default',
]
include_defs('//bucklets/node.bucklet')
fetch_node(version = NODE_VERSION)
genrule(
name = 'onos-web-gui2-build',
srcs = glob([
'**/*.json',
'src/main/webapp/**/*.ts',
'src/main/webapp/**/*.html',
'src/main/webapp/**/*.css',
'src/main/webapp/**/*.png',
'*.js',
'e2e/**/*'
], excludes = [
'dist/**/*',
'node_modules/**/*',
'src/main/webapp/dist/**/*'
]),
bash =
#To avoid any older 'NodeJS' installations it is necessary to use only the one
# associated with this project - Angular 6 won't work on older releases
'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
+ 'echo $PATH;'
+ '$(location :node-bin-' + NODE_VERSION + ')/bin/node -v;'
+ 'ORIGPATH="$SRCDIR";'
+ 'cd $(location :node-bin-' + NODE_VERSION + ')/bin &&'
+ 'ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm5 &&'
+ 'cd $ORIGPATH &&'
# The symlink to npm is not always created properly by the BUCK job that
# untars it. It's safer to have our own symlink 'npm5'
+ 'npm5 -v;'
+ 'npm5 install -g @angular/cli@6.0.0 2>&1;'
+ 'npm5 install 2>&1;'
+ 'ng -v;'
# 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/dist/ --deploy-url /onos/ui2/dist/ --output-path="$OUT" 2>&1',
out = 'dist',
visibility = [ 'PUBLIC' ],
)
genrule(
name = 'onos-web-gui2-test',
srcs = [],
bash =
'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
+ 'ORIGPATH="$SRCDIR";'
+ 'ORIGOUTPUT=\$(echo $ORIGPATH|cut -d\'_\' -f 1 );'
+ 'cd $(location :onos-web-gui2-build)/../../onos-web-gui2-build__srcs;'
# The sym linked karma.conf.js will mean that 'karma-jasmine' won't be found
+ 'cp karma.conf.js karma.conflocal.js;'
+ 'pwd > "$OUT";'
+ 'npm5 -v >> "$OUT";'
+ 'ng -v >> "$OUT";'
+ 'if [ -f /usr/bin/chromium-browser ]; then export CHROME_BIN=/usr/bin/chromium-browser; fi;'
+ 'echo $CHROME_BIN >> "$OUT";'
# No point using PhantonJS as the browser because it's not compatible with ES6
# Install either chrome or chromium-browser on the machine
+ 'ng test --preserve-symlinks --karma-config=karma.conflocal.js --code-coverage --browsers=ChromeHeadless --watch=false >> "$OUT" 2>&1 || '
+ 'if [ $? -eq 0 ]; then echo "Successfully ran tests";'
+ 'else '
+ ' if grep -q CHROME_BIN $ORIGOUTPUT/onos-web-gui2-test-log.txt ; then '
+ ' echo "Warning: Step onos-web-gui2-test (test of Angular code) skipped because no binary for ChromeHeadless browser was found on your platform." >&2;'
+ ' echo "Install Google Chrome or Chromium Browser to allow this step to run." >&2;'
+ ' else '
+ ' echo "Error running \'ng test\' on \'//web/gui2:onos-web-gui2-test\'. See $ORIGOUTPUT/onos-web-gui2-test-log.txt for more details" >&2;'
+ ' tail -n 100 $ORIGOUTPUT/onos-web-gui2-test-log.txt >&2;'
+ ' fi;'
+ 'fi;',
out = 'onos-web-gui2-test-log.txt',
)
genrule(
name = 'onos-web-gui2-lint',
srcs = [],
bash =
'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
+ 'cd $(location :onos-web-gui2-build)/../../onos-web-gui2-build__srcs;'
+ 'pwd > "$OUT";'
+ 'npm5 -v >> "$OUT";'
+ 'ng -v >> "$OUT";'
+ 'ng lint >> "$OUT"',
out = 'onos-web-gui2-lint-log.txt',
)
genrule(
name = 'onos-web-gui2-compodoc',
srcs = [],
bash =
'export PATH=$(location :node-bin-' + NODE_VERSION + ')/bin:$PATH; '
+ 'cd $(location :onos-web-gui2-build) && cd ../.. && cd onos-web-gui2-build__srcs;'
+ 'pwd;'
+ 'npm5 -v;'
+ 'npm5 install -g @compodoc/compodoc 2>&1;'
+ 'npm5 run compodoc -- -V;'
# TODO This does not pick up on sym linked files - issue raised with authors
+ 'npm5 run compodoc -- -d "$OUT"',
out = 'documentation',
)
osgi_jar_with_tests (
name = 'onos-gui2',
deps = COMPILE_DEPS,
test_deps = TEST_DEPS,
resources = [
':onos-web-gui2-build'
],
resources_root = '.',
test_resources = [
':onos-web-gui2-test',
':onos-web-gui2-lint'
],
test_resources_root = '.',
web_context = '/onos/ui2',
do_javadocs = False,
)
onos_app (
title = 'ONOS GUI v2 Application',
category = 'GUI',
url = 'http://onosproject.org',
description = 'ONOS GUI v2 based on Angular 6',
included_bundles = ['//web/gui2:onos-gui2'],
)