1

I am trying to use OpenDaylight to generate Pojos from Yang files according to this guide. I cloned Yangtools from OpenDaylight github and built the project with mvn clean install

i've added the following to my pom:

<plugin>
           <groupId>org.opendaylight.yangtools</groupId>
           <artifactId>yang-maven-plugin</artifactId>
           <version>2.0.8-SNAPSHOT</version>
           <executions>
               <execution>
                   <goals>
                       <goal>generate-sources</goal>
                   </goals>
                   <configuration>
                       <!-- directory containing yang files to parse and generate code -->
                       <yangFilesRootDir>src/main/yang</yangFilesRootDir>
                       <codeGenerators>
                           <generator>
                               <codeGeneratorClass>
                                   org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
                               </codeGeneratorClass>
                               <!-- directory into which generated files will be placed -->
                               <outputBaseDir>
                                   target/generated-sources
                               </outputBaseDir>
                           </generator>
                       </codeGenerators>
                       <!-- if true, plugin will search for yang files also in dependent projects -->
                       <inspectDependencies>true</inspectDependencies>
                   </configuration>
               </execution>
           </executions>
           <dependencies>
               <dependency>
                   <groupId>org.opendaylight.yangtools</groupId>
                   <artifactId>maven-sal-api-gen-plugin</artifactId>
                   <version>0.7.4-Lithium-SR4</version>
                   <type>jar</type>
               </dependency>
           </dependencies>
       </plugin>

however i am unable to generate the sources. I am getting the following error:

[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources (default) on project odl-poc: Execution default of goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources failed: An API incompatibility was encountered while executing org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources: java.lang.AbstractMethodError: Method org/opendaylight/yangtools/maven/sal/api/gen/plugin/CodeGeneratorImpl.generateSources(Lorg/opendaylight/yangtools/yang/model/api/SchemaContext;Ljava/io/File;Ljava/util/Set;Ljava/util/function/Function;)Ljava/util/Collection; is abstract

what am i doing wrong?

Alex Stoliar
  • 305
  • 3
  • 8

1 Answers1

3

Looks like a version incompatibility - you're referencing yang-maven-plugin version 2.0.8-SNAPSHOT, which is the current unreleased master branch, and dependency maven-sal-api-gen-plugin version 0.7.4-Lithium-SR4, which was like 5 major releases ago and long obsolete.

Tom Pantelis
  • 1,349
  • 1
  • 7
  • 6
  • 1
    which versions of yang-maven-plugin and maven-sal-api-gen-plugin(and what are the matching releases for those versions) should i use? – Alex Stoliar Jul 17 '18 at 11:25
  • 2.0.8 was released recently, you might as well use that. If you’re using other OpenDaylight components, you should choose the matching version; that will be 2.0.7 for Fluorine (the release currently in development), 2.0.5 for Oxygen. – Stephen Kitt Jul 17 '18 at 12:21
  • 1
    maven-sal-api-gen-plugin is in the mdsal project - latest master version is 0.13.0-SNAPSHOT. However I would suggest deriving your pom from org.opendaylight.mdsal/binding-parent which provides the yang-maven-plugin definition et al for free. – Tom Pantelis Jul 17 '18 at 14:29
  • I thinks the version issues are now solved. i tried both deriving my pom from binding-parent as suggested and using yang-maven-plugin and i am now getting the following error:[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:2.0.7:generate-sources (default) on project odl-yang-generator-poc: Execution default of goal org.opendaylight.yangtools:yang-maven-plugin:2.0.7:generate-sources failed: codeGeneratorClass for CodeGenerator cannot be null. – Alex Stoliar Jul 18 '18 at 08:38