总的来说,我对 Apache Nifi 和 NAR 还是很陌生。我正在创建一个自定义处理器 NAR 项目,该项目需要从另一个 NAR 文件中存在的 jar 中引用类。我无权访问生成此 NAR 的项目(源代码)。所以我试图将此 NAR 文件作为 maven 依赖项包含在内。这类似于添加外部/本地 jar 作为 maven 依赖项的方式。实现这一目标的正确方法是什么?
注意:我的自定义项目是“nifi-nar-bundles”的子项目,因此它将继承“nar-maven-plugin”
<parent>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-bundles</artifactId>
<version>1.11.4</version>
</parent>
我正在使用 eclipse 及其 maven 插件,并尝试了一些东西:
#1
<dependency>
<groupId>com.group.test</groupId>
<artifactId>test-nar</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<type>nar</type>
<systemPath>C:\test-nar-1.0.0.nar</systemPath>
</dependency>
这不会在eclipse中的“Maven Dependencies”下添加NAR文件。但是,如果我删除 <type>nar</type>
,它会在“Maven Dependencies”下显示 NAR 文件,但不会将其 jar 放在类路径中。
#2
我使用以下命令在本地 maven 存储库中安装了 NAR,并将其打包为“nar”:
mvn install:install-file -Dfile=test-nar-1.0.0.nar -DgroupId=com.group.test -DartifactId=test-nar -Dversion=1.0.0 -Dpackaging=nar
然后将其作为依赖项放在 pom.xml
文件中,如下所示:
<dependency>
<groupId>com.group.test</groupId>
<artifactId>test-nar</artifactId>
<version>1.0.0</version>
<type>nar</type>
</dependency>
这也不会在eclipse中的“Maven Dependencies”下添加NAR文件。
答案 0 :(得分:0)
“nar”类型的 test-nar 依赖项应该包含在你的 NAR 模块中,如果你不能将它的依赖项引入你的代码模块(不是你的 NAR 模块),你可能需要包含 NAR本身在您的代码模块中提供,以便让代码模块进行编译。但是,依赖项将在运行时由父 NAR (test-nar) 提供。