[acceleo] unable to load JAR-packaged EMTLs on unix [message #869597] |
Thu, 03 May 2012 17:04 |
Joel Gluth Messages: 5 Registered: May 2012 |
Junior Member |
|
|
(This is not urgent, I have a workaround, but it's worth mentioning).
I have an Acceleo project that functions as a Maven plugin, and when deployed on Windows, it works as expected.
On Linux, though, I get errors of the form:
[INFO] --- uml2whatever-maven-plugin:1.0.7-SNAPSHOT:generate-client (generate) @ whatever-client ---
java.lang.RuntimeException: Cannot create a resource for 'jar:file:/home/joel/.m2/repository/com/whatever/maven/plugin/uml2whatever-maven-plugin/1.0.7-SNAPSHOT/uml2whatever-maven-plugin-1.0.7-SNAPSHOT.jar!/com/whatever/api/client/clientGenerate.emtl'; a registered resource factory is needed
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:394)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:358)
Some digging around reveals that I am falling back on a method in AcceleoResourceFactoryRegistry, called calculateFactory(). In particular, it attempts to derive a path to the JAR file from the URI, with code like this:
String jarPrefix = "jar:file:/"; //$NON-NLS-1$
String jarSeparator = "!/"; //$NON-NLS-1$
if (path.startsWith(jarPrefix) && path.contains(jarSeparator)) {
String jarPath = path.substring(jarPrefix.length(), path.indexOf(jarSeparator));
Ie., it trims the leading slash after 'file:'.
This works on Windows, because you can trim the leading slash and end up with a path like "C:/home/joel/whatever...". On Unix and friends, it turns it into a relative path, which doesn't exist. It tries to find a JAR at "home/joel/.m2/repository/com/whatever/maven/plugin/uml2whatever-maven-plugin/1.0.7-SNAPSHOT/uml2whatever-maven-plugin-1.0.7-SNAPSHOT.jar", and, since I'm not building at the filesystem root, it doesn't.
What made this hard to find was
} catch (IOException e) {
// do not log, the jar does not exists
}
My workaround has been to explicitly add
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emtl", new EMtlResourceFactoryImpl());
to my Generate classes' registerResourceFactories() methods, since I know in advance that I am using the XMI serialization format, but it's not ideal.
Is this worth adding to bugzilla? Non-portable Java code seems like a bug to me.
[Updated on: Thu, 03 May 2012 17:05] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02611 seconds