ARTICLE AD BOX
I'm writing a custom Maven plugin for building a Flatpak from a Java project. In a Maven mojo I understand we use @Parameter annotations to parse pom.xml file configurations. For example:
pom.xml:
<configuration> <param1>VALUE</param1> </configuration>In MyMojo.java:
@Parameter private String param1;But how would I set a value that includes HTML tags? For example:
<configuration> <param1><p>VALUE</p></param1> </configuration>Trying this, I get the error:
Basic element 'param1' must not contain child elements.
So I wrap the <p>VALUE</p> in a CDATA block:
<configuration> <param1><![CDATA[<p>VALUE</p>]]></param1> </configuration>This works up to the point where the MetaInfo object is written to file:
private void writeMetaInfo(MetaInfo metaInfo, Writer writer) throws IOException { XmlMapper mapper = new XmlMapper(); new PrintWriter(writer, true).println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); // metaInfo value is correct before writing - it has <p> not <p> mapper.writerWithDefaultPrettyPrinter().writeValue(writer, metaInfo); }The result is an XML file with: <param1><p>VALUE</p></param1>
...with the leading angle brackets replaced with their entity, <. This doesn't work for the Flatpak MetaInfo file I'm building. It needs the <p> and </p>.
So it seems to be a problem with the XmlMapper.
I found this question which seems to indicate just using the CDATA block should work.
Any ideas?
