How to insert a maven property which is an XML node?

163 views Asked by At

I need to add a maven profile that when activates, insert some rules to maven-shade-plugin relocation section, so I add a property in a profile:

  <properties>
    <cdh.hive.relocation>
      <relocation>
        <pattern>org.apache.hive</pattern>
        <shadedPattern>org.my_project.apache.hive</shadedPattern>
      </relocation>
    </cdh.hive.relocation>
  </properties>

And inject it in the plugin config, using ${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>

But maven gave the following error:

[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

Why it doesn't work? What should I do to make it work?

1

There are 1 answers

0
Luigi Polvani On BEST ANSWER

I don't think you can, you should instead use profiles