Maven corrupting binary files in src/main/resources when building jar

This part:

                <resources>
                    <resource>
                        <directory>${basedir}/src/main/resources/lib</directory>
                        <filtering>false</filtering>
                    </resource>
                </resources>

Should be under under the <build/> section like this:

 <project>
      <build>
          <resources>
              <resource>
                  <directory>${basedir}/src/main/resources/lib</directory>
                  <filtering>false</filtering>
              </resource>
          </resources>
          <plugins>
              ...
          </plugins>
      </build>
 </project>

When assembly plugin kicks in it is already too late, as the resources were already copied by maven resources plugin. You should exclude filtering on earlier phase (when the resources are being copied to target folder by maven resource plugin).

See maven's docs how to do this: https://maven.apache.org/plugins/maven-resources-plugin/examples/binaries-filtering.html

For your case this can be something like:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
                <nonFilteredFileExtensions>
                    <nonFilteredFileExtension>dll</nonFilteredFileExtension>
                </nonFilteredFileExtensions>
            </configuration>
        </plugin>
    </plugins>

Tags:

Java

Maven

Dll