【发布时间】:2020-05-29 13:40:38
【问题描述】:
如何使用 OpenDaylight Yangtools maven 插件从 yang-version 1.1 模块生成 Java 代码?
我有一个 yang-version 1.1 模型(第一部分如下所示)
module o-ran-sc-my-desc-v1 {
yang-version 1.1;
namespace "urn:o-ran:my-desc:1.0";
prefix rxad;
organization
"O-RAN Software Community";
contact
"www.o-ran.org";
我从 YANG 工具指南 https://wiki.opendaylight.org/view/YANG_Tools:User_Guide 开始构建 POM 文件并生成代码。那有旧版本和无效的代码生成器类名。我升级到插件版本 4.0.1,代码生成器版本 3.0.9,两者都是 Maven 中心的最新版本,并弄清楚了代码生成器类的名称。终于在 Maven 中得到了一些东西,但现在我得到了这个代码生成器错误:
[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:4.0.1:generate-sources (default) on project o1-netconf-client:
Execution default of goal org.opendaylight.yangtools:yang-maven-plugin:4.0.1:generate-sources failed: An API incompatibility was
encountered while executing org.opendaylight.yangtools:yang-maven-plugin:4.0.1:generate-sources: java.lang.NoSuchMethodError:
org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils.getAllTypeDefinitions(Lorg/opendaylight/yangtools/yang/model/api/DataNodeContainer;)Ljava/util/Collection;
为了完整起见,下面发布了 POM 的相关部分。
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<goals>
<goal>generate-sources</goal>
</goals>
<configuration>
<!-- directory containing yang files to parse and generate code -->
<yangFilesRootDir>my/agent/yang</yangFilesRootDir>
<codeGenerators>
<generator>
<codeGeneratorClass>
org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl
</codeGeneratorClass>
<!-- directory into which generated files will be placed -->
<outputBaseDir>
target/generated-sources/sal
</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.mdsal</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
<version>3.0.9</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
是否有可能我使用了不兼容的版本?
【问题讨论】:
标签: opendaylight ietf-netmod-yang