code reuse, no need to register runners explicitly as agent searches for runner imple...
[teamcity/dotNetPackagesSupport.git] / nuget-agent / src / jetbrains / buildServer / nuget / agent / runner / publish / PackagesPublishRunner.java
1 /*\r
2  * Copyright 2000-2011 JetBrains s.r.o.\r
3  *\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
7  *\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  *\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
15  */\r
16 \r
17 package jetbrains.buildServer.nuget.agent.runner.publish;\r
18 \r
19 import jetbrains.buildServer.RunBuildException;\r
20 import jetbrains.buildServer.agent.AgentRunningBuild;\r
21 import jetbrains.buildServer.agent.BuildProcess;\r
22 import jetbrains.buildServer.agent.BuildRunnerContext;\r
23 import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;\r
24 import jetbrains.buildServer.nuget.agent.parameters.NuGetPublishParameters;\r
25 import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
26 import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;\r
27 import jetbrains.buildServer.nuget.agent.util.CompositeBuildProcess;\r
28 import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
29 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
30 import org.jetbrains.annotations.NotNull;\r
31 \r
32 import java.io.File;\r
33 \r
34 /**\r
35  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
36  * Date: 21.07.11 15:15\r
37  */\r
38 public class PackagesPublishRunner extends NuGetRunnerBase {\r
39   public PackagesPublishRunner(@NotNull final NuGetActionFactory actionFactory,\r
40                                @NotNull final PackagesParametersFactory parametersFactory) {\r
41     super(actionFactory, parametersFactory);\r
42   }\r
43 \r
44   @NotNull\r
45   public BuildProcess createBuildProcess(@NotNull final AgentRunningBuild runningBuild,\r
46                                          @NotNull final BuildRunnerContext context) throws RunBuildException {\r
47     final CompositeBuildProcess process = new CompositeBuildProcessImpl();\r
48     final NuGetPublishParameters params = myParametersFactory.loadPublishParameters(context);\r
49 \r
50     process.pushBuildProcess(new MatchFilesBuildProcess(context, params, new MatchFilesBuildProcess.Callback() {\r
51       public void fileFound(@NotNull File file) throws RunBuildException {\r
52         process.pushBuildProcess(\r
53                 myActionFactory.createPush(context, params, file)\r
54         );\r
55       }\r
56     }));\r
57 \r
58     return process;\r
59   }\r
60 \r
61   @NotNull\r
62   public String getType() {\r
63     return PackagesConstants.PUBLISH_RUN_TYPE;\r
64   }\r
65 }