Skip to content

Commit

Permalink
Merge branch 'master' into mavenRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Jan 2, 2022
2 parents d713502 + 2fa607b commit 4e1206e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 67 deletions.
4 changes: 0 additions & 4 deletions buildall.sh

This file was deleted.

1 change: 0 additions & 1 deletion description

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 Sonatype, Inc.
* Copyright (c) 2010, 2021 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -38,7 +38,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;

import org.apache.maven.execution.MavenExecutionResult;
Expand All @@ -58,6 +57,7 @@
import org.eclipse.m2e.core.internal.markers.SourceLocation;
import org.eclipse.m2e.core.internal.markers.SourceLocationHelper;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectUtils;
import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;

Expand Down Expand Up @@ -229,17 +229,17 @@ private void processMavenSessionErrors(MavenSession session, MojoExecutionKey mo
private void refreshResources(IProject project, Collection<File> resources, IProgressMonitor monitor)
throws CoreException {
for(File file : resources) {
IPath path = getProjectRelativePath(project, file);
IPath path = MavenProjectUtils.getProjectRelativePath(project, file.getAbsolutePath());
if(path == null) {
log.debug("Could not get relative path for file: ", file.getAbsoluteFile());
log.debug("Could not get relative path for file: {}", file.getAbsoluteFile());
continue; // odd
}

IResource resource;
if(path.isEmpty()) {
resource = project;
} else if(!file.exists()) {
resource = project.findMember(path);
resource = project.findMember(path); // null if path does not exist in the workspace
} else if(file.isDirectory()) {
resource = project.getFolder(path);
} else {
Expand All @@ -261,24 +261,6 @@ private void refreshResources(IProject project, Collection<File> resources, IPro
}
}

public static IPath getProjectRelativePath(IProject project, File file) {
if(project == null || file == null) {
return null;
}

IPath projectPath = project.getLocation();
if(projectPath == null) {
return null;
}

IPath filePath = new Path(file.getAbsolutePath());
if(!projectPath.isPrefixOf(filePath)) {
return null;
}

return filePath.removeFirstSegments(projectPath.segmentCount());
}

private void processBuildResults(IProject project, MavenProject mavenProject, MavenExecutionResult result,
BuildResultCollector results, Map<Throwable, MojoExecutionKey> buildErrors) {
IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager();
Expand Down Expand Up @@ -324,11 +306,7 @@ private void processBuildResults(IProject project, MavenProject mavenProject, Ma

private void deleteBuildParticipantMarkers(IProject project, IMavenMarkerManager markerManager, File file,
String buildParticipantId) {
IPath path = getProjectRelativePath(project, file);
IResource resource = null;
if(path != null) {
resource = project.findMember(path);
}
IResource resource = MavenProjectUtils.getProjectResource(project, file);
if(resource == null) {
resource = project.getFile(IMavenConstants.POM_FILE_NAME);
}
Expand All @@ -343,11 +321,7 @@ private void deleteBuildParticipantMarkers(IProject project, IMavenMarkerManager
private void addBuildParticipantMarker(IProject project, IMavenMarkerManager markerManager, Message buildMessage,
String buildParticipantId) {

IPath path = getProjectRelativePath(project, buildMessage.file);
IResource resource = null;
if(path != null) {
resource = project.findMember(path);
}
IResource resource = MavenProjectUtils.getProjectResource(project, buildMessage.file);
if(resource == null) {
resource = project.getFile(IMavenConstants.POM_FILE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008-2010 Sonatype, Inc.
* Copyright (c) 2008-2021 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -36,21 +36,20 @@ private MavenProjectUtils() {
}

/**
* Returns project resource for given filesystem location or null the location is outside of project.
* Returns project resource path for given file-system location or null if the location is outside of project.
*
* @param resourceLocation absolute filesystem location
* @return IPath the full, absolute workspace path resourceLocation
* @param resourceLocation absolute file-system location
* @return IPath the full, absolute workspace path of resourceLocation
*/
public static IPath getProjectRelativePath(IProject project, String resourceLocation) {
if(resourceLocation == null) {
if(project == null || resourceLocation == null) {
return null;
}
IPath projectLocation = project.getLocation();
IPath directory = Path.fromOSString(resourceLocation); // this is an absolute path!
if(projectLocation == null || !projectLocation.isPrefixOf(directory)) {
return null;
}

return directory.removeFirstSegments(projectLocation.segmentCount()).makeRelative().setDevice(null);
}

Expand All @@ -73,29 +72,23 @@ public static IPath[] getSourceLocations(IProject project, List<String> roots) {
return locations.toArray(new IPath[locations.size()]);
}

/**
* Returns the {@link IResource} of the given project that has the same absolute path in the local file system like
* the given file or null if the file does not point into the project or no such resource <b>exists in the
* workspace</b>.
*/
public static IResource getProjectResource(IProject project, File file) {
String resourceLocation = file != null ? file.getAbsolutePath() : null;
IPath relativePath = getProjectRelativePath(project, resourceLocation);
return relativePath != null ? project.findMember(relativePath) : null;
}

/**
* Returns the full, absolute path of the given file relative to the workspace. Returns null if the file does not
* exist or is not a member of this project.
*/
public static IPath getFullPath(IProject project, File file) {
if(project == null || file == null) {
return null;
}

IPath projectPath = project.getLocation();
if(projectPath == null) {
return null;
}

IPath filePath = new Path(file.getAbsolutePath());
if(!projectPath.isPrefixOf(filePath)) {
return null;
}
IResource resource = project.findMember(filePath.removeFirstSegments(projectPath.segmentCount()));
if(resource == null) {
return null;
}
return resource.getFullPath();
IResource resource = getProjectResource(project, file);
return resource != null ? resource.getFullPath() : null;
}

}
8 changes: 4 additions & 4 deletions target-platform/target-platform.target
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
<unit id="org.eclipse.ui.tests.harness" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/egit/updates-5.13/"/>
<repository location="https://download.eclipse.org/egit/updates-6.0/"/>
<unit id="org.eclipse.jgit" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/modeling/emf/emf/builds/release/2.27/"/>
<repository location="https://download.eclipse.org/modeling/emf/emf/builds/release/2.28/"/>
<unit id="org.eclipse.emf.edit.ui.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.ecore.edit.feature.group" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/webtools/downloads/drops/R3.22.0/R-3.22.0-20210612170523/repository/"/>
<repository location="https://download.eclipse.org/webtools/downloads/drops/R3.24.0/R-3.24.0-20211122101137/repository/"/>
<unit id="org.eclipse.wst.common.uriresolver" version="0.0.0"/>
<unit id="org.eclipse.wst.common.emf" version="0.0.0"/>
<unit id="org.eclipse.wst.xml.ui" version="0.0.0"/>
<unit id="org.eclipse.wst.xsd.core" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/tools/orbit/downloads/2021-09/"/>
<repository location="https://download.eclipse.org/tools/orbit/downloads/2021-12/"/>
<unit id="com.google.gson" version="0.0.0"/>
<unit id="com.google.guava" version="0.0.0"/>
<unit id="ch.qos.logback.core" version="0.0.0"/>
Expand Down

0 comments on commit 4e1206e

Please sign in to comment.