我正在开发一个涉及maven,java和clojure的项目.我面临的问题是,我UTF-8在我的clojure源文件中有一些字符,因为我的源代码没有被java编译器正确解释,我有点通过设置环境变量来工作JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8,但我想要的是通过MAVEN传递此属性.
我已经尝试过设置,MAVEN_OPTS=-Dfile.encoding但这似乎不起作用.
我也试过为maven的编译器插件设置配置......这样的事情:
<configuration>
<compilerArgument>-Dfile.encoding=UTF8</compilerArgument>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这也不起作用.
我是在做错事,还是有别的办法.
谢谢,
RD
好的,这里有一些更详细的信息.这是我的父母pom,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding> <! also tried <encoding>UTF8</encoding>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
孩子的pom没有什么有趣的事,除了...
<resources>
<resource>
<directory>src/main/clojure</directory>
</resource>
</resources>
Run Code Online (Sandbox Code Playgroud)
;; clojure代码片段会导致问题
(let [char "?"]
(not (empty? (filter #(s/contains? % char) <some-list>)))
;; The list is always empty because I never find a match if I do not set the env. variable
Run Code Online (Sandbox Code Playgroud) 我不想依赖外部环境变量来强制maven使用UTF-8构建我的类.在Mac上,我在使用maven构建时遇到了各种各样的问题.只有下面的选项才能解决问题:
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
mvn clean install
Run Code Online (Sandbox Code Playgroud)
但是,我正在分发我的项目,依靠用户设置此环境变量来正确构建项目是没有意义的.
尝试了这里描述的所有内容:为clojure源文件启用UTF-8编码
任何人都对这个令人敬畏的Maven问题有所了解?