如何插入作为 XML 节点的 Maven 属性?
How to insert a maven property which is an XML node?
我需要添加一个 maven 配置文件,当激活时,将一些规则插入到 maven-shade-plugin 重定位部分,所以我在配置文件中添加了一个 属性:
<properties>
<cdh.hive.relocation>
<relocation>
<pattern>org.apache.hive</pattern>
<shadedPattern>org.my_project.apache.hive</shadedPattern>
</relocation>
</cdh.hive.relocation>
</properties>
并使用 ${cdh.hive.relocation}:
将其注入到插件配置中
<relocations>
<relocation>
<pattern>com.mchange.v2.c3p0</pattern>
<shadedPattern>com.my_project.mchange.v2.c3p0</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.http</pattern>
<shadedPattern>org.my_project.apache.http</shadedPattern>
</relocation>
<relocation>
<pattern>org.json4s</pattern>
<shadedPattern>org.my_project.json4s</shadedPattern>
</relocation>
${cdh.hive.relocation}
</relocations>
但是maven报错如下:
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were
encountered while processing the POMs: [FATAL] Non-parseable POM
/home/peng/git-cloudera/5.10.2/datapassport/pom.xml: TEXT must be
immediately followed by END_TAG and not START_TAG (position: START_TAG
seen ...\n ... @137:23) @
line 137, column 23
为什么不起作用?我应该怎么做才能让它发挥作用?
我认为你做不到,你应该改用 profiles
我需要添加一个 maven 配置文件,当激活时,将一些规则插入到 maven-shade-plugin 重定位部分,所以我在配置文件中添加了一个 属性:
<properties>
<cdh.hive.relocation>
<relocation>
<pattern>org.apache.hive</pattern>
<shadedPattern>org.my_project.apache.hive</shadedPattern>
</relocation>
</cdh.hive.relocation>
</properties>
并使用 ${cdh.hive.relocation}:
将其注入到插件配置中 <relocations>
<relocation>
<pattern>com.mchange.v2.c3p0</pattern>
<shadedPattern>com.my_project.mchange.v2.c3p0</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.http</pattern>
<shadedPattern>org.my_project.apache.http</shadedPattern>
</relocation>
<relocation>
<pattern>org.json4s</pattern>
<shadedPattern>org.my_project.json4s</shadedPattern>
</relocation>
${cdh.hive.relocation}
</relocations>
但是maven报错如下:
[ERROR] The build could not read 1 project -> [Help 1] org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [FATAL] Non-parseable POM /home/peng/git-cloudera/5.10.2/datapassport/pom.xml: TEXT must be immediately followed by END_TAG and not START_TAG (position: START_TAG seen ...\n ... @137:23) @ line 137, column 23
为什么不起作用?我应该怎么做才能让它发挥作用?
我认为你做不到,你应该改用 profiles