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

org.marvelution.jira.plugins.jenkins.utils.JenkinsPluginUtil Maven / Gradle / Ivy

There is a newer version: 2.3.1
Show newest version
/*
 * Copyright (c) 2012-present Marvelution B.V.
 *
 * Licensed 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.marvelution.jira.plugins.jenkins.utils;

import javax.inject.Inject;
import javax.inject.Named;

import com.atlassian.plugin.Plugin;
import com.atlassian.plugin.osgi.bridge.external.PluginRetrievalService;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import org.osgi.framework.Version;

/**
 * Plugin Util
 *
 * @author Mark Rekveld
 * @since 1.0.0
 */
@Named
public class JenkinsPluginUtil {

	private final PluginRetrievalService pluginRetrievalService;

	@Inject
	public JenkinsPluginUtil(@ComponentImport PluginRetrievalService pluginRetrievalService) {
		this.pluginRetrievalService = pluginRetrievalService;
	}

	/**
	 * Returns the {@link Plugin}
	 */
	public Plugin getPlugin() {
		return pluginRetrievalService.getPlugin();
	}

	/**
	 * Returns the plugin key
	 */
	public String getPluginKey() {
		return getPlugin().getKey();
	}

	/**
	 * Returns the complete key of the given plugin specific {@literal moduleKey}
	 *
	 * @since 2.0.0
	 */
	public String getCompleteModuleKey(String moduleKey) {
		return String.format("%s:%s", getPluginKey(), moduleKey);
	}

	/**
	 * Returns the plugin version
	 */
	public Version getVersion() {
		return Version.parseVersion(getPlugin().getPluginInformation().getVersion());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy