+ /**
+ * Tries three lookups
+ * First try to lookup the file in the classpath.
+ * else try relative path
+ * else try prefixing the relative path with the maven project path.
+
+ * @param filePath - A String denoting the source yang file path.
+ * @return URL - to the source yang file
+ * @throws MalformedURLException
+ */
+ private URL lookupURL(String filePath) throws IOException {
+ //check out the class path first
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ URL sourceYangURL = classLoader.getResource(filePath);
+
+ if (sourceYangURL != null) {
+ return sourceYangURL;
+ }
+
+ String errorMessage = String.format(
+ "YANG file <%s> not found in classpath or on the file system."
+ ,filePath
+ );
+
+ //check the file system first
+ File sourceFile = new File(toAbsoluteFile(filePath));
+ if (!sourceFile.exists()) {
+ throw new FileNotFoundException(errorMessage);
+ }
+ try {
+ sourceYangURL = sourceFile.toURI().toURL();
+ } catch (MalformedURLException e) {
+ throw new IOException(errorMessage,e);
+ }
+ return sourceYangURL;
+ }
+
+