如何使用 maven-resources-plugin 避免二进制文件的 UTF-8 编码?
我正在使用 maven-resources-plugin 从我的项目中复制一些资源,但我的资源之一是二进制文件。输出显示它是Using 'UTF-8'编码复制过滤的资源
这是我的问题!
这是我的插件配置。
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/autopublisher</outputDirectory>
<resources>
<resource>
<directory>src/autopublisher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
我可以跳过二进制文件的 UTF-8 转换吗?
谢谢。
I'm using the maven-resources-plugin to copy some resources from my project but one of my resources is a binary file. The output says it is Using 'UTF-8' encoding to copy filtered resources
which I my problem!!!
Here is my plugin configuration.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/autopublisher</outputDirectory>
<resources>
<resource>
<directory>src/autopublisher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Can I skip the UTF-8 conversion for binaries?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了解决我的问题,我将其添加到我的配置中 maven 二进制过滤 :
Well to solve my problem I added this to my configuration maven binary filtering:
设置两个单独的
元素,一个使用false
,另一个使用true ;
。使用
的
和
元素通过扩展名从其中之一排除二进制文件。然而,资源插件在默认情况下排除图像等方面变得越来越智能,因此请确保使用最新版本。
Set up two separate
<resource>
elements, one with<filtering>false</filtering>
and the other with<filtering>true</filtering>
. Use the<includes>
and<excludes>
elements of<resource>
to exclude your binary files by extension from one of them.The resources plugin is however getting smarter about excluding e.g. images by default, so make sure you use the latest version.
我遇到过类似的情况,插件无意中处理了二进制文件(txt 和二进制数据的混合),使其最终无法使用。
为了解决这个问题,我只需对要过滤的文件类型进行更明确的过滤,并保持所有其他文件不变,请参见下文:
I came across similar situation where a binary file (well a mix of txt and binary data) was inadvertently processed by the plugin, making it unusable at the end.
To solve this, I just had to make filtering a bit more explicit as to which types of file to filter and keeping all others, untouched, see below:
对于没有扩展名的已编译二进制文件(它在 RHEL 构建服务器上启动以进行某些组件测试),为它打算运行的 Linux 版本添加了文件扩展名,并使用上面的 code-gijoe 答案来确保 maven 不会“过滤”它:
For a compiled binary that had no extension (it gets launched on the RHEL build server for some component tests), added a file extension for the Linux version it was intended to run under and used code-gijoe's answer above to ensure that maven did not "filter" it: