2013-02-28 74 views
0

我想从依赖中获取资源文件并将其放到我的类路径或其他目录中。我尝试了maven-dependency-plugin,但似乎我没有正确配置它。有谁知道该怎么做?如何从相关工件中获取资源文件

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>2.3</version> 
    <executions> 
     <execution> 
     <id>get browsers.xml</id> 
     <goals> 
      <goal>unpack-dependencies</goal> 
     </goals> 
     <phase>generate-resources</phase> 
     <configuration> 
       <includeGroupIds>ru.fad.autotests</includeGroupIds> 
       <includeArtifactIds>selenium-grid-browsers-local</includeArtifactIds> 
       <includes>browsers.xml</includes> 
       <outputDirectory>resources/</outputDirectory> 
     </configuration> 
     </execution> 
     </executions> 
    </plugin> 

我在另一个工件中有'browsers.xml'文件,并且想将其复制到我的目录中。

+0

请分享确切的代码并详细说明您正在尝试做什么。 – 2013-02-28 15:51:25

+0

你能否更具体地说明你的意思是“复制到我的目录?”你的项目结构中的哪个目录?另外,“但似乎我没有正确配置它” - 你能详细说明一下吗?与你想要做什么相比,目前它在做什么(错误?)? – noahlz 2013-02-28 19:47:50

+0

我的文件'browsers.xml'位于从属工件的资源中。我必须将它复制到src/main/resources目录中。我没有收到任何错误。但是这个配置拷贝了meta-pom.xml,除了browsers.xml以外,还有目标目录。我不知道为什么:)如何才能正确地做到这一点? – 2013-03-01 09:41:33

回答

0

有几种不同的方法可以解决这个问题,但我认为最好的解决方案是使用Maven Build Helper,具体为build-helper:add-resource目标。

而不是拆包你的依赖于resources/(这应该是版本控制只文件),开箱取出期望的伪影到target/,即target/my-resources/和参考从构建辅助目录。