Permalink
Browse files

398139 : select proper packaging before conversion

Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information...
1 parent eaa1c7b commit 7c631faa86eada406207d5669b6bdfc8c8b69fb3 @fbricon fbricon committed Dec 28, 2012
View
6 org.eclipse.m2e.wtp.jaxrs.feature/.project
@@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>
View
2 org.eclipse.m2e.wtp.jaxrs.feature/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
View
4 org.eclipse.m2e.wtp.jaxrs.feature/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
View
6 org.eclipse.m2e.wtp.jsf.feature/.project
@@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>
View
2 org.eclipse.m2e.wtp.jsf.feature/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
View
4 org.eclipse.m2e.wtp.jsf.feature/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
View
4 org.eclipse.m2e.wtp.sdk.feature/.project
@@ -6,12 +6,12 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
+ <name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
View
85 org.eclipse.m2e.wtp/plugin.xml
@@ -275,7 +275,36 @@
</extension>
<extension
- point="org.eclipse.m2e.core.projectConversionParticipants">
+ point="org.eclipse.m2e.core.projectConversionParticipants" >
+
+ <!-- m2e 1.3 requires all 3rd party plugins to register compatible packagings -->
+ <conversionParticipantConfiguration
+ conversionParticipantId="org.eclipse.m2e.jdt.javaProjectConversionParticipant"
+ compatiblePackagings="war,ejb,rar,app-client"
+ />
+
+ <conversionParticipantConfiguration
+ conversionParticipantId="org.eclipse.m2e.wtp.conversion.WebProjectConverter"
+ compatiblePackagings="war"
+ />
+ <conversionParticipantConfiguration
+ conversionParticipantId="org.eclipse.m2e.wtp.conversion.EjbProjectConverter"
+ compatiblePackagings="ejb"
+ />
+ <conversionParticipantConfiguration
+ conversionParticipantId="org.eclipse.m2e.wtp.conversion.ConnectorProjectConverter"
+ compatiblePackagings="rar"
+ />
+ <conversionParticipantConfiguration
+ conversionParticipantId="org.eclipse.m2e.wtp.conversion.AppClientProjectConverter"
+ compatiblePackagings="app-client"
+ />
+ <conversionParticipantConfiguration
+ conversionParticipantId="org.eclipse.m2e.wtp.conversion.EarProjectConverter"
+ compatiblePackagings="ear"
+ />
+
+
<projectConversionParticipant
class="org.eclipse.m2e.wtp.internal.conversion.WebProjectConverter"
id="org.eclipse.m2e.wtp.conversion.WebProjectConverter"
@@ -307,33 +336,35 @@
nature="org.eclipse.wst.common.modulecore.ModuleCoreNature">
</projectConversionParticipant>
- <!-- m2e 1.3 requires all 3rd party plugins to register compatible packagings -->
- <conversionParticipantConfiguration
- conversionParticipantId="org.eclipse.m2e.jdt.javaProjectConversionParticipant"
- compatiblePackagings="war,ejb,rar,app-client"
- />
-
- <conversionParticipantConfiguration
- conversionParticipantId="org.eclipse.m2e.wtp.conversion.WebProjectConverter"
- compatiblePackagings="war"
- />
- <conversionParticipantConfiguration
- conversionParticipantId="org.eclipse.m2e.wtp.conversion.EjbProjectConverter"
- compatiblePackagings="ejb"
- />
- <conversionParticipantConfiguration
- conversionParticipantId="org.eclipse.m2e.wtp.conversion.ConnectorProjectConverter"
- compatiblePackagings="rar"
- />
- <conversionParticipantConfiguration
- conversionParticipantId="org.eclipse.m2e.wtp.conversion.AppClientProjectConverter"
- compatiblePackagings="app-client"
- />
- <conversionParticipantConfiguration
- conversionParticipantId="org.eclipse.m2e.wtp.conversion.EarProjectConverter"
- compatiblePackagings="ear"
- />
</extension>
+ <extension
+ point="org.eclipse.m2e.core.conversionEnabler">
+ <enabler
+ class="org.eclipse.m2e.wtp.internal.conversion.WebProjectConversionEnabler"
+ id="org.eclipse.m2e.wtp.conversion.web.enabler"
+ weight="50">
+ </enabler>
+ <enabler
+ class="org.eclipse.m2e.wtp.internal.conversion.EarProjectConversionEnabler"
+ id="org.eclipse.m2e.wtp.conversion.ear.enabler"
+ weight="50">
+ </enabler>
+ <enabler
+ class="org.eclipse.m2e.wtp.internal.conversion.EjbProjectConversionEnabler"
+ id="org.eclipse.m2e.wtp.conversion.ejb.enabler"
+ weight="50">
+ </enabler>
+ <enabler
+ class="org.eclipse.m2e.wtp.internal.conversion.AppClientProjectConversionEnabler"
+ id="org.eclipse.m2e.wtp.conversion.appclient.enabler"
+ weight="50">
+ </enabler>
+ <enabler
+ class="org.eclipse.m2e.wtp.internal.conversion.ConnectorProjectConversionEnabler"
+ id="org.eclipse.m2e.wtp.conversion.connector.enabler"
+ weight="50">
+ </enabler>
+ </extension>
</plugin>
View
56 ...tp/src/org/eclipse/m2e/wtp/internal/conversion/AbstractProjectFacetConversionEnabler.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.wtp.internal.conversion;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.m2e.core.project.conversion.AbstractProjectConversionEnabler;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstract Project Conversion Enabler that accepts a {@link IProject} based on the presence of an {@link IProjectFacet}
+ * on the given project.
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public abstract class AbstractProjectFacetConversionEnabler extends AbstractProjectConversionEnabler {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractProjectFacetConversionEnabler.class);
+
+ private IProjectFacet requiredFacet;
+
+ public AbstractProjectFacetConversionEnabler(IProjectFacet requiredFacet) {
+ this.requiredFacet = requiredFacet;
+ }
+
+ /**
+ * Checks the project has the required {@link IProjectFacet}
+ */
+ public boolean accept(IProject project) {
+ if (project != null) {
+ IFacetedProject facetedProject;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ return facetedProject != null && facetedProject.hasProjectFacet(requiredFacet);
+ } catch(CoreException ex) {
+ LOG.error("Can not accept "+ project.getName(), ex);
+ }
+ }
+ return false;
+ }
+
+
+
+}
View
36 ...2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/AppClientProjectConversionEnabler.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.wtp.internal.conversion;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.m2e.wtp.JEEPackaging;
+
+/**
+ * Enables Maven project conversion on Faceted Application Client projects,
+ * i.e having the {@link IJ2EEFacetConstants.APPLICATION_CLIENT_FACET} Facet.
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public class AppClientProjectConversionEnabler extends AbstractProjectFacetConversionEnabler {
+
+ public AppClientProjectConversionEnabler() {
+ super(IJ2EEFacetConstants.APPLICATION_CLIENT_FACET);
+ }
+
+ /**
+ * Returns the <code>app-client</code> packaging
+ */
+ public String[] getPackagingTypes(IProject project) {
+ return new String[]{JEEPackaging.APP_CLIENT.getName()};
+ }
+}
View
9 ...clipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/AppClientProjectConverter.java
@@ -8,11 +8,9 @@
package org.eclipse.m2e.wtp.internal.conversion;
-import static org.eclipse.m2e.wtp.DomUtils.*;
+import static org.eclipse.m2e.wtp.DomUtils.getOrCreateChildNode;
+
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -27,15 +25,12 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.m2e.wtp.DomUtils;
import org.eclipse.m2e.wtp.WTPProjectsUtil;
-import org.eclipse.ui.ide.ResourceUtil;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
View
36 ...2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/ConnectorProjectConversionEnabler.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.wtp.internal.conversion;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.m2e.wtp.JEEPackaging;
+
+/**
+ * Enables Maven project conversion on Faceted Connector projects,
+ * i.e having the {@link IJ2EEFacetConstants.JCA_FACET} Facet.
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public class ConnectorProjectConversionEnabler extends AbstractProjectFacetConversionEnabler {
+
+ public ConnectorProjectConversionEnabler() {
+ super(IJ2EEFacetConstants.JCA_FACET);
+ }
+
+ /**
+ * Returns the <code>rar</code> packaging
+ */
+ public String[] getPackagingTypes(IProject project) {
+ return new String[]{JEEPackaging.RAR.getName()};
+ }
+}
View
37 ...ipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EarProjectConversionEnabler.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.wtp.internal.conversion;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.m2e.wtp.JEEPackaging;
+
+/**
+ * Enables Maven project conversion on Faceted EAR projects,
+ * i.e having the {@link IJ2EEFacetConstants.ENTERPRISE_APPLICATION_FACET} Facet.
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public class EarProjectConversionEnabler extends AbstractProjectFacetConversionEnabler {
+
+ public EarProjectConversionEnabler() {
+ super(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_FACET);
+ }
+
+ /**
+ * Returns the <code>ear</code> packaging
+ */
+ public String[] getPackagingTypes(IProject project) {
+ return new String[]{JEEPackaging.EAR.getName()};
+ }
+
+}
View
36 ...ipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EjbProjectConversionEnabler.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.wtp.internal.conversion;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.m2e.wtp.JEEPackaging;
+
+/**
+ * Enables Maven project conversion on Faceted EJB projects,
+ * i.e having the {@link IJ2EEFacetConstants.EJB_FACET} Facet.
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public class EjbProjectConversionEnabler extends AbstractProjectFacetConversionEnabler {
+
+ public EjbProjectConversionEnabler() {
+ super(IJ2EEFacetConstants.EJB_FACET);
+ }
+
+ /**
+ * Returns the <code>ejb</code> packaging
+ */
+ public String[] getPackagingTypes(IProject project) {
+ return new String[]{JEEPackaging.EJB.getName()};
+ }
+}
View
2 org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EjbProjectConverter.java
@@ -13,12 +13,10 @@
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
-import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
import org.eclipse.m2e.wtp.WTPProjectsUtil;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
View
36 ...ipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/WebProjectConversionEnabler.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.wtp.internal.conversion;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.m2e.wtp.JEEPackaging;
+
+/**
+ * Enables Maven project conversion on Faceted Dynamic Web projects,
+ * i.e having the {@link IJ2EEFacetConstants.DYNAMIC_WEB_FACET} Facet.
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public class WebProjectConversionEnabler extends AbstractProjectFacetConversionEnabler {
+
+ public WebProjectConversionEnabler() {
+ super(IJ2EEFacetConstants.DYNAMIC_WEB_FACET);
+ }
+
+ /**
+ * Returns the <code>war</code> packaging
+ */
+ public String[] getPackagingTypes(IProject project) {
+ return new String[]{JEEPackaging.WAR.getName()};
+ }
+}
View
4 pom.xml
@@ -29,7 +29,7 @@
<test.timeout>1800</test.timeout><!-- 30 mins -->
<tycho.test.jvmArgs>-Xmx512m -XX:MaxPermSize=256m</tycho.test.jvmArgs>
- <eclipse.target>juno</eclipse.target>
+ <eclipse.target>kepler</eclipse.target>
<eclipse-repo.url>http://download.eclipse.org/releases/${eclipse.target}</eclipse-repo.url>
<webtools-repo.url>http://download.eclipse.org/webtools/repository/${eclipse.target}</webtools-repo.url>
<!-- Warning : changing the mavenarchiver version requires submitting a new CQ in ipzilla -->
@@ -93,7 +93,7 @@
<repository>
<id>m2e-core</id>
<layout>p2</layout>
- <url>http://download.eclipse.org/technology/m2e/milestones/1.2/</url>
+ <url>http://download.eclipse.org/technology/m2e/milestones/1.3/</url>
</repository>
<repository>
<id>mavenarchiver</id>

0 comments on commit 7c631fa

Please sign in to comment.