2013-01-09 86 views
5

我想使用maven将脚本文件作为打包测试文件的一部分。余马使用下面的插件配置然而配置和Jython文件的文件不会在测试罐使用maven jar插件将非Java文件和资源文件包含到测试jar中

  <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.2</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>test-jar</goal> 
        </goals> 
        <configuration> 
         <includes> 
          <include>**/config/*</include> 
          <include>**/jython/*</include> 
         </includes> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 

包是反正有包括不是在SRC /测试/ java和SRC /测试/资源中的文件在测试jar?

回答

7

使用指定其他测试资源文件夹:

<build> 
    <testResources> 
     <testResource> 
      <directory>src/test</directory> 
      <includes> 
       <include>**/config/*</include> 
       <include>**/jython/*</include> 
      </includes> 
     </testResource> 
    </testResources> 
</build> 

您应该然后发现没有配置是必需的Maven的罐子的插件。

也可以使用build-helper-maven-plugin。请参阅:Maven - Add directory to classpath while executing tests

+2

很好的答案。我唯一想补充的是:应该是src/test /(不是前导/),而不是/它将扫描整个硬盘。 –

+0

@ChristopherYang谢谢 - 我已经更新了我的答案 –

相关问题