Skip to content

No format for pom.xml in the Maven POM editor #1457

Closed as not planned
Closed as not planned

Description

@foal

Describe the bug
There is no option to format pom.xml in the Maven POM editor.
There is no Source menu with Format option, Ctrl+Shift+F does nothing.
Context menu contains Source -> Format Ctrl+Shift+F , but selection of this command also does nothing.

Spring Tool Suite 4

Version: 4.27.0.RELEASE
Build Id: 202411281622
Revision: a0cb489
A clear and concise description of what the bug is.

To Reproduce

  1. Open pom.xml in Maven POM editor
  2. Use Ctrl+Shift+F to format or select from context menu Source ->Format
  3. XML still unformatted

In the XML editor the same file is formatted without any issues.

Activity

  1. martinlippert commented on Jan 27, 2025

    @martinlippert
    Member

    @foal Thanks for reporting, let's see if we can get to the bottom of this. So far I failed to reproduce this, installing a fresh Spring Tools 4 for Eclipse 4.27.0, starting it with an empty new workspace, creating a Rest Service guide project, opening the pom.xml file in the POM file editor, for Format action shows up in the menu and hitting the corresponding keyboard shortcut (on my macOS machine, it is Cmd-Shift-F) seems to work just fine.

    So we need to figure out what is different on your end that causes the Format action to disappear. Do you have additional plugins installed? If yes, can you try to reproduce this with a fresh Spring Tools for Eclipse installation? Another angle could be to install a plain Eclipse 2024-12 JEE package to see if that works on your machine.

  2. anatoly-spb commented on Feb 4, 2025

    @anatoly-spb

    I confirm the problem. I have did the following:

    1. download fresh Spring Tool Suite 4.27 for Windows x86_64 from https://spring.io/tools:
    Spring Tool Suite 4 
    
    Version: 4.27.0.RELEASE
    Build Id: 202411281622
    Revision: a0cb489d5daf268d32d7327495fe28f3d12212b3
    
    1. create fresh workspace with default options
    2. create maven project with simple project template
    3. unformat pom.xml:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>test</name>
    <description>test</description>
    </project>
    
    1. press Ctrl+Shift+F and source/format and my pom in Maven POM Editor is still unchanged, is still unformatted

    Here is my full configuration https://pastebin.com/QqMBfjBs

  3. foal commented on Feb 5, 2025

    @foal
    Author

    For 4.28 on Windows - the same issue.

    1. Download
    2. Unpack
    3. Run as is without any changes with workspace in new folder
    4. Import Maven project
    5. Try to format pom.xml with: Ctrl+Shift+F - no works, context menu on editor - no works, context menu in Package explorer - no works
  4. BoykoAlex commented on Feb 5, 2025

    @BoykoAlex
    Contributor

    Do you have XML language server enabled?

  5. foal commented on Feb 5, 2025

    @foal
    Author

    If it is enabled by default - yes. As I said I do not change nothing, just unpack, run import project and try to format pom.xml

  6. foal commented on Feb 5, 2025

    @foal
    Author

    I have checked - yes, it is enabled

    Image

  7. martinlippert commented on Feb 6, 2025

    @martinlippert
    Member

    @anatoly-spb @foal Can you try to reproduce this with a plain Eclipse JEE 2024-12 installation from https://www.eclipse.org/downloads/packages/

    (Since I can't reproduce this locally, I am trying to identify where the problem might be coming from, therefore the various checks to see where the root cause might be)

  8. anatoly-spb commented on Feb 6, 2025

    @anatoly-spb

    @martinlippert Thank you for your time. I have downloaded https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2024-12/R/eclipse-java-2024-12-R-win32-x86_64.zip&mirror_id=1285 and there is no problem with formatting pom, it works as expected:

    1. download fresh eclipse for java developers
    2. create fresh workspace
    3. create simple maven project
    4. open pom with Maven POM Editor
    5. unformat pom.xml
    6. Ctrl+Shift+F formats my pom as expected
  9. foal commented on Feb 6, 2025

    @foal
    Author

    @martinlippert, yes, I can confirm in eclipse-jee-2024-12-R-win32-x86_64.zip the XML formatting on pom.xml works too from the box.

  10. 5 remaining items

  11. anatoly-spb commented on Feb 24, 2025

    @anatoly-spb

    @martinlippert Thank you for your time. I have installed fresh Eclipse 2024-12 installation, installed Spring Boot Language Server Feature and after that Format does not work.

  12. BoykoAlex commented on Feb 24, 2025

    @BoykoAlex
    Contributor

    Is content assist, validation still working in the POM editor?

  13. BoykoAlex commented on Feb 24, 2025

    @BoykoAlex
    Contributor

    Please turn on the logging for the Lemminx server (XML language server)
    Image

    Have another go at formatting while the logging is on and share the log contents with us please.

  14. anatoly-spb commented on Feb 24, 2025

    @anatoly-spb

    @BoykoAlex Thank you. Here is log org.eclipse.wildwebdeveloper.xml.zip

    the pom.xml:

    <project xmlns="http://maven.apache.org/POM/4.0.0"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    </project>
    
    

    There is one thing: Pom Xml is attached to Spring Boot Language Server:

    Image

    Is it ok?

    Pom Xml:

    Image

    Maven POM XML:

    Image

  15. BoykoAlex commented on Feb 24, 2025

    @BoykoAlex
    Contributor

    How do you invoke the formatting action? Select all/range and then Ctrl-F/Cmd-F?
    I don't see the textDocument/rangeFormatting message sent to XML language server in your log file... I do see it in mine where formatting works. Can you confirm that the textDocument/rangeFormatting message is not sent from the client to the server? In other words select a range invoke the action (perhaps try invoking the action via the context menu Source -> Format as well in case the key binding got disabled somehow) and find that in the log there is not textDocument/rangeFormatting message at all.

  16. anatoly-spb commented on Feb 24, 2025

    @anatoly-spb

    @BoykoAlex I try both Ctrl+Shift+F and context menu Source/Format - nothing work.

  17. BoykoAlex commented on Feb 24, 2025

    @BoykoAlex
    Contributor

    Do you see the textDocument/rangeFormatting in the XML LS log when you invoke the format action?
    If not, we should probably have a look at the Eclipse log as well... If this is the case, can you please attach the Eclipse log?

  18. anatoly-spb commented on Feb 25, 2025

    @anatoly-spb

    @BoykoAlex I see nothing with textDocument/rangeFormatting. I have attached eclipse log and others inside log.zip

    log.zip

  19. anatoly-spb commented on Feb 25, 2025

    @anatoly-spb

    Here is log from fresh Eclipse IDE installation. textDocument/rangeFormatting presents in .log file.

    log.xml.zip

    Also in fresh Eclipse IDE only one Maven POM XML content type, after installation Spring there is Pom XML:

    Image

    Does it matter?

  20. Rots commented on Dec 9, 2025

    @Rots

    This is marked as waiting-for-feedback. What kind of feedback is still expected?
    I ran into this issue as well. It is super annoying to have to rely on external tools for pom.xml formatting.

    Spring Tools for Eclipse
    Version: 4.32.2.RELEASE
    Build Id: 202511091838
    OS: Windows 11, v.10.0, x86_64 / win32
    Java vendor: Eclipse Adoptium
    Java runtime version: 21.0.5+11-LTS
    Java version: 21.0.5

    Update: nevermind, after restart of sts it works again.

  21. martinlippert commented on Dec 9, 2025

    @martinlippert
    Member

    Update: nevermind, after restart of sts it works again.

    I am finally closing this now, based on the latest comment here. In case you (or anyone else) come across this issue again, please comment and we can re-open.

  22. foal commented on Dec 9, 2025

    @foal
    Author

    I still have the issue with this functionality - right now the format works only for selected text. To format the XML I need to select them all or at least part with is unformatted.

  23. martinlippert commented on Dec 12, 2025

    @martinlippert
    Member

    Unfortunately, I am still not able to reproduce this - which makes it difficult to find the root cause here. From the above comments, it reads like as soon as you install the Spring Boot Language Server Feature into a plain Eclipse JEE package, the format action is somewhat broken. Can you verify if this is still the case with a new Eclipse 2025-12 JEE install and installing the Spring Boot Language Server Feature from https://cdn.spring.io/spring-tools/release/update/latest/ ? That would be great.

    In case this breaks the format action (again), what happens if you disable the association between POM Xml and the Spring Boot Language Server in the preferences via: Preferences -> Language Serversand restart the IDE?

    What happens if you open the pom.xml file with Open With...in the generic code editor? Does formatting work in there?

    Is there anything related showing up in the Error Log view when you open that? Anything related to XML or Lemminx maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: eclipsetype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions