2015-02-04 3 views
3

Привет, хочу, чтобы некоторые файлы, которые находятся внутри jar, копировались в корневую папку моего проекта java.Не воспроизводить путь во время maven-dependency-plugin unpack goal

Я использовал это:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>unpack</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>unpack</goal> 
        </goals> 
        <configuration> 
         <artifactItems> 
          <artifactItem> 
          <groupId>net.sourceforge.tess4j</groupId> 
          <artifactId>tess4j</artifactId> 
          <version>1.4.1</version> 
          <type>jar</type> 
          <includes>win32-x86/*.dll</includes> 
          <overWrite>true</overWrite> 
          <outputDirectory>${basedir}</outputDirectory> <!-- project root directory --> 
         </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

проблема, я получаю это

javaProject 
    src 
    target 
    win32-x86/dll1.dll 
    win32-x86/dll2.dll 

Я хочу, чтобы это

javaProject 
    src 
    target 
    dll1.dll 
    dll2.dll 

Я не хочу, чтобы путь к папке с внутри jar, который нужно воспроизвести, я просто хочу, чтобы файлы были сброшены в корень моего проекта.

Любые идеи?

Спасибо.

ответ

2

Вы можете использовать Jetspeed распакуйте Maven плагин: http://pulkitsinghal.blogspot.be/2011/04/jetspeed-finally-unpack-plugin-with.html

http://portals.apache.org/jetspeed-2/buildguide/jetspeed-unpack-plugin.html См для документации.

Опция вы хотите:

<flat>true</flat> 

Полный пример:

<plugin> 
    <groupId>org.apache.portals.jetspeed-2</groupId> 
    <artifactId>jetspeed-unpack-maven-plugin</artifactId> 
    <version>${org.apache.portals.jetspeed.version}</version> 
    <configuration> 

    <unpack> 
     <artifact>...</artifact> 
     <file>...</file> 
     <targetDirectory>...</targetDirectory> 
     <overwrite>...</overwrite>    
     <resources combine.children="append"> 

     <resource> 
      <path>...</path> 
      <destination>...</destination> 
      <overwrite>...</overwrite> 
      <flat>...</flat> 
      <include>...</include> 
      <exclude>...</exclude> 
      <name>...</name> 
     </resource> 
     ... 
     </resources> 
    </unpack> 

    <skip>...</skip> 
    <verbose>...</verbose> 

    </configuration> 
</plugin> 
+0

perfect thanks: D – Eildosa

+3

20 строк XML, где я мог бы сделать это с помощью двух строк сценария bash :( И даже не мог заставить его работать :( Я ненавижу maven. –

0

Вы можете использовать

 <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <phase>test-compile</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <tasks> 
        <move todir="${libPath}"> 
         <fileset dir="${libPath}"/> 
         <mapper type="flatten"/> 
        </move> 
       </tasks> 
      </configuration> 
     </plugin> 

, чтобы сгладить результат потом.