[YANGTOOLS-716] yang-maven-plugin built-in M2E support Created: 14/Nov/16 Updated: 10/Apr/22 Resolved: 01/Mar/17 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Highest |
| Reporter: | Michael Vorburger | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Epic Link: | Fix Maven Codegen API |
| Description |
|
Background: Lifecycle mappings are instructions for the Maven integration in the Eclipse IDE (M2E) what to do with Maven plugins; see e.g. https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html for an introduction. yang-maven-plugin currently has no built-in lifecycle mapping. The current solution thus is to either: (a) manually yourself set an <ignore /> for yang-maven-plugin, which will cause M2E to completely ignore yang-maven-plugin, and so end-users just do "mvn generate-sources" whenever they initially import projects, change *.yang models, or switch branches (and the branch switching IMHO is in practice the most common and often used use case requiring manual action among the three...). (b) use the M2Eclipse extension for the yang-maven-plugin which is available in the org.opendaylight.yangide.m2e.yang Eclipse plugin that is part of yangide (YangProjectConfigurator). I used to myself use, and through https://github.com/vorburger/opendaylight-eclipse-setup advocate for, the option (b) for the last 6 months. But I've meanwhile changed my mind and am about to switch this to (a) instead, because yangide: (ii) embeds a easily outdated copy of yangtools JARs in its org.opendaylight.yangide.core Eclipse Plugin's libs/; (iii) is not currently actively maintained. Long story short, and to get to the point of this enhancement: In an ideal world, from what I understand about this stuff, yang-maven-plugin would itself already provide lifecycle mapping metadata - https://wiki.eclipse.org/M2E_compatible_maven_plugins describes how this can be achieved. This would apparently also require the yang-maven-plugin to be written to be "IDE-invokeable" by using, only BuildContext to write files and emit validation errors. It doesn't look very complicated; but the one thing that I would be slightly worried about is performance; if m2e assume stateless yang-maven-plugin with no static (I'm not sure it does; to be explored), it may be slow if it has to re-construct its "index" constantly? (That's basically what the index that part of yangide is for, which takes time o construct, from what I understand.) I personally don't have bandwidth to dig further into this in the short term, but I'll keep it on a list of possible things to look at over the next.. months, likely. If anyone reads this and would like to have a stab at it, please go for it and don't let me hold you back. (But I'd certainly be willing to collaborate with/review/test etc. any work related to this.) |
| Comments |
| Comment by Michael Vorburger [ 14/Nov/16 ] |
|
> because yangide: (iv) doesn't "work" reliably anyway; e.g. on switch branches it does NOT currently appear to automatically transparently re-generate the required code |
| Comment by Robert Varga [ 20/Feb/17 ] |
|
master: https://git.opendaylight.org/gerrit/52087 For completely reliable operation, BUG-175 needs to be addressed so we can have an intermediate layer between generators and the plugin – otherwise we cannot guarantee generators' interactions. |
| Comment by Robert Varga [ 23/Feb/17 ] |
| Comment by Michael Vorburger [ 28/Feb/17 ] |
|
https://git.opendaylight.org/gerrit/#/c/52416/ to clean gen. output dir in IDE.. |
| Comment by Michael Vorburger [ 28/Feb/17 ] |
|
I've just done more testing re. this: to see if it's now possible (after c/52416 will be merged), or still premature, to remove the lifecycle-mapping ignore that we currently have in opendaylight-eclipse-setup.. First observation: A number of projects actually have a lifecycle-mapping ignore for yang-maven-plugin hard-coded in their pom.xml; e.g. genius/lockmanager/ {api,impl}- all of those would have to be cleaned-up for this to really work as expected (I'll be raising Gerrits for that). Second observation: menu Project > Clean full build does apparently NOT trigger M2E plugin execution - you HAVE to do project right click Maven > Update Project <Alt F5> to "Update project configuration from pom.xml" for the yang-maven-plugin code generation to run in-IDE. Third observation: Eclipse / M2E is, kind of obviously, not smart enough to trigger and order Project inter dependencies when running plugins.. e.g. if you do "mvno -Pide clean" in genius and then Maven > Update Project one or a few projects, you often run into this kind of error (in the Error Log) - because dependant projects have not yet been generated... (I found this surprising, because even though I'd expect Java compilation red errors from gen. code ref. to other gen. code from dependant projects, the YANG parsing should still have worked?) Failed to parse YANG from source SourceSpecificContext [source=META-INF/yang/mdsalutil-impl.yang, current=SOURCE_PRE_LINKAGE, finished=INIT]: Imported module [odl-mdsalutil] was not found. [at META-INF/yang/mdsalutil-impl.yang:8:4] The solution to this is to do the Maven > Update Project on all open projects (or e.g. on a working set) after a clean; that seems to work. |
| Comment by Michael Vorburger [ 28/Feb/17 ] |
|
Performance timing wise, I'm seeing this having a significant impact that warrants more measurements - e.g. on Genius, a project clean without this (with lifecycle-mapping ignore for yang-maven-plugin) is ca. 1-ish minute, whereas with this it's ca. 4 minutes. But a CLI "mvn -Pq generate-sources" in genius takes only ca. 1.5 minutes, so... code gen. by M2E is for some reason apparently (how can that be?), quite a bit, slower than on CLI mvn... The big Q then becomes if it's a Good Idea to transparently enable this for end-users, so that e.g. a new git clone and branch switching things "just work" (no red, even if full workspace rebuild is a bit slower) - or whether it's better to keep it on ignore and let people have to do "mvn -Pq generate-sources" on CLI as is now (which is a PITA). |
| Comment by Michael Vorburger [ 01/Mar/17 ] |
|
> Performance timing wise, I'm seeing this having a significant impact FTR: I was measuring this using latest Version: Neon.2 Release (4.6.2) Build id: 20161208-0600, as I'm struggling with bleeding edge Oxygen for other reasons > a CLI "mvn -Pq generate-sources" in genius takes only ca. 1.5 minutes that perhaps wasn't an entirely fair comparison, because that only gen. code but does not compile, better to compare it with e.g. a "mvn -o -Pq clean package" which is ca. 2.5 minutes. > whereas with this it's ca. 4 minutes or ca. 3.15 min. on measuring it again.. but still significantly more than the 1 min. without YANG code gen. in IDE, and the time on CLI .. although now the diff is ca. 45s, perhaps acceptable. |
| Comment by Michael Vorburger [ 01/Mar/17 ] |
|
>> whereas with this it's ca. 4 minutes or ca. 2.55 min if I give Eclipse -Xmx4096m instead of -Xmx2048m |
| Comment by Michael Vorburger [ 01/Mar/17 ] |
|
Also requires https://git.opendaylight.org/gerrit/#/c/52440/ re. target/ |