| Summary: | PathTraverser must ignore non-existent files | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Karsten Thoms <karsten.thoms> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | sv3n.lange, sven.efftinge |
| Version: | 2.0.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
I'd like to get an exception if the configuration is pointing to non existent files. Don't you get an error marker for that in your project as well? This happened when having the Maven Classpath Container on the classpath. There was no error marker in the IDE. The classpath container had a dependency to that artifact, and *would* resolve this jar. But at execution time it might actually not be there. I think Maven IDE users will face this problem, and from the error message it is not that obvious. You could print out a warning if the file does not exist that is about to be traversed. But the exception is annoying, since it might not lead to an error, when some jars are unresolvable. I fear a warning will be overseen and people get surprised if we just ignore an incomplete classpath. I think people should rather fix the classpath issue. |
I had the situation that a project's classpath might refer to a non-existent Jar file and the PathTraverser throws an exception: ====================================================== 1 [Thread-1] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Unsupported path : /Users/thoms/.m2/repository/org/eclipse/plugins/org.eclipse.emf.mapping.ecore2xml/2.7.0.v20110331-2022/org.eclipse.emf.mapping.ecore2xml-2.7.0.v20110331-2022.jar (only folders and archives are supported). java.lang.IllegalArgumentException: Unsupported path : /Users/thoms/.m2/repository/org/eclipse/plugins/org.eclipse.emf.mapping.ecore2xml/2.7.0.v20110331-2022/org.eclipse.emf.mapping.ecore2xml-2.7.0.v20110331-2022.jar (only folders and archives are supported). at org.eclipse.xtext.mwe.PathTraverser.findAllResourceUris(PathTraverser.java:46) at org.eclipse.xtext.mwe.PathTraverser.resolvePathes(PathTraverser.java:33) at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getPathToUriMap(RuntimeResourceSetInitializer.java:54) at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getInitializedResourceSet(RuntimeResourceSetInitializer.java:72) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.findModule(Mwe2Runner.java:112) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:77) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74) at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35) ====================================================== However, the workflow in this case could also succeed. Suggested change: ===================================== public Set<URI> findAllResourceUris(String path, Predicate<URI> isValidPredicate) { File file = new File(path); if (!file.exists()) { return Sets.newHashSet(); } else if (file.isDirectory()) { return traverseDir(file, isValidPredicate); } else if (file.isFile()) { return traverseArchive(file, isValidPredicate); } throw new IllegalArgumentException("Unsupported path : " + path + " (only folders and archives are supported)."); } =====================================