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

前端 未结 2 1081
悲哀的现实
悲哀的现实 2020-12-10 17:41

I\'ve got an issue with a maven project where I am distributing dlls from the src/main/resources/lib folder.

The project is built as a single jar with dependencies

相关标签:
2条回答
  • 2020-12-10 18:22

    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>
    
    0 讨论(0)
  • 2020-12-10 18:32

    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>
    
    0 讨论(0)
提交回复
热议问题