Author: kwin
Date: Thu Oct 20 09:07:31 2016
New Revision: 1765778

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

detect if incremental generation of manifest and service definitions is enabled 
through according maven plugins and generate an error marker otherwise (with 
according quick-fixes)

SLING-6128 remove lifecycle-mapping for content-package
SLING-6129 support bnd-maven-plugin

Added:
    
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectNotSupportingM2EIncrementalBuildQuickFix.java
   (with props)
Removed:
    
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/ContentPackageLifecycleMapping.java
Modified:
    sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF
    sling/trunk/tooling/ide/eclipse-m2e-ui/lifecycle-mapping-metadata.xml
    sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml
    
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectConfigurator.java
    sling/trunk/tooling/ide/m2e-feature/feature.xml
    sling/trunk/tooling/ide/p2update/pom.xml
    
sling/trunk/tooling/ide/target-definition/org.apache.sling.ide.target-definition.target

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=1765778&r1=1765777&r2=1765778&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 Thu Oct 20 
09:07:31 2016
@@ -9,7 +9,8 @@ Bundle-ClassPath: .
 Require-Bundle: org.eclipse.m2e.core;bundle-version="1.4.0",
  org.eclipse.m2e.archetype.common;bundle-version="1.4.0",
  org.eclipse.m2e.maven.runtime;bundle-version="1.4.0",
- org.eclipse.jst.j2ee 
+ org.eclipse.jst.j2ee,
+ org.eclipse.m2e.discovery;bundle-version="1.4.0"
 Import-Package: org.apache.commons.httpclient;version="3.1.0",
  org.apache.commons.httpclient.auth;version="3.1.0",
  org.apache.commons.httpclient.methods;version="3.1.0",
@@ -44,10 +45,12 @@ Import-Package: org.apache.commons.httpc
  org.eclipse.jst.j2ee.web.project.facet,
  org.eclipse.swt,
  org.eclipse.swt.events,
+ org.eclipse.swt.graphics,
  org.eclipse.swt.layout,
  org.eclipse.swt.widgets,
  org.eclipse.ui,
  org.eclipse.ui.actions,
+ org.eclipse.ui.browser,
  org.eclipse.ui.plugin,
  org.eclipse.ui.progress,
  org.eclipse.wst.common.frameworks.datamodel,

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/lifecycle-mapping-metadata.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/lifecycle-mapping-metadata.xml?rev=1765778&r1=1765777&r2=1765778&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/lifecycle-mapping-metadata.xml 
(original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/lifecycle-mapping-metadata.xml Thu 
Oct 20 09:07:31 2016
@@ -1,21 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
+<!-- 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. -->
 <lifecycleMappingMetadata>
+
+    <lifecycleMappings>
+        <!-- maven-bundle-plugin packaging types should be configured just 
+            as a regular JAR, this binds the regular JDT Project Configurator 
(defined 
+            by org.eclipse.m2e.jdt in 
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/plugin.xml?id=55d285f37094796395b3801b56405b25d6603824)
 -->
+        <lifecycleMapping>
+            <packagingType>bundle</packagingType>
+            
<lifecycleMappingId>org.eclipse.m2e.jdt.JarLifecycleMapping</lifecycleMappingId>
+        </lifecycleMapping>
+    </lifecycleMappings>
     <pluginExecutions>
         <pluginExecution>
             <pluginExecutionFilter>
@@ -28,52 +32,88 @@
                 </goals>
             </pluginExecutionFilter>
             <action>
+                <!-- bind primary configurator also to m-b-p goals, otherwise 
secondaryTo attribute does not work, if the primary configurator is only bound 
to another plugin execution) -->
+                <configurator>
+                    <id>org.eclipse.m2e.jdt.javaConfigurator</id>
+                </configurator>
+            </action>
+        </pluginExecution>
+        <pluginExecution>
+            <pluginExecutionFilter>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <versionRange>[1.0.0,)</versionRange>
+                <goals>
+                    <goal>manifest</goal>
+                    <goal>bundle</goal>
+                </goals>
+            </pluginExecutionFilter>
+            <action>
+                <configurator>
+                    
<id>org.apache.sling.ide.eclipse.m2e.bundleconfigurator</id>
+                </configurator>
+            </action>
+        </pluginExecution>
+        <pluginExecution>
+            <pluginExecutionFilter>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-maven-plugin</artifactId>
+                <versionRange>[2.4.1,)</versionRange>
+                <goals>
+                    <goal>bnd-process</goal>
+                </goals>
+            </pluginExecutionFilter>
+            <action>
+                <!-- bind primary configurator also to m-b-p goals, otherwise 
secondaryTo attribute does not work, if the primary configurator is only bound 
to another plugin execution) -->
+                <configurator>
+                    <id>org.eclipse.m2e.jdt.javaConfigurator</id>
+                </configurator>
+            </action>
+        </pluginExecution>
+        <pluginExecution>
+            <pluginExecutionFilter>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-maven-plugin</artifactId>
+                <versionRange>[2.4.1,)</versionRange>
+                <goals>
+                    <goal>bnd-process</goal>
+                </goals>
+            </pluginExecutionFilter>
+            <action>
                 <configurator>
                     
<id>org.apache.sling.ide.eclipse.m2e.bundleconfigurator</id>
                 </configurator>
             </action>
         </pluginExecution>
+        <pluginExecution>
+            <pluginExecutionFilter>
+                <groupId>com.day.jcr.vault</groupId>
+                <artifactId>content-package-maven-plugin</artifactId>
+                <versionRange>[0.0.10,2)</versionRange>
+                <goals>
+                    <goal>package</goal>
+                </goals>
+            </pluginExecutionFilter>
+            <action>
+                <configurator>
+                    <id>org.apache.sling.ide.eclipse.m2e.configurator</id>
+                </configurator>
+            </action>
+        </pluginExecution>
+        <pluginExecution>
+            <pluginExecutionFilter>
+                <groupId>com.day.jcr.vault</groupId>
+                <artifactId>content-package-maven-plugin</artifactId>
+                <versionRange>[0.0.10,2)</versionRange>
+                <goals>
+                    <goal>install</goal>
+                </goals>
+            </pluginExecutionFilter>
+            <action>
+                <ignore>
+                    <message>content-package-maven-plugin goal "install" is 
ignored</message>
+                </ignore>
+            </action>
+        </pluginExecution>
     </pluginExecutions>
-  
-  <lifecycleMappings>
-    <lifecycleMapping>
-      <packagingType>content-package</packagingType>
-      
<lifecycleMappingId>org.apache.sling.ide.eclipse.m2e.contentPackageLifecycleMapping</lifecycleMappingId>
-      <pluginExecutions>
-        <pluginExecution>
-          <pluginExecutionFilter>
-            <groupId>com.day.jcr.vault</groupId>
-            <artifactId>content-package-maven-plugin</artifactId>
-            <versionRange>[0.0.10,2)</versionRange>
-            <goals>
-              <goal>package</goal>
-            </goals>
-          </pluginExecutionFilter>
-          <action>
-            <configurator>
-              <id>org.apache.sling.ide.eclipse.m2e.configurator</id>
-            </configurator>
-          </action>
-        </pluginExecution>
-           
-        <pluginExecution>
-          <pluginExecutionFilter>
-          
-            <groupId>com.day.jcr.vault</groupId>
-            <artifactId>content-package-maven-plugin</artifactId>
-            <versionRange>[0.0.10,2)</versionRange>
-            <goals>
-              <goal>install</goal>
-            </goals>
-          </pluginExecutionFilter>
-          <action>
-           <ignore>
-               <message>content-package-maven-plugin goal "install" is 
ignored</message>
-           </ignore>
-          </action>
-        </pluginExecution>
-      </pluginExecutions>
-    </lifecycleMapping>
-    
-  </lifecycleMappings>    
 </lifecycleMappingMetadata>
\ No newline at end of file

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml?rev=1765778&r1=1765777&r2=1765778&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml Thu Oct 20 09:07:31 2016
@@ -47,25 +47,45 @@
 
     <extension
             point="org.eclipse.m2e.core.projectConfigurators">
+        <!-- make sure this runs after the default java configurator, being 
provided by 
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/plugin.xml#n42
  -->
+        <!-- the secondaryTo does only work in case the according configurator 
is bound to the same plugin execution -->
         <configurator
                 
class="org.apache.sling.ide.eclipse.m2e.internal.BundleProjectConfigurator"
                 id="org.apache.sling.ide.eclipse.m2e.bundleconfigurator"
                 name="Sling Bundle Configurator"
-                secondaryTo="maven-bundle-plugin">
+                secondaryTo="org.eclipse.m2e.jdt.javaConfigurator">
         </configurator>
         <configurator 
                 id="org.apache.sling.ide.eclipse.m2e.configurator"
                 
class="org.apache.sling.ide.eclipse.m2e.internal.ContentPackageProjectConfigurator"
-                name="Sling Content Package Configurator" />        
+                name="Sling Content Package Configurator" />
     </extension>
     
-    <extension point="org.eclipse.m2e.core.lifecycleMappings">  
-           <lifecycleMapping
-             
id="org.apache.sling.ide.eclipse.m2e.contentPackageLifecycleMapping"
-                   
class="org.apache.sling.ide.eclipse.m2e.internal.ContentPackageLifecycleMapping"
-                   name="Sling Content Content Package Build Lifecycle 
Mapping">
-           </lifecycleMapping>            
-    </extension>         
+    <!-- custom marker used in the BundleProjectConfigurator, see 
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_markers.htm
 -->
+   <extension point="org.eclipse.core.resources.markers"
+         id="bundleprojectnotsupportingm2e" 
+         name="Bundle Project Not Supporting M2E">
+      <super type="org.eclipse.core.resources.problemmarker"/>
+      <persistent value="true"/>
+   </extension>
+    
+    <extension
+         point="org.eclipse.ui.ide.markerSupport">
+        <markerTypeCategory
+              name="Sling IDE">
+           <markerTypeReference
+               
id="org.apache.sling.ide.eclipse-m2e-ui.bundleprojectnotsupportingm2e">
+           </markerTypeReference>
+       </markerTypeCategory>
+   </extension>
+    
+    
<!--https://wiki.eclipse.org/FAQ_How_do_I_implement_Quick_Fixes_for_my_own_language%3F
 -->
+    <extension point="org.eclipse.ui.ide.markerResolution">
+      <markerResolutionGenerator
+         
markerType="org.apache.sling.ide.eclipse-m2e-ui.bundleprojectnotsupportingm2e"
+         
class="org.apache.sling.ide.eclipse.m2e.internal.BundleProjectNotSupportingM2EIncrementalBuildQuickFix"/>
+   </extension>
+    
        <extension point="org.eclipse.m2e.core.archetypeCatalogs">
                <remote url="http://repo1.maven.org/maven2/";
                        description="Maven Central"/>

Modified: 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectConfigurator.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectConfigurator.java?rev=1765778&r1=1765777&r2=1765778&view=diff
==============================================================================
--- 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectConfigurator.java
 (original)
+++ 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectConfigurator.java
 Thu Oct 20 09:07:31 2016
@@ -16,40 +16,108 @@
  */
 package org.apache.sling.ide.eclipse.m2e.internal;
 
