Home » Modeling » MoDisco » Java Code Generation with MoDisco
Java Code Generation with MoDisco [message #528239] |
Mon, 19 April 2010 19:35 |
Philip Mayer Messages: 30 Registered: July 2009 |
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_JavaStructures from project org.eclipse.gmt.modisco.java.generation
WARN: org.eclipse.osgi.framework.internal.core.Framework$DuplicateBundleException: 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.generation_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 #528410 is a reply to message #528239] |
Tue, 20 April 2010 12:23 |
Fabien Giquel Messages: 147 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
rue Nina Simone
44000 NANTES
----------------------------------------------------
|
|
|
Re: Java Code Generation with MoDisco [message #528411 is a reply to message #528239] |
Tue, 20 April 2010 12:29 |
Fabien Giquel Messages: 147 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.
Fabien.
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
rue Nina Simone
44000 NANTES
----------------------------------------------------
|
|
|
Re: Java Code Generation with MoDisco [message #528478 is a reply to message #528411] |
Tue, 20 April 2010 16:23 |
Philip Mayer Messages: 30 Registered: July 2009 |
Member |
|
|
Dear Fabien,
Hooray! Success!
Indeed, with Eclipse Helios M6 (the modelling package) plus Acceleo (installed via the Helios update site) plus MoDisco nightly from today, and my own plugin in a runtime workbench, it works nicely.
Thank you very much for your answer, I appreciate it very much (and it is not common to receive this kind of support - so even more thanks to you !).
As a side note: I tried to also use the other method provided by Generate_JavaStructures which takes a model instead of an URI which I just created with JavaFactory.eInstance.createXXX() methods (and it includes a CompilationUnit).
The method returned with a nullpointer because my model did not have a resourceset. I then added a dummy resource and set, but then generation runs but doesnt output anything (in AcceleoService.doGenerate, the argumentType.isInstance(potentialTarget) always fails, even for CompilationUnit instances). What am I missing?
(The background of this is that I intend to create a model on-the-fly and then generate code without serialising the model first. This would be great to have).
Thanks again, and I am looking forward to your next releases,
Philip
|
|
| | | | |
Re: Java Code Generation with MoDisco [message #574773 is a reply to message #528411] |
Tue, 20 April 2010 16:23 |
Philip Mayer Messages: 30 Registered: July 2009 |
Member |
|
|
Dear Fabien,
Hooray! Success!
Indeed, with Eclipse Helios M6 (the modelling package) plus Acceleo (installed via the Helios update site) plus MoDisco nightly from today, and my own plugin in a runtime workbench, it works nicely.
Thank you very much for your answer, I appreciate it very much (and it is not common to receive this kind of support - so even more thanks to you :) !).
As a side note: I tried to also use the other method provided by Generate_JavaStructures which takes a model instead of an URI which I just created with JavaFactory.eInstance.createXXX() methods (and it includes a CompilationUnit).
The method returned with a nullpointer because my model did not have a resourceset. I then added a dummy resource and set, but then generation runs but doesnt output anything (in AcceleoService.doGenerate, the argumentType.isInstance(potentialTarget) always fails, even for CompilationUnit instances). What am I missing?
(The background of this is that I intend to create a model on-the-fly and then generate code without serialising the model first. This would be great to have).
Thanks again, and I am looking forward to your next releases,
Philip
|
|
|
Re: Java Code Generation with MoDisco [message #574795 is a reply to message #528478] |
Wed, 21 April 2010 08:23 |
Fabien Giquel Messages: 147 Registered: July 2009 |
Senior Member |
|
|
About using a model created from scratch : may be the java elements tree you have created is not complete enough.
Here is an minimal example which works :
ResourceSet rs = new ResourceSetImpl();
Resource r = new ResourceImpl();
rs.getResources().add(r);
Model m = JavaFactory.eINSTANCE.createModel();
m.setName("modelFromScratch");
CompilationUnit cu = JavaFactory.eINSTANCE.createCompilationUnit();
cu.setName("MyNewClass.java");
m.getCompilationUnits().add(cu);
org.eclipse.gmt.modisco.java.Package pkg = JavaFactory.eINSTANCE.createPackage();
pkg.setName("newPkg");
m.getOwnedElements().add(pkg);
ClassDeclaration c = JavaFactory.eINSTANCE.createClassDeclaration();
c.setName("MyNewClass");
cu.getTypes().add(c);
pkg.getOwnedElements().add(c);
r.getContents().add(m);
javaGenerator = new Generate_JavaStructures(m,
new File("C:/.../myOutputFolder"),
new ArrayList<Object>());
javaGenerator.doGenerate(null);
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
rue Nina Simone
44000 NANTES
----------------------------------------------------
|
|
|
Goto Forum:
Current Time: Thu Apr 25 22:34:26 GMT 2024
Powered by FUDForum. Page generated in 0.03177 seconds
|