Maven 2 & 3

Spaces if properties are not preserved if using CDATA

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Trivial Trivial
  • Resolution: Unresolved
  • Affects Version/s: 2.0.9
  • Fix Version/s: 3.x / Backlog
  • Component/s: None
  • Labels:
    None
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

Using a property like this one:

<properties>
<cdata><![CDATA[ ]]></cdata>
</properties>

results into an empty property (see effective-pom):

<properties>
<cdata/>
</properties>

which is wrong.
See also the XML spec:

"Note that a CDATA section containing only white space or a reference to an entity whose replacement text is character references expanding to white space do not match the nonterminal S"

which also stats that white spaces inside CDATA must not be trimmed away.

Activity

Hide
Brett Porter added a comment -

do you have a use case for this?

The property is recorded properly, however it is trimmed (as a property, not xml content). However, it works if there is something either side, or other cdata content.

As for the effective POM, the resulting POM is stripped of all directives, not as a way to preserve the original representation.

Show
Brett Porter added a comment - do you have a use case for this? The property is recorded properly, however it is trimmed (as a property, not xml content). However, it works if there is something either side, or other cdata content. As for the effective POM, the resulting POM is stripped of all directives, not as a way to preserve the original representation.
Hide
Stefan Franke added a comment -

one use case is this

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<additionalConfig>
<file>
<name>.checkstyle</name>
<url>file://path/to/file</url>
<content>${varies}</content>
</file>
</additionalConfig>
</configuration>

if ${varies} is unset, the url is used.
if ${varies} is set its content is used.
But creating an empty file does not work.

Show
Stefan Franke added a comment - one use case is this <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <additionalConfig> <file> <name>.checkstyle</name> <url>file://path/to/file</url> <content>${varies}</content> </file> </additionalConfig> </configuration> if ${varies} is unset, the url is used. if ${varies} is set its content is used. But creating an empty file does not work.
Hide
Brett Porter added a comment -

a very minor issue, but we should be trimming the xml source by its rules and not the properties in the model

Show
Brett Porter added a comment - a very minor issue, but we should be trimming the xml source by its rules and not the properties in the model

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: