Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-07-31 03:58:16 -0400
committerIgor Fedorenko2011-07-31 03:58:16 -0400
commitc47e215285d7c562d2e8c98c52a80349abe070b6 (patch)
tree7960aca2bfe35fdf5b1745332a7bb24c1b407dfd
parente288b8a47e935b50a091b259cb96beebbe5c3ee7 (diff)
parent74e41f5cadf4d515ccb47e38a8656a7b111ef457 (diff)
downloadm2e-core-c47e215285d7c562d2e8c98c52a80349abe070b6.tar.gz
m2e-core-c47e215285d7c562d2e8c98c52a80349abe070b6.tar.xz
m2e-core-c47e215285d7c562d2e8c98c52a80349abe070b6.zip
Merge remote-tracking branch 'origin/master' into m2e-self-hosting
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/SelectionUtil.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomEdits.java21
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomHelper.java54
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/markers/MarkerResolutionGenerator.java15
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java28
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertArtifactProposal.java7
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java20
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java31
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java2
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/IClasspathDescriptor.java2
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java79
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java2
13 files changed, 176 insertions, 91 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/SelectionUtil.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/SelectionUtil.java
index 6266dc6c..eb678252 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/SelectionUtil.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/SelectionUtil.java
@@ -325,7 +325,7 @@ public class SelectionUtil {
request.setRecursive(false);
request.setPom(pomFile);
- MavenExecutionResult result = maven.execute(request, monitor);
+ MavenExecutionResult result = maven.readProject(request, monitor);
MavenProject project = result.getProject();
if(project!=null) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomEdits.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomEdits.java
index 8efc3c68..e68e5293 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomEdits.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomEdits.java
@@ -131,7 +131,9 @@ public class PomEdits {
Node child = list.item(i);
if (child instanceof Text) {
Text text = (Text)child;
- buff.append(text.getData());
+ buff.append(text.getData().trim()); //352416 the value is trimmed because of the multiline values
+ //that get trimmed by maven itself as well, any comparison to resolved model needs to do the trimming
+ // or risks false negative results.
}
}
return buff.toString();
@@ -414,9 +416,9 @@ public class PomEdits {
if (tuple.isReadOnly()) {
domModel.releaseFromRead();
} else {
- //for ducuments saving shall only happen when the model is not held elsewhere (eg. in opened view)
+ //for ducuments saving shall generally only happen when the model is not held elsewhere (eg. in opened view)
//for files, save always
- if(tuple.getFile() != null || domModel.getReferenceCountForEdit() == 1) {
+ if(tuple.isForceSave() || domModel.getReferenceCountForEdit() == 1) {
domModel.save();
}
domModel.releaseFromEdit();
@@ -432,6 +434,7 @@ public class PomEdits {
private final IDocument document;
private final IDOMModel model;
private boolean readOnly = false;
+ private boolean forceSave = false;
/**
* operation on top of IFile is always saved
@@ -445,6 +448,7 @@ public class PomEdits {
this.operation = operation;
document = null;
model = null;
+ forceSave = true;
}
/**
* operation on top of IDocument is only saved when noone else is editing the document.
@@ -482,6 +486,17 @@ public class PomEdits {
}
/**
+ * force saving the document after performing the operation
+ */
+ public void setForceSave() {
+ forceSave = true;
+ }
+
+ public boolean isForceSave() {
+ return forceSave;
+ }
+
+ /**
* @return Returns the readOnly.
*/
public boolean isReadOnly() {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomHelper.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomHelper.java
index 00dae4b4..97c765f6 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomHelper.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/PomHelper.java
@@ -8,25 +8,7 @@
package org.eclipse.m2e.core.ui.internal.editing;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.CLASSIFIER;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEPENDENCIES;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEPENDENCY;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.PLUGIN;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.SCOPE;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.TYPE;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.childEquals;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElement;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElementWithText;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChilds;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.format;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.getChild;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeChild;
-import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText;
+import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.*;
import java.util.List;
@@ -37,6 +19,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+
import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
@@ -90,9 +74,17 @@ public final class PomHelper {
}
return false;
}
-
+ /**
+ *
+ * @param file
+ * @param operation
+ * @param label
+ * @param forceSave if true will save all files, no matter if associated document is opened in editor area or not.
+ * @return
+ * @throws CoreException
+ */
@SuppressWarnings("restriction")
- public static TextChange createChange(IFile file, Operation operation, String label) throws CoreException {
+ public static TextChange createChange(IFile file, Operation operation, String label, boolean forceSave) throws CoreException {
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager().getModelForRead(file);
@@ -104,7 +96,13 @@ public final class PomHelper {
IDocument tempDocument = tempModel.getStructuredDocument();
performOnDOMDocument(new OperationTuple((IDOMModel) tempModel, operation));
- return new ChangeCreator(existing ? null : file, document, tempDocument, label).createChange();
+ TextChange change = new ChangeCreator(!forceSave && existing ? null : file, document, tempDocument, label).createChange();
+ if (forceSave) assert change instanceof TextFileChange; //if assert not fullfilled, we will not get the file saved..
+
+ if (forceSave && change instanceof TextFileChange) {
+ ((TextFileChange)change).setSaveMode(TextFileChange.FORCE_SAVE);
+ }
+ return change;
} catch(Exception exc) {
LOG.error(Messages.PomHelper_errorCreatingChange, exc);
throw new CoreException(new Status(IStatus.ERROR, M2EUIPluginActivator.PLUGIN_ID,
@@ -117,6 +115,18 @@ public final class PomHelper {
}
/**
+ * by default will create a change that won't save files with opened documents
+ * @param file
+ * @param operation
+ * @param label
+ * @return
+ * @throws CoreException
+ */
+ public static TextChange createChange(IFile file, Operation operation, String label) throws CoreException {
+ return createChange(file, operation, label, false);
+ }
+
+ /**
* creates and adds new plugin to the parent. Formats the result.
* @param parentList
* @param groupId null or value
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/markers/MarkerResolutionGenerator.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/markers/MarkerResolutionGenerator.java
index d22bf72f..18f66844 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/markers/MarkerResolutionGenerator.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/markers/MarkerResolutionGenerator.java
@@ -53,18 +53,27 @@ public class MarkerResolutionGenerator implements IMarkerResolutionGenerator, IM
//important for 335299
IMarkerResolution[] cached = (IMarkerResolution[]) marker.getResource().getSessionProperty(QUALIFIED);
if (cached == null) {
- cached = new IMarkerResolution[] {new RefreshResolution()};
+ cached = new IMarkerResolution[] {new RefreshResolution(marker)};
marker.getResource().setSessionProperty(QUALIFIED, cached);
}
return cached;
} catch(CoreException e) {
- return new IMarkerResolution[] {new RefreshResolution()};
+ return new IMarkerResolution[] {new RefreshResolution(marker)};
}
}
private class RefreshResolution extends WorkbenchMarkerResolution {
+ private IMarker marker;
+
+ /**
+ * @param marker
+ */
+ public RefreshResolution(IMarker marker) {
+ this.marker = marker;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.IMarkerResolution2#getDescription()
*/
@@ -127,7 +136,7 @@ public class MarkerResolutionGenerator implements IMarkerResolutionGenerator, IM
List<IMarker> toRet = new ArrayList<IMarker>();
for (IMarker m : markers) {
try {
- if (IMavenConstants.MARKER_CONFIGURATION_ID.equals(m.getType())) {
+ if (IMavenConstants.MARKER_CONFIGURATION_ID.equals(m.getType()) && m != marker) {
//TODO is this the only condition for lifecycle markers
toRet.add(m);
}
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 169fa3b8..b08ac264 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
@@ -174,6 +174,7 @@ public class MavenBuilder extends IncrementalProjectBuilder {
participant.setGetDeltaCallback(getDeltaCallback);
participant.setSession(session);
participant.setBuildContext(buildContext);
+ long executionStartTime = System.currentTimeMillis();
try {
if(FULL_BUILD == kind || delta != null || participant.callOnEmptyDelta()) {
Set<IProject> sub = participant.build(kind, monitor);
@@ -185,6 +186,9 @@ public class MavenBuilder extends IncrementalProjectBuilder {
log.debug("Exception in build participant {}", participant.getClass().getName(), e);
buildErrors.put(e, mojoExecutionKey);
} finally {
+ log.debug("Finished executing build participant {} for plugin execution {} in {} ms", new Object[] {
+ participant.getClass().getName(), mojoExecutionKey.toString(),
+ System.currentTimeMillis() - executionStartTime});
participant.setMavenProjectFacade(null);
participant.setGetDeltaCallback(null);
participant.setSession(null);
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 5d35bdb0..056a9d93 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
@@ -20,12 +20,17 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,7 +79,9 @@ import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.lifecycle.internal.DependencyContext;
import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator;
+import org.apache.maven.lifecycle.internal.MojoExecutor;
import org.apache.maven.model.ConfigurationContainer;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Model;
@@ -286,10 +293,31 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
}
public void execute(MavenSession session, MojoExecution execution, IProgressMonitor monitor) {
+ Map<MavenProject, Set<Artifact>> artifacts = new HashMap<MavenProject, Set<Artifact>>();
+ for(MavenProject project : session.getProjects()) {
+ artifacts.put(project, new LinkedHashSet<Artifact>(project.getArtifacts()));
+ }
try {
+ MojoExecutor mojoExecutor = lookup(MojoExecutor.class);
+ DependencyContext dependencyContext = mojoExecutor.newDependencyContext(session,
+ Collections.singletonList(execution));
+
+ // workaround for http://jira.codehaus.org/browse/MNG-5141
+ // use reflection until we can get maven 3.0.4+, which has MNG-5141 fixed
+ Method ensureDependenciesAreResolved = mojoExecutor.getClass().getDeclaredMethod("ensureDependenciesAreResolved",
+ MojoDescriptor.class, MavenSession.class, DependencyContext.class);
+ ensureDependenciesAreResolved.setAccessible(true);
+ ensureDependenciesAreResolved.invoke(mojoExecutor, execution.getMojoDescriptor(), session, dependencyContext);
+
lookup(BuildPluginManager.class).executeMojo(session, execution);
} catch(Exception ex) {
session.getResult().addException(ex);
+ } finally {
+ for(MavenProject project : session.getProjects()) {
+ project.setArtifactFilter(null);
+ project.setResolvedArtifacts(null);
+ project.setArtifacts(artifacts.get(project));
+ }
}
}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertArtifactProposal.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertArtifactProposal.java
index e9e6b570..3587ff0d 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertArtifactProposal.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/InsertArtifactProposal.java
@@ -209,6 +209,13 @@ public class InsertArtifactProposal implements ICompletionProposal, ICompletionP
if (fDialog.getSelectedScope() != null && !"compile".equals(fDialog.getSelectedScope())) {
setText(getChild(dependency, SCOPE), fDialog.getSelectedScope());
}
+ if (af.type != null && !"jar".equals(af.type)
+ && !"null".equals(af.type)) { // guard against MNGECLIPSE-622 //$NON-NLS-1$)
+ setText(getChild(dependency, TYPE), af.type);
+ }
+ if (af.classifier != null) {
+ setText(getChild(dependency, CLASSIFIER), af.classifier);
+ }
format(toFormat);
generatedOffset = ((IndexedRegion)toFormat).getStartOffset();
generatedLength = ((IndexedRegion)toFormat).getEndOffset() - generatedOffset;
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
index b6ff0272..d3c23aae 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
@@ -607,26 +607,6 @@ public class DependenciesComposite extends Composite {
}
- /** mkleint: apparently this methods shall find the version in resolved pom for the given dependency
- * not sure if getBaseVersion is the way to go..
- * Note: duplicated in DependencyDetailsComposite
- * @param groupId
- * @param artifactId
- * @param monitor
- * @return
- */
- String getVersion(String groupId, String artifactId, IProgressMonitor monitor) {
- try {
- MavenProject mavenProject = editorPage.getPomEditor().readMavenProject(false, monitor);
- Artifact a = mavenProject.getArtifactMap().get(groupId + ":" + artifactId); //$NON-NLS-1$
- if(a != null) {
- return a.getBaseVersion();
- }
- } catch(CoreException ex) {
- log.error(ex.getMessage(), ex);
- }
- return null;
- }
public static class DependencyFilter extends ViewerFilter {
private SearchMatcher searchMatcher;
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index ebef4b0f..324f3bdb 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -139,7 +139,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
StructuredTextEditor effectivePomSourcePage;
- List<MavenPomEditorPage> pages = new ArrayList<MavenPomEditorPage>();
+ private List<MavenPomEditorPage> mavenpomEditorPages = new ArrayList<MavenPomEditorPage>();
private Map<String, org.sonatype.aether.graph.DependencyNode> rootNodes = new HashMap<String, org.sonatype.aether.graph.DependencyNode>();
@@ -300,7 +300,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- for(MavenPomEditorPage page : pages) {
+ for(MavenPomEditorPage page : getMavenPomEditorPages()) {
page.setErrorMessage(msg, msg == null ? IMessageProvider.NONE : severity);
}
}
@@ -322,8 +322,11 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
public void reload() {
int active = getActivePage();
- if (active > -1) {
- MavenPomEditorPage page = getPages().get(active);
+ //this code assumes the MavenPomEditorPages are the first ones in the list..
+ //currenty the case, effective+xml editor are at the end..
+ //if this constraint changes, we need to find the active page in the super.pages list first and check for instanceof
+ if (active > -1 && active < getMavenPomEditorPages().size()) {
+ MavenPomEditorPage page = getMavenPomEditorPages().get(active);
page.loadData();
}
if(isEffectiveActive()){
@@ -666,7 +669,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
private int addPomPage(IFormPage page) {
try {
if(page instanceof MavenPomEditorPage) {
- pages.add((MavenPomEditorPage) page);
+ mavenpomEditorPages.add((MavenPomEditorPage) page);
}
if (page instanceof IPomFileChangedListener) {
fileChangeListeners.add((IPomFileChangedListener) page);
@@ -858,8 +861,22 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
return sourcePage.isDirty();
}
+ /**
+ * returns only the pages that implement MavenPomEditorPage
+ * will not return the effective pom and xml editor page for example..
+ * @return
+ */
+ public List<MavenPomEditorPage> getMavenPomEditorPages() {
+ return mavenpomEditorPages;
+ }
+
+ /**
+ * use the <code>getMavenPomEditorPages()</code> method instead
+ * @return
+ */
+ @Deprecated
public List<MavenPomEditorPage> getPages() {
- return pages;
+ return getMavenPomEditorPages();
}
public void showDependencyHierarchy(ArtifactKey artifactKey) {
@@ -1089,7 +1106,7 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
if (getContainer() != null && !getContainer().isDisposed())
getContainer().getDisplay().asyncExec(new Runnable() {
public void run() {
- for (MavenPomEditorPage page : getPages()) {
+ for (MavenPomEditorPage page : getMavenPomEditorPages()) {
page.mavenProjectHasChanged();
}
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
index f5e58998..3ca126af 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
@@ -338,8 +338,8 @@ public abstract class MavenPomEditorPage extends FormPage {
if (getPartControl() != null && !getPartControl().isDisposed()) {
getPartControl().getDisplay().asyncExec(new Runnable() {
public void run() {
- FormHoverProvider.Execute runnable = FormHoverProvider.createHoverRunnable(getManagedForm().getForm().getShell(), markers, getPomEditor().getSourcePage().getTextViewer());
if (!getManagedForm().getForm().isDisposed()) {
+ FormHoverProvider.Execute runnable = FormHoverProvider.createHoverRunnable(getManagedForm().getForm().getShell(), markers, getPomEditor().getSourcePage().getTextViewer());
if (runnable != null) {
FormUtils.setMessageWithPerformer(getManagedForm().getForm(), msg, severity, runnable);
} else {
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/IClasspathDescriptor.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/IClasspathDescriptor.java
index 426dd3aa..9633121d 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/IClasspathDescriptor.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/IClasspathDescriptor.java
@@ -22,7 +22,7 @@ import org.eclipse.m2e.core.project.IMavenProjectFacade;
/**
- * Instances of this class can be used to incrementally define IClasspathEntry[] arrays used by JDT to decribe Java
+ * Instances of this class can be used to incrementally define IClasspathEntry[] arrays used by JDT to describe Java
* Project classpath and contents of Java classpath containers.
*
* @author igor
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java
index 00147116..e0a69e4d 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java
@@ -253,37 +253,41 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
MavenSession mavenSession = request.getMavenSession();
- for(MojoExecution compile : projectFacade.getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
- COMPILER_PLUGIN_ARTIFACT_ID, mon.newChild(1), GOAL_COMPILE)) {
- mainSourceEncoding = maven.getMojoParameterValue(mavenSession, compile, "encoding", String.class); //$NON-NLS-1$
- try {
- inclusion = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
- "includes", String[].class)); //$NON-NLS-1$
- } catch(CoreException ex) {
- log.error("Failed to determine compiler inclusions, assuming defaults", ex);
- }
- try {
- exclusion = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
- "excludes", String[].class)); //$NON-NLS-1$
- } catch(CoreException ex) {
- log.error("Failed to determine compiler exclusions, assuming defaults", ex);
+ List<MojoExecution> executions = getCompilerMojoExecutions(request, mon.newChild(1));
+
+ for(MojoExecution compile : executions) {
+ if(isCompileExecution(compile)) {
+ mainSourceEncoding = maven.getMojoParameterValue(mavenSession, compile, "encoding", String.class); //$NON-NLS-1$
+ try {
+ inclusion = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
+ "includes", String[].class)); //$NON-NLS-1$
+ } catch(CoreException ex) {
+ log.error("Failed to determine compiler inclusions, assuming defaults", ex);
+ }
+ try {
+ exclusion = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
+ "excludes", String[].class)); //$NON-NLS-1$
+ } catch(CoreException ex) {
+ log.error("Failed to determine compiler exclusions, assuming defaults", ex);
+ }
}
}
- for(MojoExecution compile : projectFacade.getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
- COMPILER_PLUGIN_ARTIFACT_ID, mon.newChild(1), GOAL_TESTCOMPILE)) {
- testSourceEncoding = maven.getMojoParameterValue(mavenSession, compile, "encoding", String.class); //$NON-NLS-1$
- try {
- inclusionTest = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
- "testIncludes", String[].class)); //$NON-NLS-1$
- } catch(CoreException ex) {
- log.error("Failed to determine compiler test inclusions, assuming defaults", ex);
- }
- try {
- exclusionTest = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
- "testExcludes", String[].class)); //$NON-NLS-1$
- } catch(CoreException ex) {
- log.error("Failed to determine compiler test exclusions, assuming defaults", ex);
+ for(MojoExecution compile : executions) {
+ if(isTestCompileExecution(compile)) {
+ testSourceEncoding = maven.getMojoParameterValue(mavenSession, compile, "encoding", String.class); //$NON-NLS-1$
+ try {
+ inclusionTest = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
+ "testIncludes", String[].class)); //$NON-NLS-1$
+ } catch(CoreException ex) {
+ log.error("Failed to determine compiler test inclusions, assuming defaults", ex);
+ }
+ try {
+ exclusionTest = toPaths(maven.getMojoParameterValue(request.getMavenSession(), compile,
+ "testExcludes", String[].class)); //$NON-NLS-1$
+ } catch(CoreException ex) {
+ log.error("Failed to determine compiler test exclusions, assuming defaults", ex);
+ }
}
}
@@ -311,6 +315,14 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
}
}
+ protected boolean isTestCompileExecution(MojoExecution execution) {
+ return GOAL_TESTCOMPILE.equals(execution.getGoal());
+ }
+
+ protected boolean isCompileExecution(MojoExecution execution) {
+ return GOAL_COMPILE.equals(execution.getGoal());
+ }
+
private IPath[] toPaths(String[] values) {
if(values == null) {
return new IPath[0];
@@ -410,12 +422,9 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
String source = null, target = null;
- for(MojoExecution execution : request.getMavenProjectFacade().getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
- COMPILER_PLUGIN_ARTIFACT_ID, monitor, GOAL_COMPILE, GOAL_TESTCOMPILE)) {
-
+ for(MojoExecution execution : getCompilerMojoExecutions(request, monitor)) {
source = getCompilerLevel(mavenSession, execution, "source", source, SOURCES); //$NON-NLS-1$
target = getCompilerLevel(mavenSession, execution, "target", target, TARGETS); //$NON-NLS-1$
-
}
if(source == null) {
@@ -434,6 +443,12 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
options.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, "warning"); //$NON-NLS-1$
}
+ protected List<MojoExecution> getCompilerMojoExecutions(ProjectConfigurationRequest request, IProgressMonitor monitor)
+ throws CoreException {
+ return request.getMavenProjectFacade().getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
+ COMPILER_PLUGIN_ARTIFACT_ID, monitor, GOAL_COMPILE, GOAL_TESTCOMPILE);
+ }
+
private String getCompilerLevel(MavenSession session, MojoExecution execution, String parameter, String source,
List<String> levels) {
int levelIdx = getLevelIndex(source, levels);
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java
index 93260fa2..938ec521 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java
@@ -139,7 +139,7 @@ public class MavenRuntimeClasspathProvider extends StandardClasspathProvider {
IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
MavenJdtPlugin plugin = MavenJdtPlugin.getDefault();
IClasspathManager buildpathManager = plugin.getBuildpathManager();
- IClasspathEntry[] cp = buildpathManager.getClasspath(javaProject.getProject(), scope, false, new NullProgressMonitor());
+ IClasspathEntry[] cp = buildpathManager.getClasspath(javaProject.getProject(), scope, false, monitor);
for(IClasspathEntry entry : cp) {
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_PROJECT:

Back to the top