Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » Java Code Generation with MoDisco
Java Code Generation with MoDisco [message #574730] Mon, 19 April 2010 15:35 Go to next message
Philip Mayer is currently offline Philip Mayer
Messages: 29
Registered: July 2009
Junior Member
Dear all,

I am trying to invoke the modisco java code generator, as described on the website http://wiki.eclipse.org/MoDisco/Components/Java/Documentatio n/0.8#Java_Generation

The MoDisco website (http://wiki.eclipse.org/MoDisco/Components) states that the full java metamodel and the code generation is only available in "MoDisco 0.8". The same page also says that "MoDisco 0.8" is for helios. So I assume that I need Helios, right?

I installed Helios M6 + Acceleo (from the Helios Update Site, v3.0.0) + the milestone modisco update site ( http://download.eclipse.org/modeling/gmt/modisco/updates/mil estones/). Now, the website http://wiki.eclipse.org/MoDisco/Components/Java/Documentatio n/0.8#Java_Generation states two methods of invoking the code generator:

a) use the import plugin wizard for the java.generation package and run an Acceleo launch configuration for the Generate_JavaStructures class. When I do this, I get (in the error log)


ERROR: Couldn't load class org.eclipse.gmt.modisco.java.generation.files.Generate_JavaS tructures from project org.eclipse.gmt.modisco.java.generation

WARN: org.eclipse.osgi.framework.internal.core.Framework$Duplicate BundleException: Bundle "org.eclipse.gmt.modisco.java.generation" version "0.8.0.v201003161136" has already been installed from: reference:file:plugins/org.eclipse.gmt.modisco.java.generati on_0.8.0.v201003161136.jar


b) again, use the import plugin wizard for the java.generation package , but launch the main class not with a Acceleo launch config but as standard java app (this should be equivalent to launching it from my own plugin) This yields:


org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http://www.eclipse.org/acceleo/mtl/0.8.0' not found.


So, in a) I seem to not be allowed to have a copy of the .generation project in the workspace and somehow it cannot find the class, and in b), the acceleo version does not match, because the generate_javastructure.emtl which is provided in "MoDisco 0.8" in the "org.eclipse.gmt.modisco.java.generation" plugin carries the namespace "http://www.eclipse.org/acceleo/mtl/0.8.0", but the Acceleo version installed in Helios is actually 3.0.0 --.--

I do not know how to proceed. Can someone point out to me how to set up an Eclipse installation in which I can use the MoDisco java model generator? What is the preferred way of doing this?


Thanks,

