Reputation: 1955
I would like to tell to Eclipse to do not format pom.xml
property(ies).
In my example, I append a long proxyString argument to maven release plugin:
</build>
</plugins>
(...)
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<!-- in case of error while release prepare or dryRun release :
check proxyString should be on one line (withour CR) -->
<configuration>
<arguments>${proxyString}</arguments>
</configuration>
</plugin>
</plugins>
</build>
When I reformat the pom.xml
, Eclipse append some Carriage Returns to that definition :
<profile>
<id>proxy</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<proxyString>-Djava.net.useSystemProxies=true -Dhttp.proxyHost=myProxy -Dhttp.proxyPort=3128 -Dhttps.proxyHost=myProxy -Dhttps.proxyPort=3128</proxyString>
</properties>
</profile>
This result in a break into the release lifecycle:
No goals have been specified for this build. You must specify a valid lifecycle phase
Does exist a way to tell Eclipse to not format a portion of a pom.xml ? (or maybe there is a better way to forward proxy settings to maven release plugin).
I know this question is really close to mine, but I didn't found how to apply it to xml file.
Upvotes: 2
Views: 1185
Reputation: 63
I used a CDATA section enclosing the text I wanted to keep as is (prevent formatting). For example:
<additionalJvmArgs><![CDATA[-Djavax.net.debug=none -Djavax.net.ssl.trustStore=${project.basedir}/../certs/my.truststore -Djavax.net.ssl.trustStorePassword=XXXXX]]></additionalJvmArgs>
Then under Window -> Preferences -> XML -> XML Files -> Editor
I selected the Preserve whitespace in tags with PCDATA content.
This worked for me.
Upvotes: 1
Reputation: 6071
You can select part of the pom which you want to format and press
CTRL + SHIFT + F
When you press 'CTRL + SHIFT + F' without selection it will format entire file.
With selection will format only selected part.
Upvotes: 2
Reputation: 20618
Unfortunately there seems to be no way to disable the XML formatter for some part of the code (as it is possible with Java code).
You can - however - increase the maximum length of lines that the XML formatter adheres to:
Window -> Preferences -> XML Files -> Editor
Set the "Line width" to whatever value you want. I have set mine to "999". Now it does not break lines that are too long. But of course now I have myself to make those lines short enough so that it keeps being readable.
Upvotes: 1