+import org.apache.maven.artifact.versioning.ComparableVersion;
 import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+import org.apache.maven.project.MavenProject;
 import org.apache.sling.ide.eclipse.core.ConfigurationHelper;
 import org.apache.sling.ide.log.Logger;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.internal.IMavenConstants;
 import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
 import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
 
 public class BundleProjectConfigurator extends AbstractProjectConfigurator {
 
-    private static final String MAVEN_SLING_PLUGIN_ARTIFACT_ID = 
"maven-sling-plugin";
-    private static final String MAVEN_SLING_PLUGIN_GROUP_ID = 
"org.apache.sling";
+    /**
+     *  the plugin ID consists of <code>groupId:artifactId</code>, see {@link 
Plugin#constructKey(String, String)}
+     */
+    private static final String MAVEN_SLING_PLUGIN_KEY = 
"org.apache.sling:maven-sling-plugin";
+    private static final String MAVEN_BUNDLE_PLUGIN_KEY 
="org.apache.felix:maven-bundle-plugin";
+    private static final String BND_MAVEN_PLUGIN_KEY = 
"biz.aQute.bnd:bnd-maven-plugin";
+    
+    private static final String MARKER_TYPE_BUNDLE_NOT_SUPPORTING_M2E = 
"org.apache.sling.ide.eclipse-m2e-ui.bundleprojectnotsupportingm2e";
 
     @Override
     public void configure(ProjectConfigurationRequest configRequest, 
IProgressMonitor monitor) throws CoreException {
+        
         // at this point the JDT project is already created by the tycho plugin
         // we just need to setup the appropriate facets
         Logger logger = Activator.getDefault().getPluginLogger();
         IProject project = configRequest.getProject();
         logger.trace("BundleProjectActivator called for POM {0} and project 
{1}", configRequest.getPom().getFullPath(),
                 project.getName());
+        
markerManager.deleteMarkers(project.getFile(IMavenConstants.POM_FILE_NAME), 
MARKER_TYPE_BUNDLE_NOT_SUPPORTING_M2E);
 
         // check for maven-sling-plugin as well (to make sure this is a Sling 
project)
-        for (Plugin plugin : 
configRequest.getMavenProject().getBuildPlugins()) {
-            if (plugin.getArtifactId().equals(MAVEN_SLING_PLUGIN_ARTIFACT_ID)
-                    && 
plugin.getGroupId().equals(MAVEN_SLING_PLUGIN_GROUP_ID)) {
-                logger.trace(
-                        "Found maven-sling-plugin in build plugins for project 
{0}, therefore adding sling bundle facets!",
-                        project.getName());
-                ConfigurationHelper.convertToBundleProject(project);
-                return;
+        MavenProject mavenProject = configRequest.getMavenProject();
+        if (mavenProject.getPlugin(MAVEN_SLING_PLUGIN_KEY) != null) {
+            logger.trace(
+                    "Found maven-sling-plugin in build plugins for project 
{0}, therefore adding sling bundle facets!",
+                    project.getName());
+            ConfigurationHelper.convertToBundleProject(project);
+        } else {
+            logger.trace("Couldn't find maven-sling-plugin in build plugins 
for project {0}, therefore not adding the sling bundle facets!", 
project.getName());
+        }
+        
+        if (!isSupportingM2EIncrementalBuild(mavenProject, logger)) {
+            
markerManager.addMarker(project.getFile(IMavenConstants.POM_FILE_NAME), 
MARKER_TYPE_BUNDLE_NOT_SUPPORTING_M2E, "Missing m2e incremental support for 
generating the bundle manifest", -1,
+                    IMarker.SEVERITY_ERROR);
+        }
+    }
+    
+    /**
+     * @param mavenProject
+     * @param logger
+     * @return {@code true} in case the pom.xml is correctly configured to 
support incremental build on the bundle's manifest, otherwise {@code false}
+     */
+    private boolean isSupportingM2EIncrementalBuild(MavenProject mavenProject, 
Logger logger) {
+        Plugin bundlePlugin = mavenProject.getPlugin(MAVEN_BUNDLE_PLUGIN_KEY);
+        if (bundlePlugin == null) {
+            Plugin bndPlugin = mavenProject.getPlugin(BND_MAVEN_PLUGIN_KEY);
+            if (bndPlugin != null) {
+                logger.trace("Using bnd-maven-plugin which supports 
incremental builds.");
+                return true;
+            }
+            logger.warn("Neither maven-bundle-plugin nor bnd-maven-plugin 
configured!");
+            return false;
+        } else {
+            String version = bundlePlugin.getVersion();
+            if (version == null) {
+                logger.warn("Could not retrieve used version of 
maven-bundle-plugin!");
+                return false;
+            }
+            ComparableVersion comparableVersion = new 
ComparableVersion(version);
+            // with https://issues.apache.org/jira/browse/FELIX-4009 m2e 
support for incremental builds was added to maven-bundle-plugin in version 3.2.0
+            if (comparableVersion.compareTo(new ComparableVersion("3.2.0")) >= 
0) {
+                // but only if explicitly configured, see 
http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests
+                // therefore check configuration
+                for (PluginExecution pluginExecution : 
bundlePlugin.getExecutions()) {
+                    if (!pluginExecution.getGoals().contains("manifest")) {
+                        continue;
+                    }
+                    Xpp3Dom configuration = 
(Xpp3Dom)pluginExecution.getConfiguration();
+                    Xpp3Dom supportIncrementalBuildConfiguration = 
configuration.getChild("supportIncrementalBuild");
+                    // https://issues.apache.org/jira/browse/FELIX-3324
+                    Xpp3Dom exportScrConfiguration = 
configuration.getChild("exportScr");
+                    if (supportIncrementalBuildConfiguration == null || 
!Boolean.parseBoolean(supportIncrementalBuildConfiguration.getValue())) {
+                        logger.warn("Although using maven-bundle-plugin in a 
version >= 3.2.0, the incremental build support was not enabled.");
+                    } else if (exportScrConfiguration == null || 
!Boolean.parseBoolean(exportScrConfiguration.getValue())) {
+                        logger.warn("Although using maven-bundle-plugin in a 
version >= 3.2.0, component descriptions are not exported (exportScr=false) .");
+                    } else {
+                        logger.trace("Using maven-bundle-plugin in a version 
>= 3.2.0 with the incremental build support correctly enabled.");
+                        return true;
+                    }
+                }
+            } else {
+                logger.warn("maven-bundle-plugin in a version < 3.2.0 does not 
support incremental builds.");
+                return false;
             }
         }
-        logger.trace("Couldn't find maven-sling-plugin in build plugins for 
project {0}", project.getName());
+        return false;
     }
 }

Added: 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectNotSupportingM2EIncrementalBuildQuickFix.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectNotSupportingM2EIncrementalBuildQuickFix.java?rev=1765778&view=auto
==============================================================================
--- 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectNotSupportingM2EIncrementalBuildQuickFix.java
 (added)
+++ 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectNotSupportingM2EIncrementalBuildQuickFix.java
 Thu Oct 20 09:07:31 2016
@@ -0,0 +1,165 @@
+/*
+ * 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.internal;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolutionGenerator;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Resolutions when current pom.xml configuration does not support manifest 
generation during incremental builds.
+ *
+ * @see <a 
href="https://wiki.eclipse.org/FAQ_How_do_I_implement_Quick_Fixes_for_my_own_language%3F";>Implement
 Quick
+ *      Fixes</a>
+ */
+public class BundleProjectNotSupportingM2EIncrementalBuildQuickFix implements 
IMarkerResolutionGenerator {
+
+    @Override
+    public IMarkerResolution[] getResolutions(IMarker marker) {
+        // either suggest to use maven-bundle-project 3.2.0 with correct 
configuration
+        IMarkerResolution[] resolutions = new IMarkerResolution[3];
+        resolutions[0] = new InstallM2ETychoExtension();
+        resolutions[1] = new FixUsingBndMavenPlugin();
+        resolutions[2] = new FixUsingMBP320WithCorrectConfiguration();
+        return resolutions;
+    }
+
+    public static final class FixUsingMBP320WithCorrectConfiguration 
implements IMarkerResolution {
+
+        FixUsingMBP320WithCorrectConfiguration() {
+        }
+
+        @Override
+        public String getLabel() {
+            return "Use maven-bundle-plugin 3.2.0 or newer with correct 
configuration";
+        }
+
+        @Override
+        public void run(IMarker marker) {
+            MessageDialogWithLinkSection.openInformationWithLink(null,
+                    "Use maven-bundle-plugin 3.2.0 or newer with correct 
configuration",
+                    "Please upgrade to at least maven-bundle-plugin 3.2.0 and 
explicitly configure goal 'manifest' with configuration 
'supportIncrementalBuild' and 'exportScr' set to 'true'.",
+                    "Further information is available at <a 
href=\"http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests\";>Maven
 Bundle Plugin FAQ</a>, <a 
href=\"https://issues.apache.org/jira/browse/FELIX-4009\";>FELIX-4009</a> and <a 
href=\"https://issues.apache.org/jira/browse/https://issues.apache.org/jira/browse/FELIX-3324\";>https://issues.apache.org/jira/browse/FELIX-3324</a>");
+        }
+    }
+    
+    public static final class FixUsingBndMavenPlugin implements 
IMarkerResolution {
+
+        FixUsingBndMavenPlugin() {
+        }
+
+        @Override
+        public String getLabel() {
+            return "Use bnd-maven-plugin in version 2.4.1 or newer";
+        }
+
+        @Override
+        public void run(IMarker marker) {
+            MessageDialogWithLinkSection.openInformationWithLink(null,
+                    "Use bnd-maven-plugin 2.4.1 or newer",
+                    "Please use bnd-maven-plugin as this supports m2e 
incremental builds correctly.",
+                    "Further information is available at <a 
href=\"http://njbartlett.name/2015/03/27/announcing-bnd-maven-plugin.html\";>Blog
 Post with Announcement</a>, <a 
href=\"https://github.com/bndtools/bnd/issues/1180\";>issues-1180</a> and <a 
href=\"https://github.com/bndtools/bnd/pull/1333\";>PR-1333</a>.");
+        }
+    }
+
+    /**
+     * Similar to {@link MessageDialog} but with an additional area above the 
buttons which contain links.
+     * 
+     * Unfortunately such a functionality is not yet part of Eclipse, but 
requested in
+     * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=484347";>bug 
484347</a>.
+     * 
+     * @see <a 
href="http://stackoverflow.com/questions/29374160/add-link-to-messagedialog-message";>http://stackoverflow
+     *      .com/questions/29374160/add-link-to-messagedialog-message<a>
+     * @see <a 
href="http://stackoverflow.com/questions/3968620/how-can-i-add-a-hyperlink-to-a-jface-dialog";>http://stackoverflow.com/questions/3968620/how-can-i-add-a-hyperlink-to-a-jface-dialog</a>
+     * 
+     * 
+     */
+    public static final class MessageDialogWithLinkSection extends 
MessageDialog {
+
+        private final String linkText;
+
+        public MessageDialogWithLinkSection(Shell parentShell, String 
dialogTitle, Image dialogTitleImage,
+                String dialogMessage, int dialogImageType, String[] 
dialogButtonLabels, int defaultIndex,
+                String linkText) {
+            super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, 
dialogImageType, dialogButtonLabels,
+                    defaultIndex);
+            this.linkText = linkText;
+        }
+
+        public static boolean openInformationWithLink(Shell parent, String 
title, String message, String link) {
+            MessageDialogWithLinkSection dialog = new 
MessageDialogWithLinkSection(parent, title, null, message,
+                    INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 
0, link);
+            return dialog.open() == 0;
+        }
+
+        @Override
+        protected Control createCustomArea(Composite parent) {
+            Link link = new Link(parent, SWT.WRAP);
+            link.setText(linkText);
+
+            link.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    try {
+                        // Open default external browser
+                        
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new 
URL(e.text));
+                    } catch (PartInitException ex) {
+                        Activator.getDefault().getPluginLogger()
+                                .error("Could not open external browser for 
link '" + e.text + "'", ex);
+                    } catch (MalformedURLException ex) {
+                        
Activator.getDefault().getPluginLogger().error("Invalid link detected '" + 
e.text + "'", ex);
+                    }
+                }
+            });
+            return link;
+        }
+    }
+
+    public static final class InstallM2ETychoExtension implements 
IMarkerResolution {
+
+        InstallM2ETychoExtension() {
+        }
+
+        @Override
+        public String getLabel() {
+            return "Install m2e-tycho extension (incompatible with 
maven-bundle-plugin 3.2.0 and later)";
+        }
+
+        @Override
+        public void run(IMarker marker) {
+            
org.eclipse.m2e.internal.discovery.MavenDiscovery.launchWizard(Collections.singleton("bundle"),
+                    Collections.EMPTY_LIST, Collections.EMPTY_LIST, 
Collections.EMPTY_LIST);
+        }
+    }
+
+}

Propchange: 
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/BundleProjectNotSupportingM2EIncrementalBuildQuickFix.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/tooling/ide/m2e-feature/feature.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/m2e-feature/feature.xml?rev=1765778&r1=1765777&r2=1765778&view=diff
==============================================================================
--- sling/trunk/tooling/ide/m2e-feature/feature.xml (original)
+++ sling/trunk/tooling/ide/m2e-feature/feature.xml Thu Oct 20 09:07:31 2016
@@ -225,10 +225,6 @@
    limitations under the License.
    </license>
 
-   <requires>
-      <import feature="org.sonatype.tycho.m2e.feature"/>
-   </requires>
-
    <plugin
          id="org.apache.sling.ide.eclipse-m2e-core"
          download-size="0"

Modified: sling/trunk/tooling/ide/p2update/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/p2update/pom.xml?rev=1765778&r1=1765777&r2=1765778&view=diff
==============================================================================
--- sling/trunk/tooling/ide/p2update/pom.xml (original)
+++ sling/trunk/tooling/ide/p2update/pom.xml Thu Oct 20 09:07:31 2016
@@ -62,9 +62,6 @@
                 <update.site.name>${project.name}</update.site.name>
                 <target.eclipse.version>Kepler or 
newer</target.eclipse.version>
               </symbols>
-              <associateSites>
-                
<site>http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.6.0/N/0.6.0.201207302152/</site>
-              </associateSites>
             </configuration>
           </execution>
         </executions>

Modified: 
sling/trunk/tooling/ide/target-definition/org.apache.sling.ide.target-definition.target
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/target-definition/org.apache.sling.ide.target-definition.target?rev=1765778&r1=1765777&r2=1765778&view=diff
==============================================================================
--- 
sling/trunk/tooling/ide/target-definition/org.apache.sling.ide.target-definition.target
 (original)
+++ 
sling/trunk/tooling/ide/target-definition/org.apache.sling.ide.target-definition.target
 Thu Oct 20 09:07:31 2016
@@ -18,10 +18,6 @@
 <?pde version="3.8"?><target name="Sling IDE Tools" sequenceNumber="46">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" 
includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.sonatype.tycho.m2e.feature.feature.group" 
version="0.6.0.201207302152"/>
-<repository 
location="http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.6.0/N/0.6.0.201207302152/"/>
-</location>
-<location includeAllPlatforms="false" includeConfigurePhase="false" 
includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.m2e.feature.feature.group" 
version="1.5.1.20150109-1820"/>
 <unit id="org.eclipse.wst.server_adapters.feature.feature.group" 
version="3.2.401.v201410241731"/>
 <unit id="org.eclipse.jst.server_ui.feature.feature.group" 
version="3.4.101.v201410241731"/>


Reply via email to