Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » Project name template and name conflict in maven import task(The template is not considered for detecting naming conflicts.)
Project name template and name conflict in maven import task [message #1857220] Wed, 25 January 2023 12:56 Go to next message
Robert Neßelrath is currently offline Robert NeßelrathFriend
Messages: 12
Registered: December 2022
Junior Member
Hello,

I have a workspace where I import two maven projects with the same project name. When importing the second project, it is by default rejected because the project has already been imported. I usually circumvent this problem by defining a name template for the maven import. This works for manually imports.

I tried to achieve the same behavior within an Oomph setup and defined the property "Project Name Template". Nevertheless the project is not imported.

Is this a known bug or is there something wrong with my approach?
Re: Project name template and name conflict in maven import task [message #1857226 is a reply to message #1857220] Wed, 25 January 2023 17:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
I'm not so familiar with the implementation details of this task. It's easy to set up an Oomph environment:

https://www.eclipse.org/setups/installer/?url=http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/configurations/OomphConfiguration.setup&show=true

Start the Runtime Workspace, use Navigate -> Open Setup -> Workspace, copy your Maven import task in there, run Help -> Perform Setup Tasks, and then debug what happens in MavenImportTaskImpl.perform to help fix any problem either in the code or in what you have specified in the task.

Otherwise I'd need to be able to reproduce your problem....


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Project name template and name conflict in maven import task [message #1857232 is a reply to message #1857226] Thu, 26 January 2023 10:12 Go to previous messageGo to next message
Robert Neßelrath is currently offline Robert NeßelrathFriend
Messages: 12
Registered: December 2022
Junior Member
Oh, that's much better than searching for code snippets in the internet to understand the functionality of some setups ;)

In fact it may be a bug, at least it is inconsistent to the maven import functionality of eclipse.
The maven import setup task first checks for projects with the same name that have already been added to the workspace.
If this is the case, the project is ignored and the setup task finishes without doing anything.
The name template is considered later in the code when actually importing the project into the workspace.

[Updated on: Thu, 26 January 2023 10:23]

Report message to a moderator

Re: Project name template and name conflict in maven import task [message #1857234 is a reply to message #1857232] Thu, 26 January 2023 12:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
Yes, I had a look and I see what you mean. The logic in org.eclipse.oomph.setup.maven.impl.MavenImportTaskImpl.processMavenProject(SourceLocator, Set<MavenProjectInfo>, MavenProjectInfo, IProgressMonitor) doesn't take into consideration that the name template can produce a different name. But I don't know how we could determine the name that the template will produce at this point in the logic... One alternative that I can imagine which doesn't require that knowledge is getting the location of all the projects and instead checking if a project already exists for the location. Of course then there might be a failure if there is a name collision in the end, so better would be to properly compute the name...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Project name template and name conflict in maven import task [message #1857235 is a reply to message #1857234] Thu, 26 January 2023 12:18 Go to previous messageGo to next message
Robert Neßelrath is currently offline Robert NeßelrathFriend
Messages: 12
Registered: December 2022
Junior Member
I think some minor changes would be required in MavenImportTaskImpl, after having a first look into the code.

First would be to generate and populate the project configuration manager earlier in the code. I think for this no further information is required than projectNameTemplate.
Second is to pass it as an additional argument to the processMavenProject methods and use it to find out the final project name.
Re: Project name template and name conflict in maven import task [message #1857236 is a reply to message #1857235] Thu, 26 January 2023 12:22 Go to previous messageGo to next message
Robert Neßelrath is currently offline Robert NeßelrathFriend
Messages: 12
Registered: December 2022
Junior Member
Oh sorry, I missed that the final logic is in the m2e ProjectConfigurationManager

[Updated on: Thu, 26 January 2023 12:34]

Report message to a moderator

Re: Project name template and name conflict in maven import task [message #1857237 is a reply to message #1857236] Thu, 26 January 2023 12:30 Go to previous messageGo to next message
Robert Neßelrath is currently offline Robert NeßelrathFriend
Messages: 12
Registered: December 2022
Junior Member
Just had an idea. If the m2e ProjectConfigurationManager is used and m2e supports the correct detection of duplicates, what happens if the detection in the oomph task is disabled.

So if commented out the if statement in line 475 of the MavenImportTaskImpl
if (!ROOT.getProject(projectName).exists())
and tested the change.

Now the project is created with the correct project name in the workspace.

The second test was what happens if the project is really already in the work space. In this case we reach line 817 in the m2e org.eclipse.m2e.core.internal.project.ProjectConfigurationManager which logs an error message and the project import is skipped.

Maybe this is already the solution....

[Updated on: Thu, 26 January 2023 12:34]

Report message to a moderator

Re: Project name template and name conflict in maven import task [message #1857243 is a reply to message #1857237] Thu, 26 January 2023 13:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33145
Registered: July 2009
Senior Member
This is similar to my idea with only checking duplicate locations... Perhaps if there is a name template we check look up (find) the project by location, otherwise we look it up by name. I.e., I still think it's good to avoid errors in the importer as much as is possible/sensible...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Project name template and name conflict in maven import task [message #1857256 is a reply to message #1857243] Thu, 26 January 2023 20:15 Go to previous message
Robert Neßelrath is currently offline Robert NeßelrathFriend
Messages: 12
Registered: December 2022
Junior Member
Yes, I agree. Otherwise the error would always be logged if the task is repeated on start or trigger.
Previous Topic:Maven Location
Next Topic:Can Eclipse Installer be run from command line?
Goto Forum:
  


Current Time: Tue May 07 20:40:37 GMT 2024

Powered by FUDForum. Page generated in 0.05007 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top