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

#1130: improve using variable FAIL_ON_AMBIGOUS_MERGE incl. documentat… #1158

Merged

Conversation

hohwille
Copy link
Member

@hohwille hohwille commented Mar 21, 2025

fixes #1130
improvement for PR #1138

  • improve using variable FAIL_ON_AMBIGOUS_MERGE
  • add documentation
  • add test
  • follow best-practice to have test (XmlMergerTest) in the same package as the tested class (XmlMerger)
  • also renamed the package com.devonfw.tools.ide.merge.xmlmerger to com.devonfw.tools.ide.merge.xml following DRY principle.

@hohwille hohwille added enhancement New feature or request configuration should be configurable or configuration change merger labels Mar 21, 2025
@hohwille hohwille added this to the release:2025.03.002 milestone Mar 21, 2025
@hohwille hohwille merged commit af1f59a into devonfw:main Mar 21, 2025
3 checks passed
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 13999873361

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 67.738%

Totals Coverage Status
Change from base Build 13998949209: 0.07%
Covered Lines: 7838
Relevant Lines: 11144

💛 - Coveralls

@hohwille
Copy link
Member Author

hohwille commented Mar 27, 2025

Successfully tested with latest SNAPSHOT (2025.03.002-20250327.024013-7):
By default the error is gone (PR #1138).
After adding the following line to conf/ide.properties:

FAIL_ON_AMBIGOUS_MERGE=true

I could get this from ide intellij:

Start: Configuring workspace main for IDE intellij
Failed to merge workspace file D:\projects\IDEasy\workspaces\main\.idea\workspace.xml with update template D:\projects\IDEasy\settings\intellij\workspace\update\.idea\workspace.xml and setup file D:\projects\IDEasy\settings\intellij\workspace\setup\.idea\workspace.xml!
com.devonfw.tools.ide.merge.xml.XmlMergeException: Merge strategy combine failed on /project[@version='4']/component[@name='RunManager']
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy.merge(XmlMergeStrategy.java:68)
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy.combineChildNodes(XmlMergeStrategy.java:112)
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy$1.doMerge(XmlMergeStrategy.java:29)
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy.merge(XmlMergeStrategy.java:64)
        at com.devonfw.tools.ide.merge.xml.XmlMerger.merge(XmlMerger.java:123)
        at com.devonfw.tools.ide.merge.xml.XmlMerger.doMerge(XmlMerger.java:82)
        at com.devonfw.tools.ide.merge.FileMerger.merge(FileMerger.java:50)
        at com.devonfw.tools.ide.merge.DirectoryMerger.merge(DirectoryMerger.java:69)
        at com.devonfw.tools.ide.merge.DirectoryMerger.merge(DirectoryMerger.java:73)
        at com.devonfw.tools.ide.merge.DirectoryMerger.merge(DirectoryMerger.java:73)
        at com.devonfw.tools.ide.tool.ide.IdeToolCommandlet.mergeWorkspaceSingle(IdeToolCommandlet.java:103)
        at com.devonfw.tools.ide.tool.ide.IdeToolCommandlet.mergeWorkspace(IdeToolCommandlet.java:90)
        at com.devonfw.tools.ide.tool.ide.IdeToolCommandlet.configureWorkspace(IdeToolCommandlet.java:72)
        at com.devonfw.tools.ide.tool.ide.IdeToolCommandlet.run(IdeToolCommandlet.java:48)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:958)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:876)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:95)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:59)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:133)
        at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.lang.IllegalStateException: 2 matches found for XPath configuration[@default='true' and @type='JUnit'] in workspace XML at /project[@version='4']/component[@name='RunManager' @selected='JUnit.EnvironmentVariablesTest.testGetToolVariable']
        at com.devonfw.tools.ide.merge.xml.matcher.IdComputer.evaluateExpression(IdComputer.java:73)
        at com.devonfw.tools.ide.merge.xml.matcher.ElementMatcher.matchElement(ElementMatcher.java:61)
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy.combineChildNodes(XmlMergeStrategy.java:106)
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy$1.doMerge(XmlMergeStrategy.java:29)
        at com.devonfw.tools.ide.merge.xml.XmlMergeStrategy.merge(XmlMergeStrategy.java:64)
        ... 19 more

Your workspace configuration failed with 1 error(s) - see log above.
This is either a configuration error in your settings git repository or a bug in IDEasy.
Please analyze the above errors with your team or IDE-admin and try to fix the problem.
In order to prevent you from being blocked, you can start your IDE anyhow but some configuration may not be in sync.
Option 1: yes
Option 2: no

@hohwille hohwille added story-review marks PRs that will be presented in the sprint-review story-reviewed Marks PRs that have been presented in the sprint-review meeting or that do not need to be presented. and removed story-review marks PRs that will be presented in the sprint-review labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration should be configurable or configuration change enhancement New feature or request merger story-reviewed Marks PRs that have been presented in the sprint-review meeting or that do not need to be presented.
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

improve behaviour on ambiguous XPath match
3 participants