Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines aren't kept at beginning or end of String content. #437

Closed
motlin opened this issue Jul 2, 2024 · 4 comments
Closed

Newlines aren't kept at beginning or end of String content. #437

motlin opened this issue Jul 2, 2024 · 4 comments
Labels

Comments

@motlin
Copy link

motlin commented Jul 2, 2024

I'm running the enforcer plugin and have this config in my pom.xml.

                                    <unCheckedPluginList>
                                        org.apache.maven.plugins:maven-site-plugin,
                                        org.apache.maven.plugins:maven-deploy-plugin
                                    </unCheckedPluginList>

After formatting with sortpom, this xml becomes:

                                    <unCheckedPluginList>org.apache.maven.plugins:maven-site-plugin,
                                        org.apache.maven.plugins:maven-deploy-plugin</unCheckedPluginList>

I have <keepBlankLines>true</keepBlankLines> so I was expecting these newlines to be kept.

@Ekryd
Copy link
Owner

Ekryd commented Jul 8, 2024

Hi!
The keepBlankLines option, in SortPom, lets you keep blank lines between two xml elements, e.g.

<name>Green</name>

<description>Salad</description>

Have you tried using xml:space="preserve"? E.g.

<unCheckedPluginList xml:space="preserve">
  org.apache.maven.plugins:maven-site-plugin,
  org.apache.maven.plugins:maven-deploy-plugin
</unCheckedPluginList>

@motlin
Copy link
Author

motlin commented Jul 9, 2024

That works, thanks! Are there no options to control this? I thought some of the options affected the newlines within the string, just not at the front or the end.

@Ekryd
Copy link
Owner

Ekryd commented Jul 14, 2024

xml:space="preserve" is a standard XML directive, and the XML framework that I use supported it, so there was no need to re-invent the wheel 😀.
I don't know if using newlines in XML elements is such a common case. I tend to use separator characters when possible to avoid the problem altogether, e.g ,:;.

@Ekryd
Copy link
Owner

Ekryd commented Jul 14, 2024

Glad that the problem is solved

@motlin motlin closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2024
@Ekryd Ekryd added the question label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants