Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ecore2Java Generation task
Ecore2Java Generation task [message #427112] Mon, 02 February 2009 15:46 Go to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi there,

I am using an ant script to generate the java code from an ecore model but
the model, edit and editor projects have dependencies issues.

Does anybody have an idea how to resolve this since I want to fully
automate the process?

Regards,

Achilleas
Re: Ecore2Java Generation task [message #427114 is a reply to message #427112] Mon, 02 February 2009 16:33 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi,

Actually the model project is not generated as a Java project and
therefore its classes cannot be imported by the edit and editor projects!

Any ideas why is that happening? The script is the following:

<project name="Ecore2Java Generation" default="GenerateJava" basedir=".">

<property name="model" value="./model/cpetypes.ecore"/>
<property name="genmodel" value="./model/cpetypes.genmodel"/>

<taskdef name="emfGen"
classname="org.eclipse.emf.importer.ecore.taskdefs.EcoreGeneratorTask "/>

<target name="GenerateJava">
<echo message="Generate the model,edit and editor Java code from the
ecore model"/>
<emf.Ecore2Java model="${model}"
genModel="${genmodel}"
modelProject="bt.com.cpetypes.model"
reconcileGenModel="keep"
generateJavaCode="true"
generateModelProject="true"
generateEditProject="true"
generateEditorProject="true"
modelProjectFragmentPath="src">
</emf.Ecore2Java>
</target>
</project>

Thanks,

Achilleas
Re: Ecore2Java Generation task [message #427116 is a reply to message #427114] Mon, 02 February 2009 17:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Achilleas,

That probably means there was an existing folder in the file system. If
there is already a project, EMF won't change it to become a Java
project, it needs to be one already...


Achilleas wrote:
> Hi,
>
> Actually the model project is not generated as a Java project and
> therefore its classes cannot be imported by the edit and editor projects!
>
> Any ideas why is that happening? The script is the following:
>
> <project name="Ecore2Java Generation" default="GenerateJava" basedir=".">
>
> <property name="model" value="./model/cpetypes.ecore"/>
> <property name="genmodel" value="./model/cpetypes.genmodel"/>
>
> <taskdef name="emfGen"
> classname="org.eclipse.emf.importer.ecore.taskdefs.EcoreGeneratorTask "/>
>
> <target name="GenerateJava">
> <echo message="Generate the model,edit and editor Java code
> from the ecore model"/>
> <emf.Ecore2Java model="${model}"
> genModel="${genmodel}"
> modelProject="bt.com.cpetypes.model"
> reconcileGenModel="keep"
> generateJavaCode="true"
> generateModelProject="true"
> generateEditProject="true"
> generateEditorProject="true"
> modelProjectFragmentPath="src">
> </emf.Ecore2Java>
> </target>
> </project>
>
> Thanks,
>
> Achilleas
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore2Java Generation task [message #427117 is a reply to message #427116] Mon, 02 February 2009 17:44 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Ed,

Actually what i found out is that the properties Model directory, edit
directory and editor directory generated in the genmodel are not as
supposed. They are generated like this:

Edit Directory /Borland.edit/src
Editor Directory /Borland.editor/src
Model Directory
D:/Borland/Together/workspace/bt.com.cpemss.plugin/bt.com.cp etypes.model/./src/.

So, i am trying first to resolve this! Any suggestions are welcomed!

Thanks,

Achilleas
Re: Ecore2Java Generation task [message #427120 is a reply to message #427117] Mon, 02 February 2009 18:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Achilleas,

The last guy that had odd problems like this found it was related to an
error in the paths he gave for the ecore/genmodel. Perhaps your files
exist with a different case. I don't know much about Ant, so it's hard
to guess...


Achilleas wrote:
> Hi Ed,
>
> Actually what i found out is that the properties Model directory, edit
> directory and editor directory generated in the genmodel are not as
> supposed. They are generated like this:
>
> Edit Directory /Borland.edit/src
> Editor Directory /Borland.editor/src
> Model Directory
> D:/Borland/Together/workspace/bt.com.cpemss.plugin/bt.com.cp etypes.model/./src/.
>
>
> So, i am trying first to resolve this! Any suggestions are welcomed!
>
> Thanks,
>
> Achilleas
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore2Java Generation task [message #427121 is a reply to message #427120] Mon, 02 February 2009 18:47 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Yes,

It is related to the paths given for the genmodel, since if I manually
edit these properties in the genmodel and then generate the java code the
resulting projects are just fine!

I am trying to change the paths so that this problem does not arise. I
hope someone that has more experience with ant can give an input on this.

Thanks Ed for the valuable inputs. At least we identified the problem:)

Achilleas
Re: Ecore2Java Generation task [message #427123 is a reply to message #427121] Mon, 02 February 2009 19:49 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Anyone has any ideas how to set this paths?

I tried also what it is advised at:

http://wiki.eclipse.org/EMF/FAQ#How_can_I_use_the_EMF_Ant_ta sks.3F

to set the editProject and editorProject:

<arg line="-editProject bt.com.cpetypes.model.edit src"/>
<arg line="-editorProject bt.com.cpetypes.model.editor src"/>

But still the model, edit and editor directory properties are set to
something else?

Some help by anyone will be appreciated. I am running the ant file from
eclipse. Should i set anything else?

Thanks,

Achilleas
Re: Ecore2Java Generation task [message #427124 is a reply to message #427123] Mon, 02 February 2009 20:26 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Sorry for posting so many times but i don't seem to find a solution on how
to set the following properties that are set inside the genmodel:

Edit Directory D:/Borland/Together/bt.com.cpetypes.model.edit/./src/.

Editor Directory D:/Borland/Together/bt.com.cpetypes.model.editor/./src/.

Model Directory
D:/Borland/Together/workspace/bt.com.cpemss.plugin/bt.com.cp etypes.model/./src/.

Once the genmodel is generated if i change those properties to the correct
ones then the generation of the code is just fine.

Still looking for ideas how to do that!!

Achilleas
Re: Ecore2Java Generation task [message #427127 is a reply to message #427124] Tue, 03 February 2009 06:13 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040308040709090005060503
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Achilleas,

I've put together a very simple example that, starting from a .ecore
file, creates a generator model and also generate the java files. All
you will need to do to try it is to edit the .bat file (ECLIPSE_DIR,
WORKSPACE_DIR, and MODEL_DIR variables) before running it. This script
uses the Eclipse Ant runner to execute the build.xml also included in
the zip.

If analyzing these files and the generated .genmodel doesn't help
solving your problem, send me your .ecore file and the directory
structure you would like to end up with. I will see if I can make it work.

FYI, I've used eclipse-SDK-3.4.1 and emf-sdo-xsd-SDK-2.4.1 to test the
files.

Cheers,
Marcelo

Achilleas wrote:
> Sorry for posting so many times but i don't seem to find a solution on
> how to set the following properties that are set inside the genmodel:
>
> Edit Directory D:/Borland/Together/bt.com.cpetypes.model.edit/./src/.
>
> Editor Directory D:/Borland/Together/bt.com.cpetypes.model.editor/./src/.
>
> Model Directory
> D:/Borland/Together/workspace/bt.com.cpemss.plugin/bt.com.cp etypes.model/./src/.
>
>
> Once the genmodel is generated if i change those properties to the
> correct ones then the generation of the code is just fine.
>
> Still looking for ideas how to do that!!
>
> Achilleas
>

--------------040308040709090005060503
Content-Type: application/octet-stream;
name="files.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="files.zip"

UEsDBBQAAAAIABUHQzqcWm96/AAAANcBAAAJAAAAYnVpbGQueG1sbZHPTsMw DMbPReIdIovr
EkBC4pB0F5gEAmkHeICs9UpGmiI3rUCId8dN96fTdov8/b7Y/qzn37UXPVLr mmDgRl6DwFA0
pQuVgfe3xewe5vnlhf6iZoNFFCWubeejAWawwgBiZVssHRmQwGCmo6UKowi2 xj2VlExjvZaP
RUN4+2x7O5SymgFvwLsVWfqROKiQFLa9juLVb6Ikd/lT6al2PEOpAIfPluOk x7ZTfUG2qjHE
pY0fBloqpojvKheeHvZzjdqm/HzBfpjojnPKU03ztsK7wLvOOIa4/V1Mm0sO r3clkhjaqPPG
hs5aOzcxaXWcYMpbjYEPR1LbK+X/UEsDBBQAAAAIAEcHQzqT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IytckyVVaxvy4uc5ut2XZpx07ju7v1XAnOc6KHFGAaZI0 Se79PcvSaBRK
x6BxwmhT6CrCV+htEorzfirg/1S3jO8DFffcvNbH52Dj5Rn85/zOdBrXalqj oQ6sHkiucrrL
HX03o+PUYSWVD3GuJNIvkQUvfqrRXHgdMVUmtCLZ5Y3z8LV4yND6+5LpN1BL AQIUABQAAAAI
ABUHQzqcWm96/AAAANcBAAAJAAAAAAAAAAAAIAAAAAAAAABidWlsZC54bWxQ SwECFAAUAAAA
CABHB0M6k9VOFlwBAAB2AgAACwAAAAAAAAAAACAAAAAjAQAAY29kZUdlbi5i YXRQSwECFAAU
AAAACAB8eqo0vUXHSfwBAAC4BwAADQAAAAAAAAAAACAAAACoAgAAbGlicmFy eS5lY29yZVBL
BQYAAAAAAwADAKsAAADPBAAAAAA=
--------------040308040709090005060503--
Re: Ecore2Java Generation task [message #427130 is a reply to message #427127] Tue, 03 February 2009 10:28 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Marcelo,

Thanks for the example. I will try that and see if I can resolve my
problem. The problem is though that I am trying to run the ant script
within Borland together from a plug-in which I created.

I am not using a batch file to do that. Despite that fact your example
might give me a clue how to change those paths within Borland together.

I will let you know soon of the result.

Thanks,

Achilleas
Re: Ecore2Java Generation task [message #427186 is a reply to message #427130] Thu, 05 February 2009 12:10 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Marcelo,

I have tried your example outside eclipse running the batch file with my
working paths and it has generated the code.

It does the same thing if I run it within eclipse, within borland, and via
the headless batch file. To be more precise the .genmodel that it is
generated contains invalid properties. These properties are the Model
directory, the Edit directory and the Editor directory.

It is always appended at the start something like:

If I run it within Eclipse:

Model Directory:D:/PhD/Development
Tools/iMDE/eclipse/workspace/bt.com.cpetypes.metamodel/bt.co m.cpetypes.metamodel/./src/.
Edit Directory: D:/PhD/Development
Tools/iMDE/eclipse/bt.com.cpetypes.metamodel.edit/./src/.
Editor Directory:D:/PhD/Development
Tools/iMDE/eclipse/bt.com.cpetypes.metamodel.editor/./src/.

instead of being the correct ones:

Model Directory: /bt.com.cpetypes.metamodel/src/
Edit Directory: /bt.com.cpetypes.metamodel.edit/src/
Editor Directory: /bt.com.cpetypes.metamodel.editor/src/

If I run it within Borland:

Model
Directory:D:/Borland/Together/bt.com.cpetypes.metamodel/bt.c om.cpetypes.metamodel/./src/.
Edit Directory: D:/Borland/Together/bt.com.cpetypes.metamodel.edit/./src/.
Editor
Directory:D:/Borland/Together/bt.com.cpetypes.metamodel.edit or/./src/.

instead of being again the correct ones:

Model Directory: /bt.com.cpetypes.metamodel/src/
Edit Directory: /bt.com.cpetypes.metamodel.edit/src/
Editor Directory: /bt.com.cpetypes.metamodel.editor/src/

While running the script the code is generated, the edit and editor
projects generated are not even set to be Java projects. Moreover the
genmodel includes this incorrect properties I mentioned above.

When correcting the properties manually from the properties view and
generating the code by right-click command on the .genmodel the code is
perfectly ok and I can run the editor as an eclipse instance.

I don't know why the path is appended and alters the properties. I tried
everything and searched everywhere to find a solution before bothering you
again! If you could provide me with a solution I will be grateful!

How can I attach a zip file while posting:)??

Thanks,

Achilleas
Re: Ecore2Java Generation task [message #427193 is a reply to message #427186] Thu, 05 February 2009 13:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Achilleas,

Comments below.


Achilleas wrote:
> Hi Marcelo,
>
> I have tried your example outside eclipse running the batch file with
> my working paths and it has generated the code.
>
> It does the same thing if I run it within eclipse, within borland, and
> via the headless batch file. To be more precise the .genmodel that it
> is generated contains invalid properties. These properties are the
> Model directory, the Edit directory and the Editor directory.
>
> It is always appended at the start something like:
>
> If I run it within Eclipse:
>
> Model Directory:D:/PhD/Development
> Tools/iMDE/eclipse/workspace/bt.com.cpetypes.metamodel/bt.co m.cpetypes.metamodel/./src/.
>
> Edit Directory: D:/PhD/Development
> Tools/iMDE/eclipse/bt.com.cpetypes.metamodel.edit/./src/.
> Editor Directory:D:/PhD/Development
> Tools/iMDE/eclipse/bt.com.cpetypes.metamodel.editor/./src/.
>
> instead of being the correct ones:
>
> Model Directory: /bt.com.cpetypes.metamodel/src/
> Edit Directory: /bt.com.cpetypes.metamodel.edit/src/
> Editor Directory: /bt.com.cpetypes.metamodel.editor/src/
This is simply the different behavior that you get between stand-alone
and Eclipse.
>
> If I run it within Borland:
>
> Model
> Directory:D:/Borland/Together/bt.com.cpetypes.metamodel/bt.c om.cpetypes.metamodel/./src/.
>
> Edit Directory:
> D:/Borland/Together/bt.com.cpetypes.metamodel.edit/./src/.
> Editor
> Directory:D:/Borland/Together/bt.com.cpetypes.metamodel.edit or/./src/.
>
> instead of being again the correct ones:
>
> Model Directory: /bt.com.cpetypes.metamodel/src/
> Edit Directory: /bt.com.cpetypes.metamodel.edit/src/
> Editor Directory: /bt.com.cpetypes.metamodel.editor/src/
>
> While running the script the code is generated, the edit and editor
> projects generated are not even set to be Java projects. Moreover the
> genmodel includes this incorrect properties I mentioned above.
Again, if you aren't running in Eclipse you don't get all the nice
Eclipse effects.
> When correcting the properties manually from the properties view and
> generating the code by right-click command on the .genmodel the code
> is perfectly ok and I can run the editor as an eclipse instance.
Generally what most people do is preserve their GenModel and reuse it.
The scripts allow you to reload the existing GenModel such that it's
up-to-date with respect to any model changes, but also preserves all the
settings within the *.genmodel.
>
> I don't know why the path is appended and alters the properties. I
> tried everything and searched everywhere to find a solution before
> bothering you again! If you could provide me with a solution I will be
> grateful!
The path of least resistance is to preserve your *.genmodel file, rather
than creating a new one from scratch...
>
> How can I attach a zip file while posting:)??
I use Thunderbird for accessing the newsgroup. It's very nice.
>
> Thanks,
>
> Achilleas
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore2Java Generation task [message #427203 is a reply to message #427193] Thu, 05 February 2009 15:17 Go to previous message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Ed and Marcelo,

Thanks to both of you guys for directing me to the solution to my problem.
I think the problem is not resolved completely, meaning that I have
manually created a .genmodel for which I only set manually these three
properties.

This is performed Ed since in any case either using a batch file, Eclipse
or Borland Together the path to the eclipse, borland or batch file is
appended to these three properties. I don't know if that is how the
impementation of the EcoreGeneratorTask works? I presume it is from the
result.

So, your suggestion Ed to preserve a .genmodel let me to the idea to
create a skeleton .genmodel and via the reconcileGenModel="reload"
property to reload the model changes from the .ecore metamodel by
executing the ant script.

Thanks for both your help,

Achilleas
Previous Topic:[EMF] How to create an instance of an ecore model
Next Topic:Philosophical Question
Goto Forum:
  


Current Time: Fri Apr 26 23:58:53 GMT 2024

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

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

Back to the top