Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XMI Files: Referencing Metamodel from Classpath
XMI Files: Referencing Metamodel from Classpath [message #1587304] Tue, 27 January 2015 09:02
Jamie Astin is currently offline Jamie AstinFriend
Messages: 1
Registered: January 2015
Junior Member
Hello everyone,

I am relatively new to the EMF community, and was hoping someone could provide some insight into my problem.

I am producing an Xpand project, which will be distributed as part of a framework. I will be shipping a JAR to other people who wish to consume this framework. It is intended that within this JAR I will provide the metamodel in ecore format, and the relevant Xpand files (xpt, Checks.chk and Extensions.ext).

Consuming projects will then simply need to implement the metamodel in a XMI file, and have a mwe2 file which describes how to invoke the code generator.

Working with the example project, I am envisaging the following:

modelling-framework.jar
    /metamodel/Checks.chk
    /metamodel/Extensions.ext
    /metamodel/metamodel.ecore
    /template/GeneratorExtensions.ext
    /template/Template.xpt

consuming-project (Eclipse Project)
   /src/Model.xmi
   /src/workflow/generator.mwe2


Looking at the Model.xmi file that is created with the sample project, the reference from the XMI model to the underlying metamodel seems to be established in the root tag:

<metamodel:Model xmi:version="2.0" 
    xmlns:xmi="//www.omg.org/XMI" 
    xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"
    xmlns:metamodel="//www.example.org/metamodel"
    xsi:schemaLocation="//www.example.org/metamodel metamodel/metamodel.ecore">


As far as I can establish, this is being facilitated by the relative path 'metamodel/metamodel.ecore'.

If I have both the "modelling-framework" and "consuming-project" as two eclipse projects in the same workspace, I can change this relative path to:

NOTE: I've had to remove the "http" protocol from the URLs to prevent the Forum software from rejecting my post. D'oh!


<metamodel:Model 
	xmi:version="2.0" 
	xmlns:xmi="//www.omg.org/XMI" 
	xmlns:xsi="//www.w3.org/2001/XMLSchema-instance" 
	xmlns:metamodel="classpath:/metamodel/metamodel.ecore" 
	xsi:schemaLocation="//www.example.org/metamodel">


This use of "classpath:/metamodel/metamodel.ecore" is successful. However, if I only have "consuming-project" in my workspace, and reference a built jar of "modelling-framework", I receive the following error:

Couldn't find resource on classpath : classpath:/metamodel/metamodel.ecore


I have checked the built jar file, and I can confirm that the ecore file is present at the specified path. In fact, the following code (in the "consuming-project" yeilds a JarURLConnection:

System.out.println(TestClass.class.getResourceAsStream("metamodel/metamodel.ecore"));


Is there some magic to refer to a metamodel from within a JAR file?

Any pointers would be greatly appreciated,

Thanks,

Jamie.
Previous Topic:do I have the correct download for the EMF plugin
Next Topic:EMF Validation with specific target Class and Java 8
Goto Forum:
  


Current Time: Tue Jul 16 02:40:30 GMT 2019

Powered by FUDForum. Page generated in 0.01700 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top