Bug 547172 - [regression] Can no longer read project if parent folder doesn't match the parent project coordinates
Summary: [regression] Can no longer read project if parent folder doesn't match the pa...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-10 15:39 EDT by Fred Bricon CLA
Modified: 2021-04-19 13:24 EDT (History)
2 users (show)

See Also:


Attachments
Import toto/tata into the worskpace to reproduce the issue (6.83 KB, application/zip)
2019-05-10 15:39 EDT, Fred Bricon CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Bricon CLA 2019-05-10 15:39:58 EDT
Created attachment 278576 [details]
Import toto/tata into the worskpace to reproduce the issue

https://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=d0cd1dbaf370f7e7602c21ed653abc1e4f825f0a causes a project defining a parent project to fail loading with `Could not read maven project`, if the parent folder contains a different maven project than the one defined in the pom.

The error is thrown from:

ProjectRegistryManager.readProjectWithDependencies(IFile, ResolverConfiguration, IProgressMonitor) line: 854	
ProjectRegistryManager$2.call() line: 1062	
ProjectRegistryManager$2.call() line: 1	
LocalCache$LocalManualCache$1.load(Object) line: 5065	
LocalCache$LoadingValueReference<K,V>.loadFuture(K, CacheLoader<? super K,V>) line: 3716	
LocalCache$Segment<K,V>.loadSync(K, int, LoadingValueReference<K,V>, CacheLoader<? super K,V>) line: 2424	
LocalCache$Segment<K,V>.lockedGetOrLoad(K, int, CacheLoader<? super K,V>) line: 2298	
LocalCache$Segment<K,V>.get(K, int, CacheLoader<? super K,V>) line: 2211	
LocalCache<K,V>.get(K, CacheLoader<? super K,V>) line: 4154	
LocalCache$LocalManualCache<K,V>.get(K, Callable<? extends V>) line: 5060	
ProjectRegistryManager.getMavenProject(MavenProjectFacade, IProgressMonitor) line: 1060	
MavenProjectFacade.getMavenProject(IProgressMonitor) line: 242	
MavenBuilder$BuildMethod$1.call(IMavenExecutionContext, IProgressMonitor) line: 99	
MavenExecutionContext.executeBare(MavenProject, ICallable<V>, IProgressMonitor) line: 177	
MavenExecutionContext.execute(MavenProject, ICallable<V>, IProgressMonitor) line: 151	
MavenExecutionContext.execute(ICallable<V>, IProgressMonitor) line: 99	
MavenBuilder$1(MavenBuilder$BuildMethod<T>).execute(int, Map<String,String>, IProgressMonitor) line: 87	
MavenBuilder.build(int, Map<String,String>, IProgressMonitor) line: 201	
BuildManager$2.run() line: 833	
SafeRunner.run(ISafeRunnable) line: 45	
BuildManager.basicBuild(int, IncrementalProjectBuilder, Map<String,String>, MultiStatus, IProgressMonitor) line: 220	
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, ICommand[], MultiStatus, IProgressMonitor) line: 263	
BuildManager$1.run() line: 316	
SafeRunner.run(ISafeRunnable) line: 45	
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, MultiStatus, IProgressMonitor) line: 319	
BuildManager.basicBuildLoop(IBuildConfiguration[], IBuildConfiguration[], int, MultiStatus, IProgressMonitor) line: 371	
BuildManager.build(IBuildConfiguration[], IBuildConfiguration[], int, IProgressMonitor) line: 392	
AutoBuildJob.doBuild(IProgressMonitor) line: 154	
AutoBuildJob.run(IProgressMonitor) line: 244	
Worker.run() line: 63	

The issue is really caused by warnings (Project build error: 'parent.relativePath' of POM bar.foo:tata:0.0.1-SNAPSHOT (/Users/fbricon/Dev/workspaces/runtime-m2e-1.12/toto/tata/pom.xml) points at foo.bar:toto instead of io.takari:takari, please verify your project structure) being turned into catastrophic errors.

