-
Notifications
You must be signed in to change notification settings - Fork 8
/
SbtRunnerRunType.java
97 lines (78 loc) · 3.25 KB
/
SbtRunnerRunType.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package jetbrains.buildServer.sbt;
import jetbrains.buildServer.util.StringUtil;
import jetbrains.buildServer.requirements.Requirement;
import jetbrains.buildServer.serverSide.*;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class SbtRunnerRunType extends RunType {
public static final String SBT_JVM_ARGS = TeamCityProperties.getProperty(
SbtRunnerConstants.TEAMCITY_SBT_DEFAULT_JVM_ARGS_PROPERTY,
SbtRunnerConstants.DEFAULT_VALUE);
private PluginDescriptor myPluginDescriptor;
public SbtRunnerRunType(@NotNull final RunTypeRegistry runTypeRegistry,
@NotNull final PluginDescriptor pluginDescriptor) {
myPluginDescriptor = pluginDescriptor;
runTypeRegistry.registerRunType(this);
}
@Override
public PropertiesProcessor getRunnerPropertiesProcessor() {
return new PropertiesProcessor() {
public Collection<InvalidProperty> process(Map<String, String> props) {
List<InvalidProperty> errors = new ArrayList<InvalidProperty>();
if (!SbtRunnerConstants.AUTO_INSTALL_FLAG.equalsIgnoreCase(props.get(SbtRunnerConstants.SBT_INSTALLATION_MODE_PARAM)) && StringUtil.isEmptyOrSpaces(props.get(SbtRunnerConstants.SBT_HOME_PARAM))) {
errors.add(new InvalidProperty(SbtRunnerConstants.SBT_HOME_PARAM, "SBT home path must be specified"));
}
if (SbtRunnerConstants.AUTO_INSTALL_FLAG.equalsIgnoreCase(props.get(SbtRunnerConstants.SBT_INSTALLATION_MODE_PARAM))) {
props.remove(SbtRunnerConstants.SBT_HOME_PARAM);
}
return errors;
}
};
}
@NotNull
@Override
public String getDescription() {
return SbtRunnerConstants.RUNNER_DESCRIPTION;
}
@Override
public String getEditRunnerParamsJspFilePath() {
return myPluginDescriptor.getPluginResourcesPath("editSbtRunParams.jsp");
}
@Override
public String getViewRunnerParamsJspFilePath() {
return myPluginDescriptor.getPluginResourcesPath("viewSbtRunParams.jsp");
}
@Override
public Map<String, String> getDefaultRunnerProperties() {
return new HashMap<String, String>() {{
put(SbtRunnerConstants.SBT_ARGS_PARAM, SbtRunnerConstants.DEFAULT_SBT_COMMANDS);
put(SbtRunnerConstants.SBT_INSTALLATION_MODE_PARAM, SbtRunnerConstants.AUTO_INSTALL_FLAG);
put("jvmArgs", SBT_JVM_ARGS);
}};
}
@NotNull
@Override
public String getType() {
return SbtRunnerConstants.RUNNER_TYPE;
}
@NotNull
@Override
public String getDisplayName() {
return SbtRunnerConstants.RUNNER_DISPLAY_NAME;
}
@NotNull
@Override
public String describeParameters(@NotNull final Map<String, String> parameters) {
String args = parameters.get(SbtRunnerConstants.SBT_ARGS_PARAM);
if (!StringUtil.isEmptyOrSpaces(args)) {
return args;
}
return "";
}
@NotNull
@Override
public List<Requirement> getRunnerSpecificRequirements(@NotNull final Map<String, String> runParameters) {
return Collections.emptyList();
}
}