blob: 1fa344c9a360a340b25e1fffc620bd212489e440 [file] [log] [blame]
Thomas Vachuskaad37e372017-08-03 12:07:01 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Compiles Java code generated by the YANG compiler.
4# -----------------------------------------------------------------------------
5
6sources=${1:-src}
7classes=${2:-classes}
8modelId=${3:-org.onosproject.model.unknown}
9
10# Stage the YANG sources and the YANG schema meta-data
11mkdir -p $classes/yang/resources
12cp $sources/schema/* $classes/yang/resources
13
14root=${root:-system}
15op="$root/org/onosproject"
16
17function findLib() {
18 find $1/$2 -name "$2-*.jar"
19}
20
21classPath="$(findLib $op onos-yang-model)"
22classPath="$classPath:$(findLib $op onos-yang-runtime)"
23classPath="$classPath:$(findLib $op onos-yang-compiler-api)"
24classPath="$classPath:$(findLib $op onos-apps-yang)"
25
26package=${modelId//./\/}
27mkdir -p $sources/src/$package
28sed "s/PACKAGE/$modelId/g" $(dirname $0)/YangModelRegistrator.java \
29 > $sources/src/$package/YangModelRegistrator.java
30
31# Compile the generated java code
32find $sources/src -name '*.java' > $sources/javaFiles
33javac -source 1.8 -target 1.8 \
34 -sourcepath "$sources/src" -classpath "$classPath" -d "$classes" \
35 @$sources/javaFiles