在运行时期间不存在Maven传递依赖项

时间:2014-07-24 09:47:14

标签: maven

我有一个使用Maven构建的Netbeans RCP项目但是在构建其中一个模块时我的构建失败并出现以下错误行:

--- nbm-maven-plugin:3.13:manifest (default-manifest) @ FNApi ---
NBM Plugin generates manifest
Project uses classes from transitive module org.netbeans.api:org-openide-util:jar:RELEASE80 which will not be accessible at runtime.
    To fix the problem, add this module as direct dependency. For OSGi bundles that are supposed to be wrapped in NetBeans modules, use the useOSGiDependencies=false parameter
Project uses classes from transitive module org.netbeans.api:org-openide-util-lookup:jar:RELEASE80 which will not be accessible at runtime.
    To fix the problem, add this module as direct dependency. For OSGi bundles that are supposed to be wrapped in NetBeans modules, use the useOSGiDependencies=false parameter

你能说一下可以做些什么吗?我尝试使用org.netbeans.api:org-openide-util-lookup添加dependencies > add,但无法完成(看起来依赖已经存在)。

这是Netbeans的完整堆栈跟踪:

--- nbm-maven-plugin:3.13:manifest (default-manifest) @ FNApi ---
NBM Plugin generates manifest
Project uses classes from transitive module org.netbeans.api:org-openide-util:jar:RELEASE80 which will not be accessible at runtime.
    To fix the problem, add this module as direct dependency. For OSGi bundles that are supposed to be wrapped in NetBeans modules, use the useOSGiDependencies=false parameter
Project uses classes from transitive module org.netbeans.api:org-openide-util-lookup:jar:RELEASE80 which will not be accessible at runtime.
    To fix the problem, add this module as direct dependency. For OSGi bundles that are supposed to be wrapped in NetBeans modules, use the useOSGiDependencies=false parameter
------------------------------------------------------------------------
Reactor Summary:

FNSD-maven-parent ................................. SUCCESS [0.563s]
FNSD-maven-branding ............................... SUCCESS [1.695s]
FNSD-maven-app .................................... SUCCESS [14.645s]
WidgetAPI ......................................... SUCCESS [2.468s]
FNApi ............................................. FAILURE [1.304s]
Browser ........................................... SKIPPED
FlamingoIntegration ............................... SKIPPED
FNCore ............................................ SKIPPED
NetDesigner ....................................... SKIPPED
DST ............................................... SKIPPED
Production ........................................ SKIPPED
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 21.553s
Finished at: Thu Jul 24 11:33:20 CEST 2014
Final Memory: 20M/247M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:3.13:manifest (default-manifest) on project FNApi: See above for failures in runtime NetBeans dependencies verification. -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

感谢任何帮助。我是Maven的新手。在构建之前,项目本身看起来很好(没有错误)。

2 个答案:

答案 0 :(得分:7)

好的,我终于明白了。我将离开这里,也许它将来会帮助某人......

http://wiki.netbeans.org/Maven_NBM_comments

  

maven编译依赖树和之间存在不一致   运行时netbeans依赖。

所以基本上,你必须手动将与org.netbeans.api相关的所有依赖项添加到pom.xml,然后它才能开始工作。引用的文章声称这种不一致可能在Maven 3中得到解决,但遗憾的是,它并非如此。

答案 1 :(得分:0)

就我而言,Netbeans 构建器给了我以下错误:

项目使用传递模块 org.gephi:io-importer-api 中的类,这些类在运行时无法访问。

要解决此问题,请将此模块添加为直接依赖项。对于应该包装在 NetBeans 模块中的 OSGi 包,请使用 useOSGiDependencies=false 参数

我最终通过将依赖项直接包含在我的 pom.xml 中解决了这个问题。是这样的:

<dependencies>
    <dependency>
        <groupId>org.gephi</groupId>
        <artifactId>io-importer-api</artifactId>
        <version>0.9.2</version>
    </dependency>
</dependencies>

版本由您决定。这取决于您使用的依赖项的版本...