Author: stefanegli Date: Fri Sep 13 07:08:43 2013 New Revision: 1522796 URL: http://svn.apache.org/r1522796 Log: SLING-3056 : removed another usage of m2e in eclipse-ui, replaced using a dom, plus moved EmbeddedArchetypeInstaller to eclipse-m2e-ui
Added: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java - copied, changed from r1522621, sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/EmbeddedArchetypeInstaller.java Removed: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/EmbeddedArchetypeInstaller.java Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java sling/trunk/tooling/ide/eclipse-ui/pom.xml Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java?rev=1522796&r1=1522795&r2=1522796&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java (original) +++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java Fri Sep 13 07:08:43 2013 @@ -16,7 +16,12 @@ */ package org.apache.sling.ide.eclipse.core.internal; -import org.apache.maven.model.Model; +import java.io.IOException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -25,21 +30,63 @@ import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.m2e.core.MavenPlugin; 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.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; public class ProjectHelper { public static boolean isPotentialBundleProject(IProject project) { - Model mavenModel = getMavenModel(project); - return (mavenModel!=null && "bundle".equals(mavenModel.getPackaging())); + String packaging = getMavenProperty(project, "packaging"); + return (packaging!=null && "bundle".equals(packaging)); } public static boolean isPotentialContentProject(IProject project) { - Model mavenModel = ProjectHelper.getMavenModel(project); - return (mavenModel!=null && "content-package".equals(mavenModel.getPackaging())); + String packaging = getMavenProperty(project, "packaging"); + return (packaging!=null && "content-package".equals(packaging)); + } + + public static String getMavenProperty(IProject project, String name) { + try{ + DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + IFile file = project.getFile("pom.xml"); + if (file==null || !file.exists()) { + return null; + } + Document document = docBuilder.parse(file.getContents()); + Element docElement = document.getDocumentElement(); + NodeList children = docElement.getChildNodes(); + for(int i=0; i<children.getLength(); i++) { + Node aChild = children.item(i); + if (aChild.getNodeName().equals(name)) { + Element e = (Element) aChild; + String text = e.getTextContent(); + return text; + } + } + } catch (ParserConfigurationException e) { + //TODO proper logging + e.printStackTrace(); + return null; + } catch (SAXException e) { + //TODO proper logging + e.printStackTrace(); + return null; + } catch (IOException e) { + //TODO proper logging + e.printStackTrace(); + return null; + } catch (CoreException e) { + //TODO proper logging + e.printStackTrace(); + return null; + } + return null; } public static boolean isBundleProject(IProject project) { @@ -75,19 +122,4 @@ public class ProjectHelper { } } - public static Model getMavenModel(IProject project) { - IFile pomFile = project.getFile("pom.xml"); - if (!pomFile.exists()) { - return null; - } - try { - Model model = MavenPlugin.getMavenModelManager().readMavenModel(pomFile); - return model; - } catch (CoreException e) { - // TODO proper logging - e.printStackTrace(); - return null; - } - } - } Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF?rev=1522796&r1=1522795&r2=1522796&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF (original) +++ sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF Fri Sep 13 07:08:43 2013 @@ -11,11 +11,19 @@ Import-Package: org.apache.commons.httpc org.apache.commons.httpclient.methods;version="3.1.0", org.apache.commons.httpclient.methods.multipart;version="3.1.0", org.apache.commons.httpclient.params;version="3.1.0", + org.apache.maven, + org.apache.maven.archetype, org.apache.maven.archetype.catalog, org.apache.maven.archetype.metadata, + org.apache.maven.artifact, + org.apache.maven.artifact.handler, + org.apache.maven.artifact.installer, org.apache.maven.artifact.repository, + org.apache.maven.execution, org.apache.maven.model, + org.apache.maven.plugin, org.apache.sling.ide.eclipse.core, + org.codehaus.plexus, org.eclipse.core.resources, org.eclipse.core.runtime;version="3.4.0", org.eclipse.core.runtime.jobs, @@ -31,6 +39,7 @@ Import-Package: org.apache.commons.httpc org.eclipse.m2e.core.embedder, org.eclipse.m2e.core.internal, org.eclipse.m2e.core.internal.archetype, + org.eclipse.m2e.core.internal.embedder, org.eclipse.m2e.core.project, org.eclipse.swt, org.eclipse.swt.events, @@ -41,7 +50,8 @@ Import-Package: org.apache.commons.httpc org.eclipse.ui.progress, org.eclipse.wst.common.project.facet.core, org.eclipse.wst.server.core, - org.osgi.framework;version="1.6.0" + org.osgi.framework;version="1.6.0", + org.sonatype.aether Bundle-ActivationPolicy: lazy Service-Component: OSGI-INF/*.xml Export-Package: org.apache.sling.ide.eclipse.ui.wizards.np Copied: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java (from r1522621, sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/EmbeddedArchetypeInstaller.java) URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java?p2=sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java&p1=sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/EmbeddedArchetypeInstaller.java&r1=1522621&r2=1522796&rev=1522796&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/EmbeddedArchetypeInstaller.java (original) +++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java Fri Sep 13 07:08:43 2013 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sling.ide.eclipse.core; +package org.apache.sling.ide.eclipse.m2e; import java.io.File; import java.io.FileInputStream; Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java?rev=1522796&r1=1522795&r2=1522796&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java (original) +++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java Fri Sep 13 07:08:43 2013 @@ -20,7 +20,7 @@ import java.io.IOException; import java.net.URL; import org.apache.maven.archetype.catalog.Archetype; -import org.apache.sling.ide.eclipse.core.EmbeddedArchetypeInstaller; +import org.apache.sling.ide.eclipse.m2e.EmbeddedArchetypeInstaller; import org.apache.sling.ide.eclipse.m2e.internal.Activator; import org.apache.sling.ide.eclipse.m2e.internal.SharedImages; import org.eclipse.jface.resource.ImageDescriptor; Modified: sling/trunk/tooling/ide/eclipse-ui/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/pom.xml?rev=1522796&r1=1522795&r2=1522796&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-ui/pom.xml (original) +++ sling/trunk/tooling/ide/eclipse-ui/pom.xml Fri Sep 13 07:08:43 2013 @@ -19,81 +19,4 @@ </excludes> </resource> </resources> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <version>2.8</version> - <executions> - <execution> - <id>copy</id> - <phase>compile</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.tooling.support.install</artifactId> - <version>0.0.1-SNAPSHOT</version> - <overWrite>false</overWrite> - <outputDirectory>${project.build.directory}/sling-tooling-support-install</outputDirectory> - </artifactItem> - <artifactItem> - <groupId>org.apache.sling</groupId> - <artifactId>sling-bundle-archetype</artifactId> - <version>1.0.1-SNAPSHOT</version> - <overWrite>false</overWrite> - <outputDirectory>${project.build.directory}/archetypes</outputDirectory> - </artifactItem> - <artifactItem> - <groupId>org.apache.sling</groupId> - <artifactId>sling-bundle-archetype</artifactId> - <version>1.0.1-SNAPSHOT</version> - <type>pom</type> - <overWrite>false</overWrite> - <outputDirectory>${project.build.directory}/archetypes</outputDirectory> - </artifactItem> - </artifactItems> - <overWriteReleases>false</overWriteReleases> - <overWriteSnapshots>true</overWriteSnapshots> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.apache.maven.plugins - </groupId> - <artifactId> - maven-dependency-plugin - </artifactId> - <versionRange>[2.8,)</versionRange> - <goals> - <goal>copy</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore></ignore> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> </build></project>