blob: 1fa344c9a360a340b25e1fffc620bd212489e440 [file] [log] [blame]
#!/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