2 * Copyright 2000-2011 JetBrains s.r.o.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package jetbrains.buildServer.nuget.server.install;
\r
19 import jetbrains.buildServer.nuget.common.DotNetConstants;
\r
20 import jetbrains.buildServer.requirements.Requirement;
\r
21 import jetbrains.buildServer.requirements.RequirementType;
\r
22 import jetbrains.buildServer.serverSide.InvalidProperty;
\r
23 import jetbrains.buildServer.serverSide.PropertiesProcessor;
\r
24 import jetbrains.buildServer.serverSide.RunType;
\r
25 import jetbrains.buildServer.util.StringUtil;
\r
26 import jetbrains.buildServer.web.openapi.PluginDescriptor;
\r
27 import org.jetbrains.annotations.NotNull;
\r
31 import static jetbrains.buildServer.nuget.common.PackagesConstants.*;
\r
34 * Created by Eugene Petrenko (eugene.petrenko@gmail.com)
\r
35 * Date: 08.07.11 20:45
\r
37 public class PackagesInstallerRunType extends RunType {
\r
38 private final PluginDescriptor myDescriptor;
\r
40 public PackagesInstallerRunType(@NotNull final PluginDescriptor descriptor) {
\r
41 myDescriptor = descriptor;
\r
46 public String getType() {
\r
47 return INSTALL_RUN_TYPE;
\r
51 public String getDisplayName() {
\r
52 return "NuGet Packages Installer";
\r
56 public String getDescription() {
\r
57 return "Installs and updates missing NuGet packages";
\r
61 public PropertiesProcessor getRunnerPropertiesProcessor() {
\r
62 return new PropertiesProcessor() {
\r
63 public Collection<InvalidProperty> process(Map<String, String> properties) {
\r
64 List<InvalidProperty> checks = new ArrayList<InvalidProperty>();
\r
66 if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_PATH))) {
\r
67 checks.add(new InvalidProperty(NUGET_PATH, "Path to nuget.exe must be specified"));
\r
70 String sln = properties.get(SLN_PATH);
\r
71 if (StringUtil.isEmptyOrSpaces(sln)) {
\r
72 checks.add(new InvalidProperty(NUGET_PATH, "Path to solution file should be specified"));
\r
74 if (!sln.toLowerCase().endsWith(".sln")) {
\r
75 checks.add(new InvalidProperty(NUGET_PATH, "File extension must be .sln. Specify path to .sln file."));
\r
85 public String describeParameters(@NotNull Map<String, String> parameters) {
\r
86 return getDescription() + "\nSolution: " + parameters.get(SLN_PATH);
\r
90 public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {
\r
91 List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));
\r
92 list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));
\r
97 public String getEditRunnerParamsJspFilePath() {
\r
98 return myDescriptor.getPluginResourcesPath("install/editInstallPackage.jsp");
\r
102 public String getViewRunnerParamsJspFilePath() {
\r
103 return myDescriptor.getPluginResourcesPath("install/viewInstallPackage.jsp");
\r
107 public Map<String, String> getDefaultRunnerProperties() {
\r
108 return new TreeMap<String, String>();
\r