2016-11-22 105 views
4

我想使用一些外部jar依赖项编译测试文件,这些依赖项不会出现在pom.xml的依赖项标记中。有没有办法通过配置。像这个 -如何将其他类路径依赖项传递给maven中的testCompile阶段

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
    <source>1.5</source> 
    <target>1.5</target> 
    </configuration> 
    <executions> 
    <execution> 
     <id>test-compile</id> 
     <configuration> 
     <classPathElements> 
      <classPathElement>somejar.jar</classPathElement> 
     </classPathElements> 
     </configuration> 
    </execution> 

    </executions> 
</plugin> 
+1

只是一个小问题库。您是否需要使用外部JAR编译测试类,或者是否需要使用外部JAR执行测试? –

+0

其实这两个,但为执行我使用maven-surefire-plugin ..其中有选项可以使用标记传递外部瓶子 – Disha

+0

你为什么要尝试这样做? (除了你不能的事实)。 – Tunaki

回答

0

东西试试这个,它包括从项目

<dependency> 
     <groupId>mylib</groupId> 
     <artifactId>com.mylib</artifactId> 
     <version>1.0</version> 
     <scope>system</scope> 
     <systemPath>${project.basedir}/src/main/resources/mylib.jar</systemPath> 
</dependency> 
相关问题