2012-12-17 88 views
1

我试图使用Maven和NAR插件来构建和测试DLL。我正在构建的DLL依赖于另一个DLL,我也使用NAR插件构建了这个DLL。这里是我的POM:Maven NAR插件:找不到路径上的DLL依赖关系

<project> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.mycompany</groupId> 
    <artifactId>myproject</artifactId> 
    <packaging>nar</packaging> 

    <name>My Project</name> 
    <version>1.0.0-SNAPSHOT</version> 

    <properties> 
    <skipTests>true</skipTests> 
    </properties> 

    <build> 
    <defaultGoal>install</defaultGoal> 
    <plugins> 
     <plugin> 
     <groupId>org.codeswarm</groupId> 
     <artifactId>maven-nar-plugin</artifactId> 
     <version>20121119</version> 
     <extensions>true</extensions> 
     <configuration> 
      <cpp> 
      <defines> 
       <define>DLLEXPORT</define> 
      </defines> 
      </cpp> 

      <libraries> 
      <library> 
       <type>shared</type> 
      </library> 
      </libraries> 

      <tests> 
      <test> 
       <name>ProjectTest</name> 
       <link>shared</link> 
      </test> 
      </tests> 
     </configuration> 

     </plugin> 
    </plugins> 
    </build> 

    <dependencies> 
    <dependency> 
     <groupId>com.mycompany</groupId> 
     <artifactId>shared-library</artifactId> 
     <version>1.0.0-SNAPSHOT</version> 
     <type>nar</type> 
     <scope>runtime</scope> 
    </dependency> 
    </dependencies> 

</project> 

如果我删除依赖于com.mycompany:shared-library - 也移除要调用到它的代码 - 那么它工作正常。 ProjectTest正常运行,并做它应该的。但是由于存在依赖关系,maven无法运行测试,因为它找不到shared-library。它崩溃与错误0xc0000135

当我在调试模式下运行Maven时,我可以看到当它编译测试时,它正确地将两个DLL头文件的include路径添加到编译器命令中。当它链接测试时,它将两个DLL的导出库正确添加到链接器命令。 Maven执行测试时出现问题:Maven希望将DLL的路径添加到系统路径,并且它执行此操作 - 但它仅将路径添加到myproject DLL。它不会将路径添加到shared-library DLL。因此,崩溃。

这是maven-nar-plugin中的一个已知问题吗?我也听说它暗示了NAR插件的一些分支在浮动;这个问题是否可以在我使用的插件以外的某个版本中解决?或者是否有一些可以推荐的解决方法?

+0

没进'行家-NAR-plugin'的源极和试图改变依赖范围'compile',基于'NarTestMojo.java:156'。仍然没有工作。 – micro314

回答