From eddc53acc6e439659970b15c13981551a5dcb0c4 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Thu, 21 Jul 2016 03:58:22 +0200 Subject: [PATCH] Improve yang-maven-plugin error reporting Instead of e.g. this: org.apache.maven.plugin.MojoFailureException: Failed to scan for YANG files in depedencies (...) Caused by: java.util.zip.ZipException: invalid CEN header (bad signature) at java.util.zip.ZipFile.open(Native Method) it will now report the much more useful variation like this: org.apache.maven.plugin.MojoFailureException: Failed to scan for YANG files in dependency: /home/vorburger/.m2/repository/org/opendaylight/openflowplugin/model/model-flow-base/0.3.0-SNAPSHOT/model-flow-base-0.3.0-SNAPSHOT.jar Change-Id: I1062d10d9157f9ac6b44cd86a29af8cc8e87b25f Signed-off-by: Michael Vorburger --- .../yangtools/yang2sources/plugin/Util.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java index 8ecf8f65ab..a29ad42a46 100644 --- a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java +++ b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java @@ -328,12 +328,17 @@ final class Util { static Collection findYangFilesInDependencies(MavenProject project) throws MojoFailureException { final List yangsFilesFromDependencies = new ArrayList<>(); + List filesOnCp; try { - List filesOnCp = Util.getClassPath(project); - LOG.info("{} Searching for yang files in following dependencies: {}", YangToSourcesProcessor.LOG_PREFIX, - filesOnCp); + filesOnCp = Util.getClassPath(project); + } catch (Exception e) { + throw new MojoFailureException("Failed to scan for YANG files in dependencies", e); + } + LOG.info("{} Searching for yang files in following dependencies: {}", YangToSourcesProcessor.LOG_PREFIX, + filesOnCp); - for (File file : filesOnCp) { + for (File file : filesOnCp) { + try { // is it jar file or directory? if (file.isDirectory()) { //FIXME: code duplicate @@ -366,9 +371,9 @@ final class Util { } } } + } catch (Exception e) { + throw new MojoFailureException("Failed to scan for YANG files in dependency: " + file.toString(), e); } - } catch (Exception e) { - throw new MojoFailureException("Failed to scan for YANG files in depedencies", e); } return yangsFilesFromDependencies; } -- 2.36.6