protected boolean isSupportingM2eIncrementalBuild()

in eclipse/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/MavenBundlePluginProjectConfigurator.java [40:83]


    protected boolean isSupportingM2eIncrementalBuild(MavenProject mavenProject, Logger logger) {
        Plugin bundlePlugin = mavenProject.getPlugin(MAVEN_BUNDLE_PLUGIN_KEY);
        if (bundlePlugin == null) {
            logger.warn("maven-bundle-plugin not 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
                boolean foundManifestGoal = false;
                for (PluginExecution pluginExecution : bundlePlugin.getExecutions()) {
                    if (!pluginExecution.getGoals().contains("manifest")) {
                        continue;
                    }
                    foundManifestGoal = true;
                    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 with incremental build support enabled, component descriptors 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;
                    }
                }
                if (!foundManifestGoal) {
                    logger.warn("Although using maven-bundle-plugin in a version >= 3.2.0, the explicit goal 'manifest' is not configured.");
                }
            } else {
                logger.warn("maven-bundle-plugin in a version < 3.2.0 does not natively support incremental builds.");
            }
        }
        return false;
    }