--- /dev/null
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.parameters;\r
+\r
+import jetbrains.buildServer.RunBuildException;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+import java.util.Collection;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 21.07.11 15:56\r
+ */\r
+public interface NuGetPublishParameters extends NuGetParameters {\r
+ @Nullable\r
+ String getPublishSource() throws RunBuildException;\r
+\r
+ @NotNull\r
+ String getApiKey() throws RunBuildException;\r
+\r
+ @NotNull\r
+ Collection<String> getFiles() throws RunBuildException;\r
+\r
+ boolean getCreateOnly();\r
+}\r
@NotNull\r
public NuGetFetchParameters loadNuGetFetchParameters(@NotNull final BuildRunnerContext context) throws RunBuildException {\r
return new NuGetFetchParameters() {\r
-\r
- private File resolvePath(@NotNull final String runnerParameter, @NotNull String name) throws RunBuildException {\r
- String path = getParameter(context, runnerParameter);\r
- if (StringUtil.isEmptyOrSpaces(path))\r
- throw new RunBuildException("Runner parameter '" + runnerParameter + "' was not found");\r
-\r
- File file = FileUtil.resolvePath(context.getBuild().getCheckoutDirectory(), path);\r
- if (!file.exists()) {\r
- throw new RunBuildException("Failed to find " + name + " at " + file);\r
- }\r
-\r
- return file;\r
- }\r
-\r
-\r
@NotNull\r
public File getSolutionFile() throws RunBuildException {\r
- return resolvePath(SLN_PATH, "Visual Studio .sln file");\r
+ return getFile(context, SLN_PATH, "Visual Studio .sln file");\r
}\r
\r
@NotNull\r
public File getNuGetExeFile() throws RunBuildException {\r
- return resolvePath(NUGET_PATH, "nuget.exe");\r
+ return getFile(context, NUGET_PATH, "nuget.exe");\r
}\r
\r
@NotNull\r
};\r
}\r
\r
+ @NotNull\r
+ private File getFile(@NotNull final BuildRunnerContext context,\r
+ @NotNull final String runnerParameter,\r
+ @NotNull final String fileName) throws RunBuildException {\r
+ String path = getParameter(context, runnerParameter);\r
+ if (StringUtil.isEmptyOrSpaces(path))\r
+ throw new RunBuildException("Runner parameter '" + runnerParameter + "' was not found");\r
+\r
+ File file = FileUtil.resolvePath(context.getBuild().getCheckoutDirectory(), path);\r
+ if (!file.exists()) {\r
+ throw new RunBuildException("Failed to find " + fileName + " at " + file);\r
+ }\r
+\r
+ return file;\r
+ }\r
+\r
+\r
private Collection<String> getMultilineParameter(BuildRunnerContext context, String nugetSources) {\r
String sources = getParameter(context, nugetSources);\r
if (sources == null) return Collections.emptyList();\r
}\r
};\r
}\r
+\r
+ @NotNull\r
+ public NuGetPublishParameters loadPublishParameters(@NotNull final BuildRunnerContext context) throws RunBuildException {\r
+ return new NuGetPublishParameters() {\r
+ public String getPublishSource() throws RunBuildException {\r
+ return getParameter(context, NUGET_PUBLISH_SOURCE);\r
+ }\r
+\r
+ @NotNull\r
+ public String getApiKey() throws RunBuildException {\r
+ return getParameter(context, NUGET_API_KEY);\r
+ }\r
+\r
+ @NotNull\r
+ public Collection<String> getFiles() throws RunBuildException {\r
+ return getMultilineParameter(context, NUGET_PUBLISH_FILES);\r
+ }\r
+\r
+ public boolean getCreateOnly() {\r
+ return getBoolean(context, NUGET_PUBLISH_CREATE_ONLY);\r
+ }\r
+\r
+ @NotNull\r
+ public File getNuGetExeFile() throws RunBuildException {\r
+ return getFile(context, NUGET_PATH, "nuget.exe");\r
+ }\r
+ };\r
+ }\r
}\r