Repository: cxf-xjc-utils Updated Branches: refs/heads/master b897b2680 -> 8d5b44460
Fix test failure, provide some more info Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/8d5b4446 Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/8d5b4446 Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/8d5b4446 Branch: refs/heads/master Commit: 8d5b44460ed3e3feee6573335d96d6deb0353396 Parents: b897b26 Author: Daniel Kulp <[email protected]> Authored: Mon Nov 10 14:52:46 2014 -0500 Committer: Daniel Kulp <[email protected]> Committed: Mon Nov 10 14:52:46 2014 -0500 ---------------------------------------------------------------------- .../cxf/maven_plugin/XSDToJavaRunner.java | 35 ++++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/8d5b4446/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java ---------------------------------------------------------------------- diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java index 96083b0..69fab41 100644 --- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java +++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java @@ -79,21 +79,30 @@ public class XSDToJavaRunner { this.cpList = cp; } - private static File getFile(String s) throws Exception { + private static File getFile(String s, XJCErrorListener l) throws Exception { File f = new File(s); if (f.exists()) { return f; } - URI uri = new URI(s); - f = new File(uri); - return f; + try { + URI uri = new URI(s); + f = new File(uri); + return f; + } catch (Throwable t) { + if (l != null) { + l.debug("Could not find a file for " + s); + } + return null; + } } public int run() throws Exception { List<URL> urls = new ArrayList<URL>(); for (String s : cpList) { - File file = getFile(s); - urls.add(file.toURI().toURL()); + File file = getFile(s, listener); + if (file != null) { + urls.add(file.toURI().toURL()); + } } final ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), this.getClass().getClassLoader()); @@ -332,22 +341,26 @@ public class XSDToJavaRunner { } public static void main(String[] args) throws Exception { + BuildContext context = new XJCBuildContext(); + XJCErrorListener listener = new XJCErrorListener(context); + List<String> cplist = new ArrayList<String>(); for (int x = 0; x < args.length; x++) { if ("-classpath".equals(args[x])) { cplist.add(args[x + 1]); - File file = getFile(args[x + 1]); - if (file.exists()) { + File file = getFile(args[x + 1], listener); + if (file != null && file.exists()) { args[x + 1] = file.getAbsolutePath(); } x++; } } - BuildContext context = new XJCBuildContext(); - XJCErrorListener listener = new XJCErrorListener(context); - File outputFile = getFile(args[args.length - 1]); + File outputFile = getFile(args[args.length - 1], listener); + if (outputFile == null) { + outputFile = new File(args[args.length - 1]); + } int i = new XSDToJavaRunner(args, listener, outputFile, cplist).run(); System.exit(i); }
