sts4 icon indicating copy to clipboard operation
sts4 copied to clipboard

No format for pom.xml in the Maven POM editor

Open foal opened this issue 11 months ago • 23 comments

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: a0cb489d5daf268d32d7327495fe28f3d12212b3 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.

foal avatar Jan 26 '25 16:01 foal

@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.

martinlippert avatar Jan 27 '25 07:01 martinlippert

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

anatoly-spb avatar Feb 04 '25 09:02 anatoly-spb

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

foal avatar Feb 05 '25 19:02 foal

Do you have XML language server enabled?

BoykoAlex avatar Feb 05 '25 19:02 BoykoAlex

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

foal avatar Feb 05 '25 20:02 foal

I have checked - yes, it is enabled

Image

foal avatar Feb 05 '25 20:02 foal

@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)

martinlippert avatar Feb 06 '25 06:02 martinlippert

@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

anatoly-spb avatar Feb 06 '25 07:02 anatoly-spb

@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.

foal avatar Feb 06 '25 07:02 foal

I try to compare Spring Tool Suite 4.28.0.RELEASE with eclipse-jee-2024-12-R-win32-x86_64.zip. There are several remarks:

  1. Eclipse JEE uses Temurin-21.0.5+11, STD uses Temurin-21.0.6+7
  2. I start STS and Eclipse JEE with the -consoleLog -debug command line options. When open pom.xml in Eclipse JEE there are messages from org.eclipse.wildwebdeveloper.xml in console log:
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\stranger'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.wildwebdeveloper.xml 2 0 2025-02-06 11:52:10.981
!MESSAGE The given URI https://jakarta.ee/xml/ns/jakartaee/application-client_9.xsd from org.eclipse.jst.standard.schemas could not be resolved for local access

!ENTRY org.eclipse.wildwebdeveloper.xml 2 0 2025-02-06 11:52:10.984
!MESSAGE The given URI https://jakarta.ee/xml/ns/jakartaee/jobXML_2_0.xsd from org.eclipse.jst.standard.schemas could not be resolved for local access

!ENTRY org.eclipse.wildwebdeveloper.xml 2 0 2025-02-06 11:52:10.987
!MESSAGE The given URI https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd from org.eclipse.jst.standard.schemas could not be resolved for local access

!ENTRY org.eclipse.wildwebdeveloper.xml 2 0 2025-02-06 11:52:10.991
!MESSAGE The given URI https://jakarta.ee/xml/ns/jaxb/bindingschema_3_0.xsd from org.eclipse.jst.standard.schemas could not be resolved for local access

!ENTRY org.eclipse.wildwebdeveloper.xml 2 0 2025-02-06 11:52:11.004
!MESSAGE The given URI https://jakarta.ee/xml/ns/validation/validation-configuration-3.0.xsd from org.eclipse.jst.standard.schemas could not be resolved for local access

!ENTRY org.eclipse.wildwebdeveloper.xml 2 0 2025-02-06 11:52:11.010
!MESSAGE The given URI http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_1.xsd from org.eclipse.jst.standard.schemas could not be resolved for local access

STS outputs only the following without messages from org.eclipse.wildwebdeveloper.xml:

!ENTRY org.eclipse.egit.ui 2 0 2025-02-06 11:47:21.608
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\stranger'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.jface 2 0 2025-02-06 11:53:00.735
!MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2025-02-06 11:53:00.736
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
        ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
                Open a type in a Java editor,
                Category(org.eclipse.ui.category.navigate,Navigate,null,true),
                WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"),
                ,,true),null),
        org.eclipse.ui.defaultAcceleratorConfiguration,
        org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
        ParameterizedCommand(Command(org.eclipse.lsp4e.symbolInWorkspace,Go to Symbol in Workspace,
                ,
                Category(org.eclipse.lsp4e.category,Language Servers,null,true),
                WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolInWorkspace"),
                ,,true),null),
        org.eclipse.ui.defaultAcceleratorConfiguration,
        org.eclipse.ui.contexts.window,,,system)

May be it will be helpfull.

anatoly-spb avatar Feb 06 '25 08:02 anatoly-spb

The warning message in the log output around the binding for Ctrl-Shift-T is a know message and most likely unrelated to the formatting issue. But I am still puzzled why you are seeing this, but I don't and my colleague running a Windows box does also not see this issue... 🤔

You could try to see what happens if you install the Spring Tools into an existing, fresh Eclipse JEE package to see if that turns the existing and working Eclipse installation into one that doesn't work. That would at least give us a hint about whether the Spring Tools extension itself causes this or some additional plugins that the Spring Tools distribution has pre-installed. Other than that, I am slowly running out of ideas how to debug this remotely.

martinlippert avatar Feb 14 '25 12:02 martinlippert

Checked - not working too. TLDR

  1. Open POM in fresh Eclipse JEE and check if formatting works. Yes.
  2. Install Spring Tools from marketplace as below Image
  3. Restart Eclipse after update and check (on the same POM) if formatting works. No.

foal avatar Feb 14 '25 12:02 foal

@martinlippert I have installed the Spring Tool Suite 4.28.0.RELEASE on eclipse-jee-2024-12-R-win32-x86_64. Maven POM Editor does not format pom.xml after installation.

I have attached the config difference report between before and after installation (unzip to see html report).

config-diff.zip

anatoly-spb avatar Feb 14 '25 13:02 anatoly-spb

@anatoly-spb @foal I am slowly running out of ideas here, but I am not willing to give up in this (yet)... :-)

Can you a stepwise approach to installing the Spring Tools components into a vanilla Eclipse JEE 2024-12 package? This might at least give us a hint about which part of the Spring Tools add-ons cause this issue.

The idea would be:

  • start with a vanilla fresh Eclipse 2024-12 installation
  • check whether the format option is working (we expect that it works up to here)
  • to go Install New Software and use this URL: https://cdn.spring.io/spring-tools/release/TOOLS/sts4/update/4.28.1.RELEASE/e4.34
  • then select the Spring Boot Language Server Feature only, nothing else, and finish the install

Is the format action still working or not after this? If it does still work, then go to Install New Software again, select the same update site, and install the Spring IDE Boot Microservices Dash

The idea is to find out which exact component install break the format action.

Thanks again for your patience and help debugging this. Much appreciated.

martinlippert avatar Feb 24 '25 12:02 martinlippert

@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.

anatoly-spb avatar Feb 24 '25 13:02 anatoly-spb

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

BoykoAlex avatar Feb 24 '25 14:02 BoykoAlex

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.

BoykoAlex avatar Feb 24 '25 14:02 BoykoAlex

@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

anatoly-spb avatar Feb 24 '25 14:02 anatoly-spb

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.

BoykoAlex avatar Feb 24 '25 16:02 BoykoAlex

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

anatoly-spb avatar Feb 24 '25 16:02 anatoly-spb

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?

BoykoAlex avatar Feb 24 '25 18:02 BoykoAlex

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

log.zip

anatoly-spb avatar Feb 25 '25 07:02 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?

anatoly-spb avatar Feb 25 '25 08:02 anatoly-spb

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.

Rots avatar Dec 09 '25 19:12 Rots

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.

martinlippert avatar Dec 09 '25 19:12 martinlippert

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.

foal avatar Dec 09 '25 20:12 foal