java - Maven 通过命令编译插件
问题描述
我有一个 Windows-1254 文件编码的项目,其中一些文件采用 UTF-8 编码。
<properties>
<project.build.sourceEncoding>Windows-1254</project.build.sourceEncoding>
<project.reporting.outputEncoding>Windows-1254</project.reporting.outputEncoding>
<version.plugin.maven.resources>3.1.0</version.plugin.maven.resources>
<functionAppName>az-app-core</functionAppName>
</properties>
我在 pom 中添加了插件并使用mvn compile
.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile1</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>**/StringUtil.java</exclude>
<exclude>**/TurkceInputTag_FaceLift.java</exclude>
<exclude>**/TurkceInputTag.java</exclude>
</excludes>
<encoding>Windows-1254</encoding>
</configuration>
</execution>
<execution>
<id>compile2</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/StringUtil.java</include>
<include>**/TurkceInputTag_FaceLift.java</include>
<include>**/TurkceInputTag.java</include>
</includes>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
</plugin>
但是我不仅需要通过命令编译项目,clean compile
而且还需要将所有配置(上面定义的 compile1、compile2 执行)提供给 maven,例如
maven compile-plugin :compile -Dexecutions/execution1/id=compile1,encoding=Windows-1254,excludes=....
我无法将文件类型编码更改为仅 UTF-8 或 Windows-1254 编码。我需要使用两种编码来编译项目。
maven 插件如何通过配置、编码、执行等命令编译?
解决方案
我第二个khmarbaise。
一个项目中的所有源代码文件都需要具有相同的编码。选择一个并转换其他源代码文件。
编辑:
您提到您无法转换文件,但不幸的是,您没有告诉我们原因。
无论什么阻碍你这样做,你都需要解决这个问题。
因此,如果您的同事、经理或客户告诉您不要更改编码,那么您需要通过与这些人交谈来解决这个问题,向他们解释 Maven 项目需要有一个(并且只有一个)源代码编码并说服他们改变它。
如果我误解了你,请随时评论我的回答。
推荐阅读
- reactjs - React Material-Table 如何传递 rowData 参数?
- javascript - 麦克风访问 Microsoft Edge
- arangodb - 如何在 ArangoDB 中的对象数组中过滤和排序对象数组
- c# - 如何在 ListView.SelectionChanged 上获取 SelectedItem 的父项
- c++ - 将 doxygen 转换为乳胶到 pdf 的问题
- android - 如何将 Azure DevOps 管道上的 .properties 文件设置为某种环境变量?
- sql - 如何返回嵌套的 JSON 数组
- angular - 在星云寄存器组件中添加自定义字段
- sas - SAS中的朴素贝叶斯分类器
- javascript - 使用 Highcharts 映射 json 数据的问题