2014-04-22 62 views
0

我正在使用maven-jar-plugin生成源jar。僅將文件夾的內容附加到罐子上

我有以下文件夾結構:

folder/foo/baz/A.java 
folder/bar/baz/B.java 

我想要的來源罐子包含以下內容:

baz/A.java 
baz/B.java 

我使用了以下配置:

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>2.4</version> 
     <executions> 
      <execution> 
       <phase>generate-resources</phase> 
       <goals> 
        <goal>jar</goal> 
       </goals> 
       <configuration> 
        <classesDirectory>folder</classesDirectory> 
        <includes> 
         <include>foo/**</include> 
         <include>bar/**</include> 
        </includes> 
        <finalName>sources</finalName> 
       </configuration> 
      </execution> 
     </executions> 
</plugin> 

但這創建了這樣的罐子:

folder/foo/baz/A.java 
folder/bar/baz/B.java 

我該如何修改代碼才能在jar中獲得我想要的結構?

回答

0

我無法與maven-jar-plugin解決這個問題,我不得不使用maven-resources-plugin,太:

<plugin> 
    <artifactId>maven-resources-plugin</artifactId> 
    <version>2.4.3</version> 
    <executions> 
     <execution> 
      <phase>generate-resources</phase> 
      <goals> 
       <goal>copy-resources</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.build.directory}/sources/</outputDirectory> 
       <resources> 
        <resource> 
         <directory>folder/foo/</directory> 
        </resource> 
        <resource> 
         <directory>folder/bar/</directory> 
        </resource> 
       </resources> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>2.4</version> 
    <executions> 
     <execution> 
      <phase>generate-resources</phase> 
      <goals> 
       <goal>jar</goal> 
      </goals> 
      <configuration> 
       <classesDirectory>${project.build.directory}/sources</classesDirectory> 
       <includes> 
        <include>**/*</include> 
       </includes> 
       <finalName>sources</finalName> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
相關問題