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

com.marvelution.jenkins.plugins.jira.utils.PluginUtils Maven / Gradle / Ivy

There is a newer version: 1.5.6
Show newest version
/*
 * JIRA Plugin for Jenkins
 * Copyright (C) 2012 Marvelution
 * [email protected]
 *
 * 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 com.marvelution.jenkins.plugins.jira.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Helper class to get Plugin properties
 * 
 * @author Mark Rekveld
 */
public final class PluginUtils {

	private static final PluginUtils INSTANCE = new PluginUtils();

	private final Properties PROPERTIES = new Properties();

	/**
	 * Private constructor
	 */
	private PluginUtils() {
		final InputStream input = getClass().getResourceAsStream("PluginUtils.properties");
		try {
			PROPERTIES.load(input);
		} catch (IOException e) {
			throw new RuntimeException("Failed to load Jenkins Plugin properties", e);
		}
	}

	/**
	 * Getter for the plugin groupId property
	 * 
	 * @return the plugin groupId property value
	 */
	public static String getPluginGroupId() {
		return INSTANCE.getProperty("plugin.groupId");
	}

	/**
	 * Getter for the plugin arifactId property
	 * 
	 * @return the plugin arifactId property value
	 */
	public static String getPluginArifactId() {
		return INSTANCE.getProperty("plugin.artifactId");
	}

	/**
	 * Getter for the plugin version property
	 *
	 * @return the plugin version property value
	 */
	public static String getPluginVersion() {
		return INSTANCE.getProperty("plugin.version");
	}

	/**
	 * Getter for the plugin version property
	 *
	 * @return the plugin version property value
	 */
	public static String getAtlassianApplinksVersion() {
		return INSTANCE.getProperty("atlassian.applinks.version");
	}

	/**
	 * Getter for a property
	 * 
	 * @param key the property key
	 * @return the property value
	 */
	private String getProperty(String key) {
		return getProperty(key, "");
	}

	/**
	 * Getter for a property
	 * 
	 * @param key the property key
	 * @param defaultValue the default value, use if the property is not set
	 * @return the property value, or the given default value if the property is not set
	 */
	private String getProperty(String key, String defaultValue) {
		return PROPERTIES.getProperty(key, defaultValue);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy