Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2018-11-15 09:40:19 -0500
committerMickael Istria2018-11-21 18:28:58 -0500
commit3286bf1719a34397c694ad67e9353913cb888865 (patch)
tree54db856de990b1273a2293dcdf0a227d2d611bc7
parentf69fa0086effca3438f750cba9ce6660b8d0c067 (diff)
downloadm2e-core-3286bf1719a34397c694ad67e9353913cb888865.tar.gz
m2e-core-3286bf1719a34397c694ad67e9353913cb888865.tar.xz
m2e-core-3286bf1719a34397c694ad67e9353913cb888865.zip
Bug 515668 - [Preliminary] Make ICallable a @FunctionalInterface
Change-Id: I2ec68584690f0b41c534aee857e6b17889135a10 Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/ICallable.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java53
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java27
3 files changed, 28 insertions, 56 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/ICallable.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/ICallable.java
index 39e90541..5cd392b7 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/ICallable.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/ICallable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Igor Fedorenko
+ * Copyright (c) 2013, 2018 Igor Fedorenko and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Igor Fedorenko - initial API and implementation
+ * Mickael Istria (Red Hat Inc.) - @FunctionInterface
*******************************************************************************/
package org.eclipse.m2e.core.embedder;
@@ -19,6 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
* @see IMavenExecutionContext
* @since 1.4
*/
+@FunctionalInterface
public interface ICallable<V> {
V call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
index a4221c7b..344ff5ea 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
@@ -387,11 +387,8 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
public MavenExecutionPlan calculateExecutionPlan(final MavenProject project, final List<String> goals,
final boolean setup, final IProgressMonitor monitor) throws CoreException {
- return context().execute(project, new ICallable<MavenExecutionPlan>() {
- public MavenExecutionPlan call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
- return calculateExecutionPlan(context.getSession(), project, goals, setup, monitor);
- }
- }, monitor);
+ return context().execute(project,
+ (context, pm) -> calculateExecutionPlan(context.getSession(), project, goals, setup, pm), monitor);
}
@SuppressWarnings("deprecation")
@@ -415,11 +412,8 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
public MojoExecution setupMojoExecution(final MavenProject project, final MojoExecution execution,
IProgressMonitor monitor) throws CoreException {
- return context().execute(project, new ICallable<MojoExecution>() {
- public MojoExecution call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
- return setupMojoExecution(context.getSession(), project, execution);
- }
- }, monitor);
+ return context().execute(project, (context, pm) -> setupMojoExecution(context.getSession(), project, execution),
+ monitor);
}
public ArtifactRepository getLocalRepository() throws CoreException {
@@ -591,8 +585,7 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
}
public MavenProject readProject(final File pomFile, IProgressMonitor monitor) throws CoreException {
- return context().execute(new ICallable<MavenProject>() {
- public MavenProject call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
+ return context().execute((context, pm) -> {
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(context.getExecutionRequest());
try {
lookup(MavenExecutionRequestPopulator.class).populateDefaults(request);
@@ -607,7 +600,6 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1,
Messages.MavenImpl_error_read_project, ex));
}
- }
}, monitor);
}
@@ -704,12 +696,8 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
}
public MavenProject resolveParentProject(final MavenProject child, IProgressMonitor monitor) throws CoreException {
- return context().execute(child, new ICallable<MavenProject>() {
- public MavenProject call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
- return resolveParentProject(context.getRepositorySession(), child, context.getExecutionRequest()
- .getProjectBuildingRequest());
- }
- }, monitor);
+ return context().execute(child, (context, pm) -> resolveParentProject(context.getRepositorySession(), child,
+ context.getExecutionRequest().getProjectBuildingRequest()), monitor);
}
public Artifact resolve(String groupId, String artifactId, String version, String type, String classifier,
@@ -740,8 +728,7 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
}
final List<ArtifactRepository> _remoteRepositories = remoteRepositories;
- return context().execute(new ICallable<Artifact>() {
- public Artifact call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
+ return context().execute((context, pm) -> {
org.eclipse.aether.RepositorySystem repoSystem = lookup(org.eclipse.aether.RepositorySystem.class);
ArtifactRequest request = new ArtifactRequest();
@@ -778,8 +765,7 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
}
return artifact;
- }
- }, monitor);
+ }, monitor);
}
public Artifact resolvePluginArtifact(Plugin plugin, List<ArtifactRepository> remoteRepositories,
@@ -954,11 +940,8 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
public <T> T getMojoParameterValue(final MavenProject project, final MojoExecution mojoExecution,
final String parameter, final Class<T> asType, final IProgressMonitor monitor) throws CoreException {
- return context().execute(project, new ICallable<T>() {
- public T call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
- return getMojoParameterValue(context.getSession(), mojoExecution, parameter, asType);
- }
- }, monitor);
+ return context().execute(project,
+ (context, pm) -> getMojoParameterValue(context.getSession(), mojoExecution, parameter, asType), monitor);
}
@SuppressWarnings("deprecation")
@@ -1026,11 +1009,9 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
public <T> T getMojoParameterValue(final MavenProject project, final String parameter, final Class<T> type,
final Plugin plugin, final ConfigurationContainer configuration, final String goal, IProgressMonitor monitor)
throws CoreException {
- return context().execute(project, new ICallable<T>() {
- public T call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
- return getMojoParameterValue(parameter, type, context.getSession(), plugin, configuration, goal);
- }
- }, monitor);
+ return context().execute(project,
+ (context, pm) -> getMojoParameterValue(parameter, type, context.getSession(), plugin, configuration, goal),
+ monitor);
}
public ArtifactRepository createArtifactRepository(String id, String url) throws CoreException {
@@ -1357,11 +1338,9 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
public void execute(final MavenProject project, final MojoExecution execution, final IProgressMonitor monitor)
throws CoreException {
- context().execute(project, new ICallable<Void>() {
- public Void call(IMavenExecutionContext context, IProgressMonitor monitor) {
- execute(context.getSession(), execution, monitor);
+ context().execute(project, (context, pm) -> {
+ execute(context.getSession(), execution, pm);
return null;
- }
}, monitor);
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
index b2d09bda..3c979609 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
@@ -267,11 +267,9 @@ public class ProjectRegistryManager {
* {@link #refresh(Set, IProgressMonitor)} instead.
*/
public void refresh(final MavenUpdateRequest request, final IProgressMonitor monitor) throws CoreException {
- getMaven().execute(request.isOffline(), request.isForceDependencyUpdate(), new ICallable<Void>() {
- public Void call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
+ getMaven().execute(request.isOffline(), request.isForceDependencyUpdate(), (context, pm) -> {
refresh(request.getPomFiles(), monitor);
return null;
- }
}, monitor);
}
@@ -487,13 +485,10 @@ public class ProjectRegistryManager {
final MavenProjectFacade _newFacade = newFacade;
final MavenProject mavenProject = getMavenProject(newFacade);
final ResolverConfiguration resolverConfiguration = _newFacade.getResolverConfiguration();
- final ICallable<Void> callable = new ICallable<Void>() {
- public Void call(IMavenExecutionContext executionContext, IProgressMonitor monitor) throws CoreException {
- refreshPhase2(newState, context, originalCapabilities, originalRequirements, pom, _newFacade, monitor);
- return null;
- }
- };
- createExecutionContext(newState, pom, resolverConfiguration).execute(mavenProject, callable, monitor);
+ createExecutionContext(newState, pom, resolverConfiguration).execute(mavenProject, (executionContext, pm) -> {
+ refreshPhase2(newState, context, originalCapabilities, originalRequirements, pom, _newFacade, pm);
+ return null;
+ }, monitor);
} else {
refreshPhase2(newState, context, originalCapabilities, originalRequirements, pom, newFacade, monitor);
}
@@ -696,12 +691,12 @@ public class ProjectRegistryManager {
final ResolverConfiguration resolverConfiguration = ResolverConfigurationIO
.readResolverConfiguration(pom.getProject());
- return execute(state, pom, resolverConfiguration, new ICallable<MavenProjectFacade>() {
- public MavenProjectFacade call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
+ return execute(state, pom, resolverConfiguration, (executionContext, pm) -> {
MavenProject mavenProject = null;
MavenExecutionResult mavenResult = null;
if(pom.isAccessible()) {
- mavenResult = getMaven().readMavenProject(pom.getLocation().toFile(), context.newProjectBuildingRequest());
+ mavenResult = getMaven().readMavenProject(pom.getLocation().toFile(),
+ executionContext.newProjectBuildingRequest());
mavenProject = mavenResult.getProject();
}
@@ -718,7 +713,6 @@ public class ProjectRegistryManager {
putMavenProject(mavenProjectFacade, mavenProject); // maintain maven project cache
return mavenProjectFacade;
- }
}, monitor);
}
@@ -808,13 +802,10 @@ public class ProjectRegistryManager {
ResolverConfiguration resolverConfiguration, final IProgressMonitor monitor) {
try {
- return execute(state, pomFile, resolverConfiguration, new ICallable<MavenExecutionResult>() {
- public MavenExecutionResult call(IMavenExecutionContext context, IProgressMonitor monitor)
- throws CoreException {
+ return execute(state, pomFile, resolverConfiguration, (context, pm) -> {
ProjectBuildingRequest configuration = context.newProjectBuildingRequest();
configuration.setResolveDependencies(true);
return getMaven().readMavenProject(pomFile.getLocation().toFile(), configuration);
- }
}, monitor);
} catch(CoreException ex) {
DefaultMavenExecutionResult result = new DefaultMavenExecutionResult();

Back to the top