Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Problem with emf2java ant script(How to define project locations in the emf2java task)
Problem with emf2java ant script [message #1053721] Tue, 07 May 2013 11:39 Go to next message
Victor Roy is currently offline Victor RoyFriend
Messages: 3
Registered: May 2013
Junior Member
Hello,
I am having trouble understanding the parameters that go into the emf2java ant task, so I am appealing here for help.

My (simple) ant script is the following:

<project name="myexample" basedir="/Users/vroy/Documents/workspace/myexample">
    <property name="model.dir"  value="model"/>
	<target name="generateSources">
		<emf.Ecore2Java model="${model.dir}/example.ecore"
			genModel="${model.dir}/example.genmodel" 
			generateModelProject = "true"
			generateEditProject = "true"
			generateEditorProject = "true"
			modelProject="${basedir}"
			modelProjectFragmentPath ="src">
			<arg line="-package http://example.eclipse.org/1.0 com.demo.emf.example.model example" />
			  <arg line="-modelProject //Users//vroy//Documents//workspace//com.demo.emf.example.model src"/>
			 <arg line="-editProject //Users//vroy//Documents//com.demo.emf.example.model.edit src"/>
			 <arg line="-editorProject //Users//vroy//Documents//com.demo.emf.example.model.editor src"/>
		</emf.Ecore2Java>
	</target>
</project>


The questions I have are the following:

a. I want to define the location of the edit and editor projects, relative to the model project but this is impossible. If I don't define an absolute path in the
<arg line=... 
then the projects are created inside the eclipse installation folders (on my mac, this means that are created inside /Applications/eclipse/Eclipse.app/Contents/MacOS ) no matter what. So, how can I define a relative location?

b. With the above script, if I try to place the newly created projects in my workspace, even with an absolute path I can't. They end up in the eclipse's installation folder. Why is this happening? Is there any way to fix it?

c. The above script sometimes fails, and I get the following error:
 
[emf.Ecore2Java] org.eclipse.core.internal.resources.ResourceException: Errors occurred while refreshing resources with the local file system.
...
[emf.Ecore2Java] 	at java.lang.Thread.run(Thread.java:722)
[emf.Ecore2Java] Contains: The project description file (.project) for 'com.demo.emf.example.model.edit' is missing.  This file contains important information about the project.  The project will not function properly until this file is restored.
BUILD SUCCESSFUL 


Any idea why?

I will appreciate any answers
Thanks in advance
V Roy
Re: Problem with emf2java ant script [message #1053754 is a reply to message #1053721] Tue, 07 May 2013 13:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Victor,

Comments below.

On 07/05/2013 3:06 PM, Victor Roy wrote:
> Hello,
> I am having trouble understanding the parameters that go into the
> emf2java ant task, so I am appealing here for help.
>
> My (simple) ant script is the following:
>
>
> <project name="myexample"
> basedir="/Users/vroy/Documents/workspace/myexample">
> <property name="model.dir" value="model"/>
> <target name="generateSources">
> <emf.Ecore2Java model="${model.dir}/example.ecore"
> genModel="${model.dir}/example.genmodel"
> generateModelProject = "true"
> generateEditProject = "true"
> generateEditorProject = "true"
> modelProject="${basedir}"
> modelProjectFragmentPath ="src">
> <arg line="-package http://example.eclipse.org/1.0
> com.demo.emf.example.model example" />
> <arg line="-modelProject
> //Users//vroy//Documents//workspace//com.demo.emf.example.model src"/>
> <arg line="-editProject
> //Users//vroy//Documents//com.demo.emf.example.model.edit src"/>
> <arg line="-editorProject
> //Users//vroy//Documents//com.demo.emf.example.model.editor src"/>
> </emf.Ecore2Java>
> </target>
> </project>
>
>
Unfortunately I really don't know much about how Ant works... But my
sense is that if you have an existing already populated *.genmodel then
it will have have all the project folders already specified and they'll
just work...

I found one script that looks like this, so maybe with some kind of
macro thingy you can specify some things only once...

<project default="codegen" basedir="..">
<dirname property="antfile.dir" file="${ant.file}"/>

<!-- Global properties -->
<property name="main.directory" location="${antfile.dir}/.."/>
<property name="output.directory" location="${main.directory}"/>
<property name="source.directory" value="src"/>
<property name="genJDKLevel" value="5.0"/>

<target name="codegen">

<!-- A macrodef makes it easier to generate code for multiple
models in one script. -->
<macrodef name="ecore2Java">
<attribute name="modelName"/>
<element name="settings"/>
<sequential>
<emf.Ecore2Java
model="${main.directory}/model/@{modelName}.ecore"
genModel="${output.directory}/emf/@{modelName}.genmodel"
modelProject="${output.directory}"
modelProjectFragmentPath="${source.directory}"
modelPluginID="@{modelName}.model"
copyright="This is my code."
jdkLevel="${genJDKLevel}">
<settings/>
</emf.Ecore2Java>
</sequential>
</macrodef>

<!-- Generating the code for the library model -->
<ecore2Java modelName="library">
<settings>
<arg line="-package http:///library.ecore org.examples
Library"/>
</settings>
</ecore2Java>

</target>
</project>


> The questions I have are the following:
>
> a. I want to define the location of the edit and editor projects,
> relative to the model project but this is impossible. If I don't
> define an absolute path in the
> <arg line=... then the projects are created inside the eclipse
> installation folders (on my mac, this means that are created inside
> /Applications/eclipse/Eclipse.app/Contents/MacOS ) no matter what. So,
> how can I define a relative location?
I think you'd need to use some kind of macro substitution in Ant itself.
>
> b. With the above script, if I try to place the newly created projects
> in my workspace, even with an absolute path I can't. They end up in
> the eclipse's installation folder. Why is this happening? Is there any
> way to fix it?
I don't know about that.
>
> c. The above script sometimes fails, and I get the following error:
>
> [emf.Ecore2Java]
> org.eclipse.core.internal.resources.ResourceException: Errors occurred
> while refreshing resources with the local file system.
> ..
> [emf.Ecore2Java] at java.lang.Thread.run(Thread.java:722)
> [emf.Ecore2Java] Contains: The project description file (.project) for
> 'com.demo.emf.example.model.edit' is missing. This file contains
> important information about the project. The project will not
> function properly until this file is restored.
> BUILD SUCCESSFUL
>
> Any idea why?
The generator does not produce .project files. IProjects are only
created when you generate in the IDE the normal way.
>
> I will appreciate any answers
> Thanks in advance
> V Roy


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Epatch in current EMF Compare
Next Topic:[EEF 2.0] How to use the reflective Editor?
Goto Forum:
  


Current Time: Sat Apr 20 03:12:35 GMT 2024

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

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

Back to the top