Skip to content

Commit

Permalink
Issue eclipse-m2e#155 - replace resolveParentProject by parent.getPro…
Browse files Browse the repository at this point in the history
…ject()

It's not clear why a project resolution is required, although it's a
very expansive operation and we already have the parent project at hand.
Just skip resolution for now.
  • Loading branch information
mickaelistria committed Nov 25, 2021
1 parent b5544ff commit 5aa8b78
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.m2e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.m2e.core;singleton:=true
Bundle-Version: 1.18.3.qualifier
Bundle-Version: 1.18.4.qualifier
Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.core</artifactId>
<version>1.18.3-SNAPSHOT</version>
<version>1.18.4-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>Maven Integration for Eclipse Core Plug-in</name>
Expand Down
11 changes: 11 additions & 0 deletions org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ Map<File, MavenExecutionResult> readMavenProjects(Collection<File> pomFiles,
@Deprecated MavenProject resolveParentProject(MavenExecutionRequest request, MavenProject project, IProgressMonitor monitor)
throws CoreException;

/**
* Returns MavenProject parent project or null if no such project.
*
* @param project
* @param monitor
* @return
* @throws CoreException
* @deprecated directly use <code>project.getParent()</code> whenever possible, and if parent needs to be re-resolved,
* it's a responsibility of the consumer to do it in its code.
*/
@Deprecated
MavenProject resolveParentProject(MavenProject project, IProgressMonitor monitor) throws CoreException;

// execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,14 @@ private PluginExecutionMetadata createMetadata(Xpp3Dom action) {
}

private static List<PI> parsePIs(MavenProject project) {

File pom = project.getFile();
InputSource source = project.getModel().getLocation(SELF).getSource();
File pom = project.getFile();
if((pom == null || !pom.isFile()) && source.getLocation() != null) {
pom = new File(source.getLocation());
}
if(pom == null || !pom.isFile()) {
return List.of();
}

List<PI> pis = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,7 @@ public static List<MappingMetadataSource> getPomMappingMetadataSources(MavenProj
maven.detachFromSession(project); // don't cache maven session
}

// TODO ideally, we need to reuse the same parent MavenProject instance in all child modules
// each instance takes ~1M, so we can easily save 100M+ of heap for larger workspaces
project = maven.resolveParentProject(project, monitor);
project = project.getParent();
} while(project != null);

return sources;
Expand Down

0 comments on commit 5aa8b78

Please sign in to comment.