From 41b34073b0708edfb9f8ad554350936d4a502c11 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Wed, 29 Dec 2021 11:11:00 +0100 Subject: [PATCH 1/3] [TargetPlatform] update dependencies (#469) --- target-platform/target-platform.target | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target-platform/target-platform.target b/target-platform/target-platform.target index 39ffc3a481..b795335e87 100644 --- a/target-platform/target-platform.target +++ b/target-platform/target-platform.target @@ -10,23 +10,23 @@ - + - + - + - + From 964600bb9592233b53959896b59577a30a14c4a4 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Wed, 29 Dec 2021 10:09:09 +0100 Subject: [PATCH 2/3] [CleanUp] resource handling in MavenBuilder and MavenProjectUtils --- .../internal/builder/MavenBuilderImpl.java | 40 +++-------------- .../m2e/core/project/MavenProjectUtils.java | 43 ++++++++----------- 2 files changed, 25 insertions(+), 58 deletions(-) diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilderImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilderImpl.java index c09b4bbd4e..ae174da051 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilderImpl.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilderImpl.java @@ -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 @@ -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; @@ -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; @@ -229,9 +229,9 @@ private void processMavenSessionErrors(MavenSession session, MojoExecutionKey mo private void refreshResources(IProject project, Collection 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 } @@ -239,7 +239,7 @@ private void refreshResources(IProject project, Collection resources, IPro 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 { @@ -261,24 +261,6 @@ private void refreshResources(IProject project, Collection 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 buildErrors) { IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager(); @@ -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); } @@ -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); } diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenProjectUtils.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenProjectUtils.java index 60f62f5b12..1a99150cd7 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenProjectUtils.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/MavenProjectUtils.java @@ -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 @@ -36,13 +36,13 @@ 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(); @@ -50,7 +50,6 @@ public static IPath getProjectRelativePath(IProject project, String resourceLoca if(projectLocation == null || !projectLocation.isPrefixOf(directory)) { return null; } - return directory.removeFirstSegments(projectLocation.segmentCount()).makeRelative().setDevice(null); } @@ -73,29 +72,23 @@ public static IPath[] getSourceLocations(IProject project, List 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 exists in the + * workspace. + */ + 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; } - } From 2fa607b526e29d94a66d6143a2f17424300dcffb Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Fri, 24 Dec 2021 10:38:59 +0100 Subject: [PATCH 3/3] Remove unnecessary description file and buildall.sh script --- buildall.sh | 4 ---- description | 1 - 2 files changed, 5 deletions(-) delete mode 100755 buildall.sh delete mode 100644 description diff --git a/buildall.sh b/buildall.sh deleted file mode 100755 index 493cea8f67..0000000000 --- a/buildall.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -mvn -f m2e-maven-runtime/pom.xml clean generate-sources -Dtycho.mode=maven -Pgenerate-osgi-metadata -mvn clean install diff --git a/description b/description deleted file mode 100644 index f5f494ffbf..0000000000 --- a/description +++ /dev/null @@ -1 +0,0 @@ -m2eclipse-core repository \ No newline at end of file