Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.Arrays;

import org.osgi.framework.Version;
import org.slf4j.Logger;
Expand All @@ -41,6 +42,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IAccessRule;
Expand Down Expand Up @@ -167,7 +169,7 @@
String executionEnvironmentId = getExecutionEnvironmentId(options);
addJREClasspathContainer(classpath, executionEnvironmentId);

addMavenClasspathContainer(classpath);
addMavenClasspathContainer(javaProject, classpath);

addCustomClasspathEntries(javaProject, classpath);

Expand All @@ -193,7 +195,7 @@
UnitTestSupport.resetLaunchConfigurations(project);
}

@SuppressWarnings("unused")

Check warning on line 198 in org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java

View check run for this annotation

Jenkins - M2E / Compiler

Unnecessary Code

LOW: At least one of the problems in category 'unused' is not analysed due to a compiler option being ignored
protected IContainer getOutputLocation(ProjectConfigurationRequest request, IProject project) throws CoreException {
MavenProject mavenProject = request.mavenProject();
return getFolder(project, mavenProject.getBuild().getOutputDirectory());
Expand Down Expand Up @@ -259,8 +261,8 @@
environmentId);
return null;
}

protected void addMavenClasspathContainer(IClasspathDescriptor classpath) {
protected void addMavenClasspathContainer(IJavaProject javaProject, IClasspathDescriptor classpath) {
List<IClasspathEntryDescriptor> descriptors = classpath.getEntryDescriptors();
List<IAccessRule> accessRules = new ArrayList<>();
boolean isExported = false;
Expand All @@ -278,7 +280,15 @@
// ensure the external annotation path is kept
IClasspathAttribute[] externalAnnotations = readExternalAnnotationAttributes(classpath,
p -> MavenClasspathHelpers.MAVEN_CLASSPATH_CONTAINER_PATH.equals(p.getPath()));
IClasspathEntry cpe = MavenClasspathHelpers.getDefaultContainerEntry(externalAnnotations);

// Add module attribute if project has module-info.java
IClasspathAttribute[] attributes = externalAnnotations;
if (ModuleSupport.getModuleInfo(javaProject, new NullProgressMonitor()) != null) {
attributes = Arrays.copyOf(externalAnnotations, externalAnnotations.length + 1);
attributes[externalAnnotations.length] = JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true");
}

IClasspathEntry cpe = MavenClasspathHelpers.getDefaultContainerEntry(attributes);

// add new entry without removing existing entries first, see bug398121
IClasspathEntryDescriptor entryDescriptor = classpath.addEntry(cpe);
Expand All @@ -288,6 +298,8 @@
}
}



private static IClasspathAttribute[] readExternalAnnotationAttributes(IClasspathDescriptor classpath,
Predicate<IClasspathEntryDescriptor> annotationSourceEntry) {
Optional<String> annotationPath = classpath.getEntryDescriptors().stream().filter(annotationSourceEntry)
Expand Down
Loading