Search code examples
mavenpngmaven-3maven-assembly-pluginico

maven-assembly-plugin png and ico broken


I´m using maven-assembly-plugin for creating a zip file containing some artifacts and additional stuff. The additional stuff is located at a folder called "Installationattachments". Everything working alright so far. "Installationattachments" also contains a png and an ico file which are also included but these are broken after they´re included. Here is the plugin declaration of my pom.xml:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <appendAssemblyId>false</appendAssemblyId>
        <descriptors>
            <descriptor>src/assembly/dep.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>create-archive</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
    <inherited>false</inherited>
</plugin>

And that´s the critical part of the assembly itself:

<!-- installation files -->
<fileSet>
    <directory>Installationattachments</directory>
    <outputDirectory></outputDirectory>
    <lineEnding>unix</lineEnding>
    <excludes>
        <exclude>*.vbs</exclude>
    </excludes>
</fileSet>
<fileSet>
    <directory>Installationattachments</directory>
    <outputDirectory></outputDirectory>
    <lineEnding>dos</lineEnding>
    <includes>
        <include>*.vbs</include>
    </includes>
</fileSet>

Solution

  • The problem is the specification of line endings through the <lineEnding> parameter. The first fileset selects all files that aren't VBS file, so it also selects PNG and ICO files. But since those are binary files, you don't want to set a specific line ending for those.

    For lack of a nonFilteredFileExtensions, whose support is asked in MASSEMBLY-849, you can add a third filesets without line ending for images:

    <fileSet>
      <directory>Installationattachments</directory>
      <outputDirectory></outputDirectory>
      <lineEnding>unix</lineEnding>
      <excludes>
        <exclude>*.vbs</exclude>
        <exclude>*.ico</exclude>
        <exclude>*.png</exclude>
      </excludes>
    </fileSet>
    <fileSet>
      <directory>Installationattachments</directory>
      <outputDirectory></outputDirectory>
      <includes>
        <include>*.ico</include>
        <include>*.png</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>Installationattachments</directory>
      <outputDirectory></outputDirectory>
      <lineEnding>dos</lineEnding>
      <includes>
        <include>*.vbs</include>
      </includes>
    </fileSet>