CLI builds don't fail, m2e 1.11 neither.
Comment 1 Mickael Istria CLA 2019-05-11 06:47:25 EDT
I'm not able to reproduce this.
I'm using an IDE with m2e commit 15d9b8d7181c39369615107519830590b6d7a2b4 , taking the zip, doing File > Import... > Existing maven project to import "tata" from your example (I have toto as parent folder with the pom in it), and I can import. I only see the warning on parent, no "Could not read maven project".
Are you using different steps?
Comment 2 Mickael Istria CLA 2019-05-11 06:54:48 EDT
(In reply to Mickael Istria from comment #1)
> I'm not able to reproduce this.
> I'm using an IDE with m2e commit 15d9b8d7181c39369615107519830590b6d7a2b4 ,
> taking the zip, doing File > Import... > Existing maven project to import
> "tata" from your example (I have toto as parent folder with the pom in it),
> and I can import. I only see the warning on parent, no "Could not read maven
> project".
> Are you using different steps?

If you can directly submit a patch that reproduces this issue in a test case (see RegistryTest for similar ones), that'd be even better ;)
Comment 3 Till Brychcy CLA 2019-05-14 05:09:56 EDT
We also have a reactor pom which not the parent pom of the submodules.

I see the problem when doing "Update Project..." (in our workspace, haven't tried the attachment) in a module which misses the "<relativePath />" in the "<parent>"-tag
Comment 4 Mickael Istria CLA 2019-05-14 05:12:31 EDT
(In reply to Till Brychcy from comment #3)
> We also have a reactor pom which not the parent pom of the submodules.
> 
> I see the problem when doing "Update Project..." (in our workspace, haven't
> tried the attachment) in a module which misses the "<relativePath />" in the
> "<parent>"-tag

Can you please detail, with an example project (ideally the one shared by Fred on this ticket), exact steps to reproduce this issue?
Comment 5 Till Brychcy CLA 2019-05-14 05:30:12 EDT
Immediately happens with the attached zip (I just imported tata).
As described, touch and saving makes the error go away, "Update project" returns it.

(I run m2e from source)
Comment 6 Mickael Istria CLA 2019-05-14 05:38:48 EDT
Ok, I could finally reproduce it. Working on it right now.
Comment 7 Till Brychcy CLA 2019-05-14 05:41:32 EDT
Happens since commit d0cd1dbaf370f7e7602c21ed653abc1e4f825f0a
Comment 8 Mickael Istria CLA 2019-05-14 08:57:57 EDT
While I think I found an acceptable solution, I do not manage to reproduce it in a test case, while I can reproduce it with a debugged IDE, and comparing the execution path seem very similar.
It seems like MavenImpl#readMavenProjects() can behave a bit differently (in some cases ignoring the warnings, in some other adding the warnings). Does anyone have an idea what can cause that? Some preference maybe?
Comment 9 Till Brychcy CLA 2019-05-14 09:20:14 EDT
It could be related to warnings in general:

I just noted it also happens in another project that is not part of a reactor, but has a warning caused by a parent pom.

Warning was;
"Project build error: Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter.".

After updating to a parent pom version where this was fixed, the problem went away.
Comment 10 Till Brychcy CLA 2019-05-14 09:36:14 EDT
I looks like you've already found a solution, but here is an example pom.xml, for my previous comment, maybe it is easier to create a test case with this:

(store in pom.xml in a new directory and import as maven project)

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>test.group</groupId>
	<artifactId>test.artifact</artifactId>
	<version>1.0.0</version>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-site-plugin</artifactId>
				<version>3.3</version>
				<configuration>
					<reportPlugins>
					</reportPlugins>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
Comment 11 Eclipse Genie CLA 2019-05-14 09:56:23 EDT
New Gerrit change created: https://git.eclipse.org/r/142135
Comment 12 Mickael Istria CLA 2019-05-15 02:33:16 EDT
Merged.
Comment 14 Denis Roy CLA 2021-04-19 13:24:06 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/