Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do not reproduce path during maven-dependency-plugin unpack goal

Hi want some files that are inside a jar copied to the root folder of my java project.

I used this :

<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>

problem is I get this

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

I want to get this

javaProject
    src
    target
    dll1.dll
    dll2.dll

I don't want the folder path from inside the jar to be reproduced, I just want the files dumped in my project's root.

Any ideas?

Thanks.

like image 302
Heetola Avatar asked Jan 24 '26 20:01

Heetola


1 Answers

You can use the Jetspeed unpack maven plugin: http://pulkitsinghal.blogspot.be/2011/04/jetspeed-finally-unpack-plugin-with.html

See http://portals.apache.org/jetspeed-2/buildguide/jetspeed-unpack-plugin.html for documentation.

The option you want is :

<flat>true</flat>

Full example:

<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>
like image 184
Wim Deblauwe Avatar answered Jan 26 '26 14:01

Wim Deblauwe