Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How do I specify EMF genmodel compliance level in an Ant Java task
How do I specify EMF genmodel compliance level in an Ant Java task [message #1785594] Tue, 17 April 2018 09:58 Go to next message
Bill Sherman is currently offline Bill ShermanFriend
Messages: 10
Registered: April 2018
Junior Member
How do I specify GenModel compliance level in this Ant Java task?

<java fork="true" classname="org.eclipse.equinox.launcher.Main">
    <arg value="-clean"/>
    <arg value="-noupdate"/>
    <arg value="-data"/>
    <arg path="${redacted}"/>
    <arg value="-application"/>
    <arg value="org.eclipse.xsd.ecore.importer.XSD2GenModel"/>
    <arg file="${stubs.xsd}"/>
    <arg file="${stubs.genmodel}"/>
    <arg value="-modelProject"/>
    <arg path="${stubs.dir}/redcated"/>
    <arg value="src"/>
    <arg value="-sdo"/>
    <arg value="-templatePath"/>
    <arg file="${stubs.templates}"/>
    <classpath>
        <pathelement location="${java.class.path}"/>
        <pathelement location="${eclipse.dir}/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar"/>
    </classpath>
</java>
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785612 is a reply to message #1785594] Tue, 17 April 2018 13:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
In general I would suggest taking to approach of doing this conversion in the IDE and keeping the *.genmodel in your source code control system. As I mentioned in the Newcommers forum thread, the GenModel has a great many properties you can set and not all of them (in fact very few of them) can be set from this application'via command line arguments. To generate code without generics, you'd have to set the GenModel's Compliance Level property to 1.4.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785616 is a reply to message #1785612] Tue, 17 April 2018 14:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you really need a programmatic XSD2GenModel, I suggest developing an MWE2 bean in which you can choose all the parameters you want. You might get some inspiration from my Ecore+GenModel reconcile and generate script and its invocations.

http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/utilities/GenerateModel.java

You can of course improve the Ant task, but unfortunately Ant integrates badly with Eclipse leading to development challenges that demotivate maintainers. Use of Ant is not encouraged. Now that EMF is built with Maven/Tycho, you might find that most of the Ant build nightmares are hidden from you.

Regards

Ed Willink

Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785621 is a reply to message #1785616] Tue, 17 April 2018 14:48 Go to previous messageGo to next message
Bill Sherman is currently offline Bill ShermanFriend
Messages: 10
Registered: April 2018
Junior Member
Oh GOSH! Since this is an old project I was hoping not to have to do a complete paradigm revamp just to make a simple change. I also wanted to make it easy for the next person: "Just start the Ant script dude!"

Being the "hacker" that I am, I added an Ant ReplaceRegEx task that replaces all occurrences of the offending generics in the generated source, such as EList<...> with EList. Now my compile errors are gone.

Veni, vidi, vici.
Bill
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785644 is a reply to message #1785621] Tue, 17 April 2018 21:12 Go to previous messageGo to next message
Bill Sherman is currently offline Bill ShermanFriend
Messages: 10
Registered: April 2018
Junior Member
Well that didn't go as well as I'd hoped. Older Java code generated by this process generates lines such as

return SchemaPackageImpl.Literals.CONTINUE_ACTION_REQUEST_TYPE;

while the same process -- but with newer versions of Eclipse and other packages/plug-ins -- generates slightly different code:

return SchemaPackageImpl.eINSTANCE.getContinueActionRequestType();

This is causing incompatibility between older code and newer code. It seems like I will indeed have to shift to using the IDE method.

Do you know what version of EMF the original behavior (using Literals) existed in? If I switch to compatibility with 1.4 do you think I'll get the older style code?

Based on the Eclipse command line I originally posted, can somebody provide me with a starting point on converting this project away from using the Eclipse command line?

Thank you,
Bill
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785651 is a reply to message #1785644] Wed, 18 April 2018 05:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
There is this tutorial:

https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.emf.doc%2Ftutorials%2Fxlibmod%2Fxlibmod.html&cp=34_1_2

But I expect you're using stuff based on SDO, and support for that has long been discontinued, i.e., the runtime libraries are no longer shipped and the code for it is removed. In the application, the -sdo argument produces these changes to the GenModel:
  public static void setSDODefaults(GenModel genModel)
  {
    genModel.setRootExtendsInterface("");
    genModel.setRootImplementsInterface("org.eclipse.emf.ecore.sdo.InternalEDataObject");
    genModel.setRootExtendsClass("org.eclipse.emf.ecore.sdo.impl.EDataObjectImpl");
    genModel.setFeatureMapWrapperInterface("commonj.sdo.Sequence");
    genModel.setFeatureMapWrapperInternalInterface("org.eclipse.emf.ecore.sdo.util.ESequence");
    genModel.setFeatureMapWrapperClass("org.eclipse.emf.ecore.sdo.util.BasicESequence");
    genModel.setSuppressEMFTypes(true);
    genModel.setSuppressEMFMetaData(true);

    genModel.getModelPluginVariables().add("EMF_COMMONJ_SDO=org.eclipse.emf.commonj.sdo");
    genModel.getModelPluginVariables().add("EMF_ECORE_SDO=org.eclipse.emf.ecore.sdo");

    genModel.getStaticPackages().add("http://www.eclipse.org/emf/2003/SDO");
  }


Whether a Literals interface is generated for a given GenPackage is determined by the "Literals Interface" property on that GenPackage; the GenPackages are the objects nested under the root GenModel element in the Generator editor.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785683 is a reply to message #1785651] Wed, 18 April 2018 10:44 Go to previous messageGo to next message
Bill Sherman is currently offline Bill ShermanFriend
Messages: 10
Registered: April 2018
Junior Member
In the original package that was given to me are the following relevant files: schema.ecore (about 1MiB), projectName.genmodel (about 250KiB), and 5 projectName_variousSuffixes.xsd files (one that has its own contents but also includes the other 4) each about 12KiB. How can I tell if one or more of these were derived from the others, or if all need to be "combined"? I had come across that tutorial previously but was concerned that I already had a GenModel file and an ecore file in addition to the XSDs.

Do you think it might be possible for me to find an old version of Eclipse with older modeling tools that would "just work" using the command-line method and giving me the older style results that I need? Project deadline is looming -- obviously no fault of yours! I'm trying to find the quickest solution, not the best solution.

Thank you so much for all of your assistance!
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785685 is a reply to message #1785683] Wed, 18 April 2018 11:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You can do XSD2Ecore and vice-versa so it is not trivial.

Timestamps might tell you which came first; the master should be much earlier.

Elegance may also give you a clue. Generated files tend to be much more uniform with some bloated content.

If you have a choice, it is much better to treat Ecore qualified by GenModel as source and XSD as derived. This should upgrade to current tooling easily. But XSD is usually there because it is the source, so an old Eclipse may be the choice.

If you are unlucky XSD was the source but the derived Ecore/GenModel were manually improved.

Make sure you use a correspondingly old Java.

Regards

Ed Willink
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785694 is a reply to message #1785685] Wed, 18 April 2018 12:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Here's the old download page:

https://www.eclipse.org/modeling/emf/downloads/index.php?project=core

EMF 2.4 appears to be the last version that included the SDO runtime. So perhaps this older version will just do what it did before:

http://archive.eclipse.org/modeling/emf/emf/downloads/drops/2.4.3/M201005200038/

I wonder why you need to regenerate. Did the model change? If so was it the *.ecore that changed or the *.xsd? My assumption would be that the *.xsd was the master, otherwise you'd not have an XSD2Ecore setup. But I still wonder why you need to regenerate; something must have changed...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785698 is a reply to message #1785694] Wed, 18 April 2018 13:52 Go to previous messageGo to next message
Bill Sherman is currently offline Bill ShermanFriend
Messages: 10
Registered: April 2018
Junior Member
Ed,

I had to make a minor adjustment to the model; I made an addition to one of the xsd files.

Unfortunately the .xsd files, .ecore file, and .genmodel file all have the exact same timestamp! I suspect that they were retrieved from some source control system and they failed to save (and/or retain) the original timestamp. Argh!

In order to install EMF 2.4 ... do I need to remove the existing support first?

Thank you so much for the speedy response!!!
Bill
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785705 is a reply to message #1785698] Wed, 18 April 2018 15:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
I'm not sure you really can install such old stuff in a newer IDE. Newer IDEs require a p2 repo. But perhaps via copying to the drop-ins folder. It's really very old stuff.

Personally I would open the *.genmodel in the workspace and use the Reload... to update it from the corresponding *.xsd. I'd look closely at any and all changes to the *.ecore and *.genmodel, and then change the necessary properties in the GenModel to make the generator to produce results compatible with your very very older runtime.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How do I specify EMF genmodel compliance level in an Ant Java task [message #1785707 is a reply to message #1785705] Wed, 18 April 2018 15:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Using a radically different IDE version is asking for big trouble. The newer IDEs successively require Java 6/7/8 that did not exist in pre-Java 5 generics days. On no account mix and match.

Installation should be 'easy'.

Install Java 5 perhaps even Java 4.

Unzip the Eclipse SDK. Sort out your start up short cut/eclipse.ini to use Java 4/5 and check that you can develop Hello world. If there is an install new software, use it to install the EMF ZIP. Otherwise Unzip EMF into the plugins folder. Either way restart.

Regards

Ed Willink
Previous Topic:Custom field on Property object in metamodel
Next Topic:sorting options with resource save api
Goto Forum:
  


Current Time: Fri Mar 29 01:54:34 GMT 2024

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

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

Back to the top