Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.m2e.core/schema/projectConversionParticipants.exsd8
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/conversion/ProjectConversionManager.java54
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/conversion/IProjectConversionManager.java9
-rw-r--r--org.eclipse.m2e.jdt/plugin.xml3
4 files changed, 32 insertions, 42 deletions
diff --git a/org.eclipse.m2e.core/schema/projectConversionParticipants.exsd b/org.eclipse.m2e.core/schema/projectConversionParticipants.exsd
index fb219cea..74c727c3 100644
--- a/org.eclipse.m2e.core/schema/projectConversionParticipants.exsd
+++ b/org.eclipse.m2e.core/schema/projectConversionParticipants.exsd
@@ -1,4 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.m2e.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
@@ -75,6 +76,13 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="nature" type="string" use="required">
+ <annotation>
+ <documentation>
+ Project nature the converter applies to.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/conversion/ProjectConversionManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/conversion/ProjectConversionManager.java
index 4aca4e07..8b3893d3 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/conversion/ProjectConversionManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/conversion/ProjectConversionManager.java
@@ -8,10 +8,10 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*******************************************************************************/
+
package org.eclipse.m2e.core.internal.project.conversion;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
@@ -31,10 +31,11 @@ import org.apache.maven.model.Model;
import org.eclipse.m2e.core.project.conversion.AbstractProjectConversionParticipant;
import org.eclipse.m2e.core.project.conversion.IProjectConversionManager;
+
/**
* Manages conversion of existing Eclipse projects into Maven ones. <br/>
* Looks up for {@link AbstractProjectConversionParticipant} contributed by 3rd party eclipse plugins.
- *
+ *
* @author Fred Bricon
*/
public class ProjectConversionManager implements IProjectConversionManager {
@@ -43,17 +44,7 @@ public class ProjectConversionManager implements IProjectConversionManager {
private static final Logger log = LoggerFactory.getLogger(ProjectConversionManager.class);
- private List<AbstractProjectConversionParticipant> allParticipants;
-
- public List<AbstractProjectConversionParticipant> getAllConversionParticipants() {
- if (allParticipants == null) {
- allParticipants = lookupConversionParticipants();
- }
- return Collections.unmodifiableList(allParticipants);
- }
-
- private static List<AbstractProjectConversionParticipant> lookupConversionParticipants() {
-
+ private static List<AbstractProjectConversionParticipant> lookupConversionParticipants(IProject project) {
List<AbstractProjectConversionParticipant> participants = new ArrayList<AbstractProjectConversionParticipant>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -63,49 +54,42 @@ public class ProjectConversionManager implements IProjectConversionManager {
for(IExtension extension : archetypesExtensions) {
IConfigurationElement[] elements = extension.getConfigurationElements();
for(IConfigurationElement element : elements) {
- AbstractProjectConversionParticipant participant = readProjectConversionParticipant(element);
- if (participant != null) {
- participants.add(participant);
+ try {
+ if(project.hasNature(element.getAttribute("nature"))) {
+ participants.add((AbstractProjectConversionParticipant) element.createExecutableExtension("class"));
+ }
+ } catch(CoreException ex) {
+ log.debug("Can not load IProjectConversionParticipant", ex);
}
}
}
}
- return Collections.unmodifiableList(participants);
- }
-
- private static AbstractProjectConversionParticipant readProjectConversionParticipant(IConfigurationElement element) {
- AbstractProjectConversionParticipant participant = null;
- try {
- participant = (AbstractProjectConversionParticipant) element.createExecutableExtension("class");
- } catch(CoreException ex) {
- log.error("Can not load IProjectConversionParticipant", ex);
- }
- return participant;
+ return participants;
}
public void convert(IProject project, Model model, IProgressMonitor monitor) throws CoreException {
- if (model == null) {
+ if(model == null) {
return;
}
List<AbstractProjectConversionParticipant> participants = getConversionParticipants(project);
- if (participants != null) {
- for (AbstractProjectConversionParticipant participant : participants) {
+ if(participants != null) {
+ for(AbstractProjectConversionParticipant participant : participants) {
participant.convert(project, model, monitor);
}
}
}
public List<AbstractProjectConversionParticipant> getConversionParticipants(IProject project) throws CoreException {
- List<AbstractProjectConversionParticipant> allParticipants = getAllConversionParticipants();
+ List<AbstractProjectConversionParticipant> allParticipants = lookupConversionParticipants(project);
List<AbstractProjectConversionParticipant> participants = new ArrayList<AbstractProjectConversionParticipant>();
- if (allParticipants != null) {
- for (AbstractProjectConversionParticipant participant : allParticipants) {
- if (participant.accept(project)) {
+ if(allParticipants != null) {
+ for(AbstractProjectConversionParticipant participant : allParticipants) {
+ if(participant.accept(project)) {
participants.add(participant);
}
}
}
return participants;
}
-
+
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/conversion/IProjectConversionManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/conversion/IProjectConversionManager.java
index ca48e5cc..3febc39d 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/conversion/IProjectConversionManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/conversion/IProjectConversionManager.java
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*******************************************************************************/
+
package org.eclipse.m2e.core.project.conversion;
import java.util.List;
@@ -18,9 +19,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.maven.model.Model;
+
/**
* Manages conversion of existing Eclipse projects into Maven ones.
- *
+ *
* @author Fred Bricon
*/
public interface IProjectConversionManager {
@@ -29,11 +31,6 @@ public interface IProjectConversionManager {
* Converts an existing Eclipse project configuration to its Maven Model counterpart
*/
void convert(IProject project, Model model, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Returns an unmodifiable list of all known {@link AbstractProjectConversionParticipant}s
- */
- List<AbstractProjectConversionParticipant> getAllConversionParticipants();
/**
* Returns an unmodifiable list of all {@link AbstractProjectConversionParticipant}s applying to this project
diff --git a/org.eclipse.m2e.jdt/plugin.xml b/org.eclipse.m2e.jdt/plugin.xml
index 6ca863de..710dc209 100644
--- a/org.eclipse.m2e.jdt/plugin.xml
+++ b/org.eclipse.m2e.jdt/plugin.xml
@@ -363,7 +363,8 @@
<projectConversionParticipant
class="org.eclipse.m2e.jdt.internal.JavaProjectConversionParticipant"
id="org.eclipse.m2e.jdt.javaProjectConversionParticipant"
- name="%java.conversion.participant.name" >
+ name="%java.conversion.participant.name"
+ nature="org.eclipse.jdt.core.javanature">
</projectConversionParticipant>
</extension>
</plugin>

Back to the top