All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.plugins.analysis.collector.AnalysisDescriptor Maven / Gradle / Ivy

Go to download

This plug-in is an add-on for the plug-ins Checkstyle, Dry, FindBugs, PMD, Tasks, and Warnings: the plug-in collects the different analysis results and shows the results in a combined trend graph. Additionally, the plug-in provides health reporting and build stability based on these combined results.

The newest version!
package hudson.plugins.analysis.collector;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.plugins.analysis.core.PluginDescriptor;

import java.util.Collection;
import java.util.HashSet;

import com.google.common.collect.Sets;

/**
 * Descriptor for the class {@link AnalysisPublisher}. Used as a singleton. The
 * class is marked as public so that it can be accessed from views.
 *
 * @author Ulli Hafner
 */
@Extension(ordinal = 1)
public final class AnalysisDescriptor extends PluginDescriptor {
    /** Plug-in name. */
    private static final String PLUGIN_NAME = "analysis";
    /** Icon to use for the result and project action. */
    private static final String ACTION_ICON = "/plugin/analysis-collector/icons/analysis-24x24.png";

    /**
     * Returns the activated plug-ins.
     *
     * @return the activated plug-ins
     */
    public static Collection getPlugins() {
        HashSet plugins = Sets.newHashSet();

        if (isCheckStyleInstalled()) {
            plugins.add("checkstyle");
        }
        if (isDryInstalled()) {
            plugins.add("dry");
        }
        if (isFindBugsInstalled()) {
            plugins.add("findbugs");
        }
        if (isPmdInstalled()) {
            plugins.add("pmd");
        }
        if (isOpenTasksInstalled()) {
            plugins.add("tasks");
        }
        if (isWarningsInstalled()) {
            plugins.add("warnings");
        }
        return plugins;
    }

    /**
     * Returns whether the Checkstyle plug-in is installed.
     *
     * @return true if the Checkstyle plug-in is installed,
     *         false if not.
     */
    public static boolean isCheckStyleInstalled() {
        return isPluginInstalled("checkstyle");
    }

    /**
     * Returns whether the Dry plug-in is installed.
     *
     * @return true if the Dry plug-in is installed,
     *         false if not.
     */
    public static boolean isDryInstalled() {
        return isPluginInstalled("dry");
    }

    /**
     * Returns whether the FindBugs plug-in is installed.
     *
     * @return true if the FindBugs plug-in is installed,
     *         false if not.
     */
    public static boolean isFindBugsInstalled() {
        return isPluginInstalled("findbugs");
    }

    /**
     * Returns whether the PMD plug-in is installed.
     *
     * @return true if the PMD plug-in is installed,
     *         false if not.
     */
    public static boolean isPmdInstalled() {
        return isPluginInstalled("pmd");
    }

    /**
     * Returns whether the Open Tasks plug-in is installed.
     *
     * @return true if the Open Tasks plug-in is installed,
     *         false if not.
     */
    public static boolean isOpenTasksInstalled() {
        return isPluginInstalled("tasks");
    }

    /**
     * Returns whether the Warnings plug-in is installed.
     *
     * @return true if the Warnings plug-in is installed,
     *         false if not.
     */
    public static boolean isWarningsInstalled() {
        return isPluginInstalled("warnings");
    }

    /**
     * Returns whether the specified plug-in is installed.
     *
     * @param shortName
     *            the plugin to check
     * @return true if the specified plug-in is installed,
     *         false if not.
     */
    private static boolean isPluginInstalled(final String shortName) {
        Hudson instance = Hudson.getInstance();
        if (instance != null) {
            return instance.getPlugin(shortName) != null;
        }
        return true;
    }

    /**
     * Instantiates a new {@link AnalysisDescriptor}.
     */
    public AnalysisDescriptor() {
        super(AnalysisPublisher.class);
    }

    /** {@inheritDoc} */
    @Override
    public String getDisplayName() {
        return Messages.Analysis_Publisher_Name();
    }

    /**
     * Returns the root folder of this plug-in.
     *
     * @return the name of the root folder of this plug-in
     */
    @Override
    public String getPluginRoot() {
        return "/plugin/analysis-collector/";
    }

    /** {@inheritDoc} */
    @Override
    public String getPluginName() {
        return PLUGIN_NAME;
    }

    /** {@inheritDoc} */
    @Override
    public String getIconUrl() {
        return ACTION_ICON;
    }

    /** {@inheritDoc} */
    @SuppressWarnings("rawtypes")
    @Override
    public boolean isApplicable(final Class jobType) {
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy