[YANGTOOLS-410] Classes were not generated under destination folder, cause compilation error of generated classes Created: 14/Feb/15 Updated: 10/Apr/22 Resolved: 18/Feb/15 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Minna Hu | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| External issue ID: | 2720 | ||||||||
| Description |
|
Hi I want to generate java classes from ietf-inet-types@2010-09-24.yang and ietf-netconf-monitoring@2010-10-04.yang, I defined the generation folder to be target/test/src, but there are several classes generated under src/main/java, as attached picture. It causes compilation error, do you know why? Thank you! Yang files are also attached. |
| Comments |
| Comment by Minna Hu [ 14/Feb/15 ] |
|
Attachment ietf-netconf-monitoring@2010-10-04.yang has been added with description: ietf-netconf-monitoring |
| Comment by Minna Hu [ 14/Feb/15 ] |
|
Attachment ietf-inet-types@2010-09-24.yang has been added with description: ietf-inet-type |
| Comment by Minna Hu [ 14/Feb/15 ] |
|
Attachment bug.PNG has been added with description: classes generated in wrong place |
| Comment by Tony Tkacik [ 15/Feb/15 ] |
|
YANG (RFC6020) does not define logic how to determine type of union, Classes present in src/main/java are intended for user to customize There is opened enhancement issue for In meantime you could fill out implementation of these classes, Marking this as duplicate of |
| Comment by Minna Hu [ 17/Feb/15 ] |
|
Tony, thank you for your reply! This is quite interesting design. I noticed that in src/main/java, those generated classes are all Builder classes for unions, you also mentioned this. Did you mean that I need to implement getDefaultInstance method? And for most projects, the classes will be generated under src/main/yang-gen-sal, and src/main/java is also a source folder, so you won't expect compilation error, right? |
| Comment by Tony Tkacik [ 17/Feb/15 ] |
|
Yeah, that is true - you need to implement this method. This pattern - which generates stubs in src/main/java is pretty common across code generators for code, which needs to be implemented, but code generator does not This code needs also to be checked in. For models in question (ietf-inet-types@2010-09-24.yang and ietf-netconf-monitoring@2010-10-04.yang) I suggest using ones already present in nexus, |
| Comment by Minna Hu [ 18/Feb/15 ] |
|
Thanks a lot, the jars implemented by YANGTools and COntroller developers will be a good reference for me. I found ietf-inet-types and ietf-netconf-monitoring artifacts in Nexus, they are under <groupId>org.opendaylight.controller</groupId>. However, in yangtools repo, ietf-inet-types are under <groupId>org.opendaylight.yangtools.model</groupId>, do you know why there is difference? Which one shall I use? I didn't find the module for ietf-netconf-monitoring in yangtools repo, is the module stored somewhere else? Please let me know, thank you! Looking forward to your reply! Thanks! |
| Comment by Tony Tkacik [ 18/Feb/15 ] |
|
ietf-inet-types is org.opendaylight.yangtools.model because it is protocol agnostic . ietf-netconf-monitoring is org.opendaylight.controller is in controller (netconf subsystem) because it is directly related to netconf. You could use both (ietf-netconf-monitoring uses ietf-inet-types from yangtools). |