|
|
|
Re: Loading resource from jar file [message #997982 is a reply to message #997791] |
Wed, 09 January 2013 05:34 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Pradeep,
No, as I said, if it works at all, its interpreted relative to the
current directory of the process, and what's that for the running IDE
and how do you know nothing changes it? So use an absolute path. If
it's in the workspace you could use
jar:platform:/resource/<project>/<path>/<jar>!/<path-in-jar>.
On 08/01/2013 7:51 PM, Pradeep Badiger wrote:
> Hi Ed,
>
> I am trying it on the EMF editor (Load Resource dialog provided by the
> EMF editor). I dont have the option to use any API as you mentioned.
>
> I was wondering, if its really possible to have relative path for the
> resource within a jar file.
>
> I have the jar file containing a resource placed relatively to the
> ecore file where i am trying to load.
> Please let me know if I have clearly defined my problem.
>
> Let me know your thoughts.
>
> thanks,
> Pradeep
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: Loading resource from jar file [message #998494 is a reply to message #998097] |
Thu, 10 January 2013 05:23 |
Pradeep Badiger Messages: 53 Registered: November 2012 |
Member |
|
|
Steps to reproduce the issue
1. Run "mvn clean install" on com.example.basemodel project
2. Run "mvn clean" on com.example.model project. This will copy the com.example.basemodel.jar to the target folder of com.example.model project.
3. Load resource from model.ecore within com.example.model project.
using - jar:platform:/resource/com.example.model/target/com.example.basemodel.jar!/model/basemodel.ecore
4. Now check the class name within the loaded resource. It should have "Person" class within the "basemodel" package.
5. Rename the "Person" class to "NewPerson" within basemodel.ecore in com.example.basemodel project.
6. Repeat steps 1, 2 and 3.
7. Now if you check the class within the loaded resource, the class name still remains as "Person", whereas it should have been "NewPerson".
8. If IDE is restarted and step 3 is repeated, then one can see the changes made in the basemodel.ecore which is loaded in model.ecore
In my workspace, i will never have the com.example.basemodel project to build. I will copy it to my com.example.model project and add the reference.
[Updated on: Thu, 10 January 2013 06:01] Report message to a moderator
|
|
|
Re: Loading resource from jar file [message #998534 is a reply to message #998494] |
Thu, 10 January 2013 07:25 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Pradeep,
Comments below.
On 10/01/2013 6:23 AM, Pradeep Badiger wrote:
> Steps to reproduce the issue
> 1. Run "mvn clean install" on com.example.basemodel project
What's mvn?
> 2. Run "mvn clean" on com.example.model project. This will copy the com.example.basemodel.jar to the target folder of com.example.model project.
Why would you need to do such a thing? I'd expect they're plugin
projects with a proper dependency...
> 3. Load resource from model.ecore within com.example.model project.
> using - jar:platform:/resource/com.example.model/target/com.example.basemodel.jar!/model/basemodel.ecore
If I recall correctly, a jar: URL will open a JarFile and will keep it
open for the lifetime of the JVM...
Try using archive: instead.
> 4. Now check the class name within the loaded resource. It should have "Person" class within the "basemodel" package.
> 5. Rename the "Person" class to "NewPerson" within com.example.basemodel project.
> 6. Repeat steps 1, 2 and 3.
> 7. Now if you check the class within the loaded resource, the class name still remains as "Person", whereas it should have been "NewPerson".
This seems to that step 2 didn't actually update the jar, which makes
sense if the jar is locked because there's an open stream on it. Have
you confirmed the jar really is updated by your step 2? But then again,
the jar: URL itself might keep an in memory copy... Not sure, but a jar:
URI is handled as just a URL, so whatever Java does for a URL with jar
protocol, that's beyond my control... Try archive: instead; it has the
same semantics, but is implemented to load/save using ZipFile/ZipStream.
> 8. If IDE is restarted and then if step 3 is repeated, then one can see the changes made in the basemodel.ecore which is loaded in model.ecore
>
> In my workspace, i will never have the com.example.basemodel project to build. I will copy it to my com.example.model project and add the reference.
Do you generate code from these models?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04262 seconds