Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed to Marvelution under one or more contributor license 
  * agreements.  See the NOTICE file distributed with this work 
  * for additional information regarding copyright ownership.
  * Marvelution 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 com.marvelution.bamboo.plugins.sonar.capability.utils;
import  org.apache.commons.lang.StringUtils;
import  org.jetbrains.annotations.NotNull;
import  org.jetbrains.annotations.Nullable;
import  com.atlassian.bamboo.configuration.Jdk;
import  com.atlassian.bamboo.v2.build.agent.capability.Capability;
import  com.atlassian.bamboo.v2.build.agent.capability.ReadOnlyCapabilitySet;

Utility helper class for Agent Capabilities

Author(s):
Mark Rekveld
public final class CapabilityUtils {
	public static final String DEFAULT_JDK_LABEL = "JDK";
	public static final String DEFAULT_JDK =
		Capability.SYSTEM_PREFIX + "." + Jdk.CAPABILITY_JDK_TYPE + "." + ;

Get the JDK Home path for the select JDK capability

Parameters:
buildJdk the build JDK label
capabilitySet the ReadOnlyCapabilitySet of the agent performing the build
Returns:
the JDK Home path
	@Nullable
    public static String getJdkPath(@Nullable String buildJdk, @NotNull ReadOnlyCapabilitySet capabilitySet) {
		final String jdkCapabilityKey =
			Jdk.CAPABILITY_JDK_PREFIX + "." + (StringUtils.isNotBlank(buildJdk) ? buildJdk : );
		final Capability capability = capabilitySet.getCapability(jdkCapabilityKey);
		if (capability != null) {
			return capability.getValue();
else {
			return null;
		}
	}
New to GrepCode? Check out our FAQ X