Linux 如何让maven构建平台独立?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10335815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make maven build platform independent?
提问by James Raitsev
When building using Maven on my mac, on mvn install
i get
在我的 Mac 上使用 Maven 构建时,mvn install
我得到
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[警告] 使用平台编码(实际上是 MacRoman)复制过滤的资源,即构建依赖于平台!
Is it possible to either build for a given platform (Linux) or otherwise make build platform independent?
是否可以为给定平台(Linux)构建或以其他方式使构建平台独立?
采纳答案by Kalpak Gadre
It happens when you have not provided following in your pom.xml
当您没有在 pom.xml 中提供以下内容时会发生这种情况
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Absence of this means you are using platform specific encoding and that's why the warning.
没有这意味着您正在使用特定于平台的编码,这就是警告的原因。
回答by Mike
And if @Kal's answer doesn't work for you, perhaps you can learn from my last 30 minutes... below link adds an additional line to the above answer and solved my problem. My problem was related to the maven-resources-plugin 2.6, but the provider of the following solution had a different problem it solved... https://stackoverflow.com/a/3018152/2485075
如果@Kal 的答案对您不起作用,也许您可以从我的最后 30 分钟中学习...下面的链接为上述答案添加了一行并解决了我的问题。我的问题与 maven-resources-plugin 2.6 有关,但以下解决方案的提供者解决了不同的问题... https://stackoverflow.com/a/3018152/2485075
回答by Henrik Damkjaer Vind
For specific needs:
对于特定需求:
<!-- https://maven.apache.org/plugins/maven-resources-plugin/index.html -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
If the plugin is already configured one should merely add
如果插件已经配置,只需添加
<encoding>UTF-8</encoding>