Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-11-07 15:19:45 -0500
committerIgor Fedorenko2011-11-07 15:19:53 -0500
commit67d8ae652fc82525773ea44425538e1db34ea830 (patch)
tree9a45e8253a1cc2f19aad23d56b911f7a4381c410
parent3d354e58f72f7385ed8a3f817cedec61106d32c1 (diff)
downloadm2e-core-67d8ae652fc82525773ea44425538e1db34ea830.tar.gz
m2e-core-67d8ae652fc82525773ea44425538e1db34ea830.tar.xz
m2e-core-67d8ae652fc82525773ea44425538e1db34ea830.zip
362295 expose eclipse builder args to build participants
Eclipse incremental builder args can be accessed via AbstractBuildParticipant2.getArgs. This method returns empty map for build kind == PRECONFIGURE_BUILD. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/InternalBuildParticipant2.java31
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilderImpl.java12
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant.java1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant2.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java3
6 files changed, 58 insertions, 7 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/InternalBuildParticipant2.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/InternalBuildParticipant2.java
new file mode 100644
index 00000000..b42426e3
--- /dev/null
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/InternalBuildParticipant2.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Sonatype, Inc.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.internal.builder;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant;
+
+
+public abstract class InternalBuildParticipant2 extends AbstractBuildParticipant {
+
+ private Map<String, String> args = Collections.emptyMap();
+
+ void setArgs(Map<String, String> args) {
+ this.args = args;
+ }
+
+ protected Map<String, String> getArgs() {
+ return args;
+ }
+}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
index dabc3382..1859c824 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
@@ -55,8 +55,7 @@ public class MavenBuilder extends IncrementalProjectBuilder implements DeltaProv
* @see org.eclipse.core.internal.events.InternalBuilder#build(int,
* java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
- @SuppressWarnings("unchecked")
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+ protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
IProject project = getProject();
log.debug("Building project {}", project.getName()); //$NON-NLS-1$
long start = System.currentTimeMillis();
@@ -115,7 +114,7 @@ public class MavenBuilder extends IncrementalProjectBuilder implements DeltaProv
projectFacade.getResolverConfiguration(), monitor);
MavenSession session = maven.createSession(request, mavenProject);
- Set<IProject> dependencies = builder.build(session, projectFacade, kind, buildParticipantsByMojoExecutionKey,
+ Set<IProject> dependencies = builder.build(session, projectFacade, kind, args, buildParticipantsByMojoExecutionKey,
monitor);
log.debug("Built project {} in {} ms", project.getName(), System.currentTimeMillis() - start); //$NON-NLS-1$
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 104b6616..8f8f0a47 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
@@ -16,6 +16,7 @@ import static org.eclipse.core.resources.IncrementalProjectBuilder.FULL_BUILD;
import static org.eclipse.core.resources.IncrementalProjectBuilder.INCREMENTAL_BUILD;
import java.io.File;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -80,8 +81,8 @@ public class MavenBuilderImpl {
}
public Set<IProject> build(MavenSession session, IMavenProjectFacade projectFacade, int kind,
- Map<MojoExecutionKey, List<AbstractBuildParticipant>> participants, IProgressMonitor monitor)
- throws CoreException {
+ Map<String, String> args, Map<MojoExecutionKey, List<AbstractBuildParticipant>> participants,
+ IProgressMonitor monitor) throws CoreException {
Set<IProject> dependencies = new HashSet<IProject>();
MavenProject mavenProject = projectFacade.getMavenProject();
@@ -89,6 +90,7 @@ public class MavenBuilderImpl {
IResourceDelta delta = getDeltaProvider().getDelta(project);
+ @SuppressWarnings("unchecked")
Map<String, Object> contextState = (Map<String, Object>) project.getSessionProperty(BUILD_CONTEXT_KEY);
AbstractEclipseBuildContext buildContext;
if(delta != null && contextState != null && (INCREMENTAL_BUILD == kind || AUTO_BUILD == kind)) {
@@ -119,6 +121,9 @@ public class MavenBuilderImpl {
participant.setGetDeltaCallback(getDeltaProvider());
participant.setSession(session);
participant.setBuildContext(buildContext);
+ if(participant instanceof InternalBuildParticipant2) {
+ ((InternalBuildParticipant2) participant).setArgs(args);
+ }
long executionStartTime = System.currentTimeMillis();
try {
if(isApplicable(participant, kind, delta)) {
@@ -138,6 +143,9 @@ public class MavenBuilderImpl {
participant.setGetDeltaCallback(null);
participant.setSession(null);
participant.setBuildContext(null);
+ if(participant instanceof InternalBuildParticipant2) {
+ ((InternalBuildParticipant2) participant).setArgs(Collections.<String, String> emptyMap());
+ }
processMavenSessionErrors(session, mojoExecutionKey, buildErrors);
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant.java
index 8ad8543e..5631c6be 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant.java
@@ -75,6 +75,7 @@ public abstract class AbstractBuildParticipant extends InternalBuildParticipant
*
* @param kind the kind of build being requested, {@link #FULL_BUILD}, {@link #AUTO_BUILD} or
* {@link #INCREMENTAL_BUILD}
+ * @noreference this method is not intended to be called by the clients.
*/
public abstract Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception;
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant2.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant2.java
index 9fef9384..2d09ee18 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant2.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractBuildParticipant2.java
@@ -11,11 +11,14 @@
package org.eclipse.m2e.core.project.configurator;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.internal.builder.InternalBuildParticipant2;
+
/**
* Build participant aware of the notion of pre-configuration build.
@@ -31,7 +34,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
*
* @since 1.1
*/
-public abstract class AbstractBuildParticipant2 extends AbstractBuildParticipant {
+public abstract class AbstractBuildParticipant2 extends InternalBuildParticipant2 {
/**
* Build kind constant indicating a pre-configuration build request.
@@ -41,8 +44,16 @@ public abstract class AbstractBuildParticipant2 extends AbstractBuildParticipant
/**
* @param kind the kind of build being requested, {@link #FULL_BUILD}, {@link #AUTO_BUILD}, {@link #INCREMENTAL_BUILD}
* or {@link #PRECONFIGURE_BUILD}.
+ * @noreference this method is not intended to be called by the clients.
*/
@Override
public abstract Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception;
+ /**
+ * Returns a table of builder-specific arguments as described in IncrementalProjectBuilder#build. Always empty map
+ * when kind == {@link #PRECONFIGURE_BUILD}.
+ */
+ protected Map<String, String> getArgs() {
+ return super.getArgs();
+ }
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java
index eaca3664..9676c981 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java
@@ -12,6 +12,7 @@
package org.eclipse.m2e.core.project.configurator;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -98,7 +99,7 @@ public abstract class AbstractLifecycleMapping implements ILifecycleMapping {
}
}
builder.build(request.getMavenSession(), projectFacade, AbstractBuildParticipant2.PRECONFIGURE_BUILD,
- participants, monitor);
+ Collections.<String, String> emptyMap(), participants, monitor);
//perform configuration
for(AbstractProjectConfigurator configurator : getProjectConfigurators(projectFacade, monitor.newChild(1))) {

Back to the top