2

We have an artifact that's a third party zip file we want to unpack and include the unpacked structure in our own assembly.

The problem is that the top level directory of the unzipped zip file is an ugly directory name with a bunch of version information included in it. In our final assembly, we want to just have that unpacked structure live under a single, simple directory name.

We want either the unpack to "skip" the top level dir, or we want the assembly to be able to specify the top directory of the fileset by wildcard, or we need a build step (antrun plugin?) to rename that top level directory - again, by wildcard - into something consistent.

Googling around suggests that adding a to the of type regexp would allow me to rewrite the filename, but apparently the maven assembly plugin doesn't support that (naturally).

nsayer
  • 16,925
  • 3
  • 33
  • 51

1 Answers1

1

I figured it out.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.8</version>
  <executions>
    <execution>
      <id>copy</id>
      <phase>package</phase>
      <configuration>
        <tasks>
          <copy todir="${project.build.directory}/dependency/simple_name">
            <fileset dir="${project.build.directory}/dependency"/>
            <regexpmapper from="^prefix[^/]*/(.*)$$" to="\1"/>
          </copy>
        </tasks>
      </configuration>
      <goals><goal>run</goal></goals>
    </execution>
  </executions>
</plugin>

That copies the unpacked content from the complex directory into a simple one. It's a little wasteful, as it leaves the complex structure behind, but I don't care.

nsayer
  • 16,925
  • 3
  • 33
  • 51