2

I want to copy files from within a jar to a specific directory without preserving the path in the jar.

I can use unjar to find just the files I want from the jar OK:

<unjar dest="some_dest_path" overwrite="true" src="somejar.jar">
    <patternset>
        <include name="somepath_in_jar/somefile.ext" />
    </patternset>
</unjar>

but the somefile gets extracted to:

some_dest_path/somepath_in_jar/somefile.ext

when I want the file to get extracted to:

some_dest_path/somefile.ext

ie without dragging the path it was packaged with along with the process

How can I extract a file from a jar without having the extracted file include the path it was packaged with?

Bohemian
  • 412,405
  • 93
  • 575
  • 722

1 Answers1

3

Try to use a mapper

<unjar dest="some_dest_path" overwrite="true" src="somejar.jar">
  <patternset>
    <include name="somepath_in_jar/somefile.ext" />
  </patternset>
  <mapper type="flatten"/>
</unjar>

see ant mapper

Hank Lapidez
  • 1,857
  • 18
  • 23