Integrating YANG live compilation into YANG runtime.
- Bumped ONOS dependency on ONOS YANG tools 2.2.0-b4.
- Added CLI to compile YANG models.
- Added GUI capability to compile YANG models via drag-n-drop or file upload.
- Fixed defect in propagating self-contained JAR apps through the cluster.
Change-Id: Icbd2a588bf1ffe0282e12d3d10a117e0957c3084
diff --git a/apps/yang/src/main/resources/onos-yang-javac b/apps/yang/src/main/resources/onos-yang-javac
new file mode 100755
index 0000000..1fa344c
--- /dev/null
+++ b/apps/yang/src/main/resources/onos-yang-javac
@@ -0,0 +1,35 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Compiles Java code generated by the YANG compiler.
+# -----------------------------------------------------------------------------
+
+sources=${1:-src}
+classes=${2:-classes}
+modelId=${3:-org.onosproject.model.unknown}
+
+# Stage the YANG sources and the YANG schema meta-data
+mkdir -p $classes/yang/resources
+cp $sources/schema/* $classes/yang/resources
+
+root=${root:-system}
+op="$root/org/onosproject"
+
+function findLib() {
+ find $1/$2 -name "$2-*.jar"
+}
+
+classPath="$(findLib $op onos-yang-model)"
+classPath="$classPath:$(findLib $op onos-yang-runtime)"
+classPath="$classPath:$(findLib $op onos-yang-compiler-api)"
+classPath="$classPath:$(findLib $op onos-apps-yang)"
+
+package=${modelId//./\/}
+mkdir -p $sources/src/$package
+sed "s/PACKAGE/$modelId/g" $(dirname $0)/YangModelRegistrator.java \
+ > $sources/src/$package/YangModelRegistrator.java
+
+# Compile the generated java code
+find $sources/src -name '*.java' > $sources/javaFiles
+javac -source 1.8 -target 1.8 \
+ -sourcepath "$sources/src" -classpath "$classPath" -d "$classes" \
+ @$sources/javaFiles