Philip
Re: Java Code Generation with MoDisco [message #574758 is a reply to message #574730] Tue, 20 April 2010 08:23 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien Giquel
Messages: 138
Registered: July 2009
Senior Member
Hi Philip,

You were right in choosing Helios.
There are been some issue in M6 milestone build for MoDisco considering
changes delivered in Acceleo M6. Sorry, We will do better in M7 coming
soon (early may).

So i suggest the following steps :
- install Helios M6 + Acceleo v3.0.0 (just as you did)
- install MoDisco from nightly update site :
http://download.eclipse.org/modeling/gmt/modisco/updates/nig htly/
- from your plugin, add dependency to org.eclipse.emf.ecore and
org.eclipse.gmt.modisco.java.generation
- in your plugin code, use the Generate_JavaStructure class. The code
should look like this :

Generate_JavaStructures javaGenerator = new
Generate_JavaStructures(URI.createFileURI("C:/.../my.javaxmi "),
new File("C:/.../myOutputFolder"), new ArrayList<Object>());
javaGenerator.doGenerate(null);


You do not need to use the import plugin wizard for those steps. As you
noticed, there is some trouble when importing the plugin and using an
acceleo launcher.

Additionaly, an example is available in
org.eclipse.gmt.modisco.java.generation.tests project (JUnit test for
java generation) which can be retrieved from our SVN.

I hope everything will be alright now.
Best regards.

Le 19/04/2010 21:35, Philip Mayer a écrit :
> Dear all,
>
> I am trying to invoke the modisco java code generator, as described on
> the website
> http://wiki.eclipse.org/MoDisco/Components/Java/Documentatio n/0.8#Java_Generation
>
> The MoDisco website (http://wiki.eclipse.org/MoDisco/Components) states
> that the full java metamodel and the code generation is only available
> in "MoDisco 0.8". The same page also says that "MoDisco 0.8" is for
> helios. So I assume that I need Helios, right?
> I installed Helios M6 + Acceleo (from the Helios Update Site, v3.0.0) +
> the milestone modisco update site
> ( http://download.eclipse.org/modeling/gmt/modisco/updates/mil estones/).
> Now, the website
> http://wiki.eclipse.org/MoDisco/Components/Java/Documentatio n/0.8#Java_Generation
> states two methods of invoking the code generator:
>
> a) use the import plugin wizard for the java.generation package and run
> an Acceleo launch configuration for the Generate_JavaStructures class.
> When I do this, I get (in the error log)
>
>
> ERROR: Couldn't load class
> org.eclipse.gmt.modisco.java.generation.files.Generate_JavaS tructures
> from project org.eclipse.gmt.modisco.java.generation
>
> WARN:
> org.eclipse.osgi.framework.internal.core.Framework$Duplicate BundleException:
> Bundle "org.eclipse.gmt.modisco.java.generation" version
> "0.8.0.v201003161136" has already been installed from:
> reference:file:plugins/org.eclipse.gmt.modisco.java.generati on_0.8.0.v201003161136.jar
>
>
>
> b) again, use the import plugin wizard for the java.generation package ,
> but launch the main class not with a Acceleo launch config but as
> standard java app (this should be equivalent to launching it from my own
> plugin) This yields:
>
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
> uri 'http://www.eclipse.org/acceleo/mtl/0.8.0' not found.
>
>
> So, in a) I seem to not be allowed to have a copy of the .generation
> project in the workspace and somehow it cannot find the class, and in
> b), the acceleo version does not match, because the
> generate_javastructure.emtl which is provided in "MoDisco 0.8" in the
> "org.eclipse.gmt.modisco.java.generation" plugin carries the namespace
> "http://www.eclipse.org/acceleo/mtl/0.8.0", but the Acceleo version
> installed in Helios is actually 3.0.0 --.--
>
> I do not know how to proceed. Can someone point out to me how to set up
> an Eclipse installation in which I can use the MoDisco java model
> generator? What is the preferred way of doing this?
>
> Thanks,
>
> Philip


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------
Re: Java Code Generation with MoDisco [message #574806 is a reply to message #574730] Wed, 21 April 2010 10:21 Go to previous messageGo to next message
Philip Mayer is currently offline Philip Mayer
Messages: 29
Registered: July 2009
Junior Member
Dear Fabian,

thanks for the code, I tried it, but it does not work either. However, it DOES work if I make the following changes to your code:

a)

replace
"new ResourceImpl();"
with
"new XMIResourceImpl();"
b)

add

r.setURI(URI.createFileURI("...") ;
r.save(null) ;

just before new Generate_JavaStructures(...)


But in this case (obviously) I also have a serialised file of the model. :)

My setup is still the same as above (Helios M6 Modeling + Acceleo 3.0.0 + MoDisco Nightly from Yesterday).

Any way of avoiding this serialisation step?

Thanks,

Philip
Re: Java Code Generation with MoDisco [message #574824 is a reply to message #574806] Wed, 21 April 2010 11:39 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien Giquel
Messages: 138
Registered: July 2009
Senior Member
You may try this : just keep "r.setURI(...)" additional statement.

I had this additional statement when running, but I did not include it in my answer because i was sure it was useless.

Best regards.
--
----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------
Re: Java Code Generation with MoDisco [message #574839 is a reply to message #574730] Wed, 21 April 2010 12:06 Go to previous message
Philip Mayer is currently offline Philip Mayer
Messages: 29
Registered: July 2009
Junior Member
Dear Fabien,

that did the trick.

Never would have thought of that ... and I am also at a loss to explain why it works, but it does.

Thanks again!

Philip
Previous Topic:Editing in MoDisco Browser
Next Topic:Java Code Generation with MoDisco
Goto Forum:
  


Current Time: Mon Sep 01 10:05:53 EDT 2014

Powered by FUDForum. Page generated in 0.02693 seconds