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

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

Open
foal opened this issue Jan 26, 2025 · 23 comments
Open

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

foal opened this issue Jan 26, 2025 · 23 comments
Labels
for: eclipse something that is specific for Eclipse status: waiting-for-feedback type: bug

Comments

@foal
Copy link

foal commented Jan 26, 2025

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.

@martinlippert
Copy link
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.

@anatoly-spb
Copy link

anatoly-spb commented Feb 4, 2025

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

@foal
Copy link
Author

foal commented Feb 5, 2025

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

@BoykoAlex
Copy link
Contributor

Do you have XML language server enabled?

@foal
Copy link
Author

foal commented Feb 5, 2025

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
Copy link
Author

foal commented Feb 5, 2025

I have checked - yes, it is enabled

Image

@martinlippert
Copy link
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)

@anatoly-spb
Copy link

anatoly-spb commented Feb 6, 2025

@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

@foal
Copy link
Author

foal commented Feb 6, 2025

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

@anatoly-spb
Copy link

anatoly-spb commented Feb 6, 2025

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.

@martinlippert
Copy link
Member

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.

@foal
Copy link
Author

foal commented Feb 14, 2025

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.

@anatoly-spb
Copy link

@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

@martinlippert
Copy link
Member

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

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.

@anatoly-spb
Copy link

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

@BoykoAlex
Copy link
Contributor

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

@BoykoAlex
Copy link
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.

@anatoly-spb
Copy link

anatoly-spb commented Feb 24, 2025

@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

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Feb 24, 2025

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.

@anatoly-spb
Copy link

anatoly-spb commented Feb 24, 2025

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

@BoykoAlex
Copy link
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?

@anatoly-spb
Copy link

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

log.zip

@anatoly-spb
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: eclipse something that is specific for Eclipse status: waiting-for-feedback type: bug
Projects
None yet
Development

No branches or pull requests

4 participants