You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2016/11/02 15:07:01 UTC

svn commit: r1767698 - in /sling/trunk/tooling/ide: eclipse-m2e-test/META-INF/ eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/ eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/ eclipse-test/src/org/apache/sling/ide/test/im...

Author: rombert
Date: Wed Nov  2 15:07:01 2016
New Revision: 1767698

URL: http://svn.apache.org/viewvc?rev=1767698&view=rev
Log:
SLING-6112 - Make Sling IDE independent of m2e-tycho 

Create a MavenProjectAdapter in eclipse-m2e-test to make it easier to
test Maven projects.

Added:
    sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/
    sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/
    sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/MavenProjectAdapter.java
Modified:
    sling/trunk/tooling/ide/eclipse-m2e-test/META-INF/MANIFEST.MF
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ProjectAdapter.java

Modified: sling/trunk/tooling/ide/eclipse-m2e-test/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-test/META-INF/MANIFEST.MF?rev=1767698&r1=1767697&r2=1767698&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-test/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-test/META-INF/MANIFEST.MF Wed Nov  2 15:07:01 2016
@@ -4,5 +4,23 @@ Bundle-Name: Sling IDE Tools: Eclipse M2
 Bundle-SymbolicName: org.apache.sling.ide.eclipse-m2e-test
 Bundle-Version: 1.1.1.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Require-Bundle: org.junit
+Require-Bundle: org.junit,
+  org.eclipse.m2e.core,
+  org.eclipse.m2e.launching,
+  org.eclipse.m2e.jdt,
+  org.eclipse.m2e.core.ui,
+  org.eclipse.m2e.discovery,
+  org.eclipse.m2e.editor,
+  org.eclipse.m2e.editor.xml,
+  org.eclipse.m2e.maven.indexer,
+  org.eclipse.m2e.archetype.common,
+  org.eclipse.m2e.profiles.ui,
+  org.eclipse.m2e.scm,
+  org.eclipse.m2e.maven.runtime,
+  org.eclipse.m2e.lifecyclemapping.defaults,
+  org.eclipse.m2e.model.edit,
+  org.eclipse.m2e.maven.runtime.slf4j.simple,
+  org.eclipse.m2e.refactoring,
+  org.eclipse.m2e.profiles.core
 Fragment-Host: org.apache.sling.ide.eclipse-m2e-ui
+Import-Package: org.apache.sling.ide.test.impl.helpers

Added: sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/MavenProjectAdapter.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/MavenProjectAdapter.java?rev=1767698&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/MavenProjectAdapter.java (added)
+++ sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/impl/helpers/MavenProjectAdapter.java Wed Nov  2 15:07:01 2016
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.eclipse.m2e.impl.helpers;
+
+import java.util.concurrent.Callable;
+
+import org.apache.sling.ide.test.impl.helpers.Poller;
+import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.ui.internal.actions.EnableNatureAction;
+import org.hamcrest.CoreMatchers;
+
+public class MavenProjectAdapter extends ProjectAdapter {
+
+    public MavenProjectAdapter(IProject project) {
+        super(project);
+    }
+
+    /**
+     * Converts the wrapped project to a Maven project
+     * 
+     * <p>It waits for for the conversion to succeed, and fails with an unchecked exception
+     * if the conversion does not succeed in the allocated time.</p>
+     * 
+     * @throws CoreException
+     * @throws InterruptedException
+     */
+    public void convertToMavenProject() throws CoreException, InterruptedException {
+
+        EnableNatureAction action = new EnableNatureAction();
+        action.selectionChanged(null, new StructuredSelection(getProject()));
+        action.run(null);
+        
+        new Poller().pollUntil(new Callable<Boolean> () {
+            @Override
+            public Boolean call() throws Exception {
+                return getProject().hasNature(IMavenConstants.NATURE_ID);
+            }
+            
+        }, CoreMatchers.equalTo(true));
+    }
+
+}

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ProjectAdapter.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ProjectAdapter.java?rev=1767698&r1=1767697&r2=1767698&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ProjectAdapter.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ProjectAdapter.java Wed Nov  2 15:07:01 2016
@@ -222,4 +222,7 @@ public class ProjectAdapter {
         }
     }
 
+    protected IProject getProject() {
+        return project;
+    }
 }