-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong version of emf.common during exec-maven-plugin and xtext-maven-plugin #2397
Comments
Yes, please do. |
@szarnekow OK, I'll do that ASAP, using the latest and greatest versions of EMF, is that OK? Or is there a minimal version we'd like to support? In any case, at least for mwe2 and xtext-maven-plugin we should get to the latest versions (or force emf.ecore to be a lower version?) I've just also realized that the BOM is in xtext-lib, not in xtext-core... we can check whether we can move this issue there. |
The problem is also that a ton of ecore files and genmodels and also code needs to be updated and I don’t have the time to bring this through until M3 I wonder how zoo end up with a newer emf code when we use 2.20 as default everywhere |
@cdietrich so should I update the EMF versions in the BOM? the ecore and genmodel files should be OK like that anyway, shouldn't they? |
These indeed might contain EMF versions in there, but that's merely for the code generation. The generated code itself is backwards / forwards compatible. I think we are good to "just" make the EMF versions consistent in the BOMs, as @LorenzoBettini mentioned 28 seconds ago |
This is not enough i still wonder how zog end up with bad code in the first place |
Just for curiosity: has no one else experienced such a problem? |
I don’t understand. The emf versions in the bom are consistent, aren’t they ? |
they are, but too old; somehow during mwe2 and xtext-maven-plugin a newer version of emf.ecore is used, which relies on a new version of emf.common (but the old version of emf.common is dragged in, and I get the problem I described). |
This is what I understood and so we would need a consistent bump not only in the bom but also in the rest of the code. so the question is why does emf 2.28 not produce 2.20 compatible code or does your ecore/genmodel not specify emf 2.20 |
Doesn't this indicate that they aren't? Or do you have managed EMF dependencies somewhere outside the bom? |
It does. Problem appears to be that emf.ecore has a dependency on emf.common but doesn't have exact lower version bounds in the manifest or the consumed emf pom has wrong lower version bounds or the xtext bom overrides these. |
But where is the problem |
And I don’t know why problem is not visible |
@cdietrich @szarnekow I'll have to investigate further, but I'm pretty sure the problem is, like it happened in the past, the xtext-maven-plugin used in a reactor with Tycho. As it happened in the past, the problems with xtext-maven-plugin did not take place in a pure Maven build, but only in a Maven/Tycho build (due to the mixture of p2 bundles and Maven JARs). I would say that the xtext-maven-plugin alters the final classpath generated by Tycho (by using a recent version of emf.ecore without a recent version of emf.common) and also breaks mwe2 when executed by exec-maven-plugin. I'm not blaming xtext-maven-plugin of course O:) |
Then the question would be why tycho does not pull in new versions of both plugins |
By the way, in the repo you mention, the example project using the xtext-maven-plugin is built with pure Maven, Tycho is not involved. Also in the past, when I spotted problems with the plugin, I had problems in a Tycho reactor, not with pure Maven. Later I'll try to investigate further. |
But the example project (where the xtext-maven-plugin is used), https://github.com/xtext/maven-xtext-example/tree/master/example-project, is not part of the reactor of the parent project. It's not built with Tycho, but with pure Maven. In fact, in the build.sh you first install all the bundles of the parent, and then you build the example-project alone. |
But you use tycho. Ok |
No, to build the example-project (the one using xtext-maven-plugin) you don't use Tycho at all |
Some updates: org.eclipse.emf:org.eclipse.emf.common:jar:2.17.0:compile (OLD VERSION) then p2.eclipse.plugin:org.eclipse.emf.common:eclipse-plugin:2.26.0.v20220817-1401:system (NEW VERSION) then p2.eclipse.plugin:org.eclipse.emf.ecore:eclipse-plugin:2.28.0.v20220817-1401:system (NEW VERSION) then org.eclipse.emf:org.eclipse.emf.ecore:jar:2.20.0:compile (OLD VERSION) So as you see, first the old version of emf.common is collected and then the newer version of emf.ecore is collected (before the old one), and that's the problem: the newer version of emf.ecore tries to access a new member of emf.common and it can't find it in the old version of emf.common. |
are deps in build.properties or inn manifest? |
That's the
and this is the
So it's the same as what the Xtext wizard creates. The difference is that this DSL is based on a parent POM. (the idea is to extract common configurations in a parent POM; something that I'm using for my DSLs and in the future I might propose as an Xtext feature). I can only guess that due some ordering of plugins, Tycho takes dependencies in a different order and the EMF Maven artifacts with version ranges (instead of strict versions) do the rest... As I said in the original post, I know how to fix that. However, I wondered if we (Xtext) can prevent these problems upstream. |
Another suspect: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext.xtext.generator/build.gradle I pinned all the platform dependencies in the past, which gave me headaches in a similar environment. I did not pin the EMF Maven dependencies because I did not realize they had version ranges. By looking at the p2 bundle of so it requires a recent version of emf.ecore but not of emf.common. The POM of the version of <dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.ecore</artifactId>
<version>[2.20.0,3.0.0)</version>
</dependency> without an explicit pin in build.gradle for emf.ecore, a newer version will be taken, which will be mixed up with an older version of emf.common. That's just a suspect. I'd have to patch xtext.xtext.generator, install it locally and see what happens. |
@cdietrich @szarnekow some updated. I'll try to explain my impression of the problem as clearly as possible, but there are few things involved. I made another experiment (slightly different from forcing I added in the <dependencies>
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>org.eclipse.xtext.xtext.generator</artifactId>
<version>${xtextVersion}</version>
</dependency>
</dependencies> This makes mwe2 run succeed. However, as I suspected, since the xtext.generator does NOT pin the emf.ecore and emf.common dependencies it drags newer versions:
But at least, it works because, besides the newer version of emf.ecore it also takes the newer version of emf.common. The So I pinned manually the dependencies to emf.ecore, emf.common and emf.ecore.xmi (yes, also the latter must be pinned) in the pom of xtext.xtext.generator in the .m2 cache. I know it's a dirty hack but it allows me to do such experiments without building a new version of xtext-core. With this manual hack, This means that these 3 emf dependencies must be pinned in https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext.xtext.generator/build.gradle So I though that pinning the versions of emf.ecore in xtext.generator would be enough, and I tried to remove the explicit dependency to xtext.generator from the exec plugin configuration and... BANG! It goes back to the original problem! Why? The emf dependencies are now pinned, so it shouldn't happen again. Another strange thing I was seeing during the maven/tycho run was that, even with all pinned dependencies in my hacked xtext.xtext.generator pom, maven metadata were still downloaded (without downloading any new jars), e.g., something like:
In my experience in fixing dependency problems, when I see something like that, it means that "some one" does not pin dependencies. With my hacked version of xtext.generator, it cannot be xtext.generator. Since this happens only when running exec plugin (and not xtext maven plugin) I think the culprit is the only other participant: mwe2! By looking at its poms, I see that mwe2.runtime (on which mwe2.language depends) has emf.ecore as a required bundle in the MANIFEST.MF (from an OSGI point of view) but it has NO Maven dependency to emf in the POM. I guess that's the source of the problem. Summarizing, I think we have to fix two things:
That's my impression. |
Because the EMF updatesite was not produced from deployed maven artifacts. |
so its done only if |
No it is done if |
ok, and as it looks like this one gets inherited if an upstream p2 repo is consumed downstream. so there is no option to get rid of it. |
That's the purpose, and actually there is no point in "get rid of it" ... because it allows Tycho to use the real maven artifact instead of a (misused) system scoped dependency with generated maven coordinates. The problem only arises because you want to mix released M3 artifacts with SNAPSHOT artifacts and even newer versions like used in the M3 build from a different library that you have pinned in your M3 release to an older version. So from maven POV, either your M3 release is obviously not compatible with newer EMF releases using different techniques, or the emf dependency should not be a And that's why pinning dependencies to fix downstream maven versionranges is bad and why I asked platform to fix that instead of trying to fix that in Tycho ;-) |
but a provided dependency wont work in pure gradle or maven projects where there is no target platform |
That's just not true. It does work as specified by the maven inclusion rules that is that provided dependencies are not inherited (and that's it purpose), so a consumer simply need to require |
but this requires 1000s of clients to be spoiled with exclude and include rules |
maybe we should abandon p2 and tycho for the exec part alltogether and have a own run workflow plugin to avoid the problem |
Whatever suites... the usual maven way is to provide a |
we have a bom. but it does not work here... |
The bom is for the maven users where " provided dependency wont work" ... you can add emf there as a compile/provided/... dependency and other projects can import it. |
I am not firm in maven enhough to understand the proposal @LorenzoBettini cab you help out |
Hi everyone! I haven't run away after opening Pandora's box ;) |
I confirm that just putting emf.common on top of the required bundles fixes the problem: https://github.com/LorenzoBettini/issue-2000-example/pull/1/files This looks like a kind of hack to me, though |
See #2000 This is the same but for org.eclipse.xtext Signed-off-by: Lorenzo Bettini [email protected]
I don't know if it's because of eclipse/xtext-core#2021 but with the released Xtext 2.29.0, the problem went away in the example project LorenzoBettini/issue-2000-example#3 |
I think we can close this one now |
I'm trying to build one of my (involved) DSL with Xtext 2.29.0.M2. I've updated the TP and the POM (I'm using the xtext-dev-bom).
During the execution of exec-maven-plugin (for running MWE2) I get this error:
Similarly, when running xtext-maven-plugin:
From what I understand, a new version of emf.ecore is used but an older version of emf.common, where that static field is not yet available.
In fact, version 2.20 of emf.ecore used to execute
while the version 2.28 of emf.ecore (which is the one being used) does
The xtext-dev-bom specifies 2.17.0 for emf.common, which is extremely old. It looks like that version of emf.common is used together with emf.ecore 2.28 and BANG.
I'm not doing strange thing with the TP nor with the POM (hopefully).
If I redefine in my parent's POM dependencyManagement section the version of emf.common
then mwe2 runs fine.
Similarly, I have to make this dependency explicit in the pluginManagement configuration of xtext-maven-plugin
then also this plugin runs fine.
Why is the version of emf.common is so old in the BOM? Shouldn't the versions of emf in the BOM be updated?
The text was updated successfully, but these errors were encountered: