diff --git a/org.eclipse.xtend.m2e/src/org/eclipse/xtend/m2e/XtendProjectConfigurator.java b/org.eclipse.xtend.m2e/src/org/eclipse/xtend/m2e/XtendProjectConfigurator.java index d704f708266..334c3c8c3ab 100644 --- a/org.eclipse.xtend.m2e/src/org/eclipse/xtend/m2e/XtendProjectConfigurator.java +++ b/org.eclipse.xtend.m2e/src/org/eclipse/xtend/m2e/XtendProjectConfigurator.java @@ -15,7 +15,6 @@ import static org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess.getOutputForSourceFolderKey; import java.io.File; -import java.lang.reflect.Method; import java.util.List; import org.apache.maven.plugin.MojoExecution; @@ -26,7 +25,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator; import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest; import org.eclipse.xtend.core.compiler.XtendOutputConfigurationProvider; @@ -158,25 +156,10 @@ private T mojoParameterValue(String paramName, Class paramType, ProjectCo } static IProject getProject(ProjectConfigurationRequest request) { - return XtendProjectConfigurator.call(request, "getMavenProjectFacade", "mavenProjectFacade").getProject(); + return request.mavenProjectFacade().getProject(); } static MavenProject getMavenProject(ProjectConfigurationRequest request) { - return call(request, "getMavenProject", "mavenProject"); - } - - @SuppressWarnings("unchecked") - private static R call(T obj, String oldMethodName, String newMethodName) { - try { - Method method = obj.getClass().getMethod(oldMethodName); - return (R) method.invoke(obj); - } catch (ReflectiveOperationException er) { - try { // We are probably running with M2E >= 2.0 try the new method name - Method method = obj.getClass().getMethod(newMethodName); - return (R) method.invoke(obj); - } catch (ReflectiveOperationException e) { - throw new IllegalStateException(e); - } - } + return request.mavenProject(); } } \ No newline at end of file diff --git a/org.eclipse.xtext.m2e/src/org/eclipse/xtext/m2e/XtextProjectConfigurator.java b/org.eclipse.xtext.m2e/src/org/eclipse/xtext/m2e/XtextProjectConfigurator.java index e85e1ee5c71..1087cb86f1f 100644 --- a/org.eclipse.xtext.m2e/src/org/eclipse/xtext/m2e/XtextProjectConfigurator.java +++ b/org.eclipse.xtext.m2e/src/org/eclipse/xtext/m2e/XtextProjectConfigurator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2022 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2014, 2024 itemis AG (http://www.itemis.eu) and others. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. @@ -24,10 +24,8 @@ import static org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess.getIgnoreSourceFolderKey; import static org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess.getKey; import static org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess.getOutputForSourceFolderKey; -import org.eclipse.m2e.core.project.IMavenProjectFacade; import java.io.File; -import java.lang.reflect.Method; import java.util.List; import org.apache.maven.plugin.MojoExecution; @@ -129,26 +127,10 @@ private String makeProjectRelative(String fileName, } static IProject getProject(ProjectConfigurationRequest request) { - return XtextProjectConfigurator.call(request, "getMavenProjectFacade", "mavenProjectFacade").getProject(); + return request.mavenProjectFacade().getProject(); } static MavenProject getMavenProject(ProjectConfigurationRequest request) { - return call(request, "getMavenProject", "mavenProject"); + return request.mavenProject(); } - - @SuppressWarnings("unchecked") - private static R call(T obj, String oldMethodName, String newMethodName) { - try { - Method method = obj.getClass().getMethod(oldMethodName); - return (R) method.invoke(obj); - } catch (ReflectiveOperationException er) { - try { // We are probably running with M2E >= 2.0 try the new method name - Method method = obj.getClass().getMethod(newMethodName); - return (R) method.invoke(obj); - } catch (ReflectiveOperationException e) { - throw new IllegalStateException(e); - } - } - } - } \ No newline at end of file