implement push command
authorEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 21 Jul 2011 12:34:59 +0000 (16:34 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 21 Jul 2011 12:34:59 +0000 (16:34 +0400)
nuget-agent/src/jetbrains/buildServer/nuget/agent/commands/CommandFactory.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/commands/impl/CommandFactoryImpl.java

index ecabe9e1e96b4c21977e294d7777e199e0182774..627167a10aa7eeda9ab1718dcff32a345cb0a021 100644 (file)
@@ -17,6 +17,7 @@
 package jetbrains.buildServer.nuget.agent.commands;\r
 \r
 import jetbrains.buildServer.RunBuildException;\r
 package jetbrains.buildServer.nuget.agent.commands;\r
 \r
 import jetbrains.buildServer.RunBuildException;\r
+import jetbrains.buildServer.nuget.agent.parameters.NuGetPublishParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
 import org.jetbrains.annotations.NotNull;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
 import org.jetbrains.annotations.NotNull;\r
@@ -42,6 +43,11 @@ public interface CommandFactory {
                      @NotNull File targetFolder,\r
                      @NotNull Callback<T> factory) throws RunBuildException;\r
 \r
                      @NotNull File targetFolder,\r
                      @NotNull Callback<T> factory) throws RunBuildException;\r
 \r
+  @NotNull\r
+  <T> T createPush(@NotNull NuGetPublishParameters params,\r
+                   @NotNull File packagePath,\r
+                   @NotNull Callback<T> factory) throws RunBuildException;\r
+\r
   public interface Callback<T> {\r
     /**\r
      * Called with generated arguments to crate execurable instance or run command\r
   public interface Callback<T> {\r
     /**\r
      * Called with generated arguments to crate execurable instance or run command\r
index 1b078d09998c63cd30ea1fe7b01870526a9c1459..ce2d78411847322237e8d20849275f0868f8e1e2 100644 (file)
@@ -18,14 +18,13 @@ package jetbrains.buildServer.nuget.agent.commands.impl;
 \r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.nuget.agent.commands.CommandFactory;\r
 \r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.nuget.agent.commands.CommandFactory;\r
-import jetbrains.buildServer.nuget.agent.parameters.NuGetFetchParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
+import jetbrains.buildServer.nuget.agent.parameters.*;\r
 import jetbrains.buildServer.util.FileUtil;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
 import java.io.File;\r
 import java.util.ArrayList;\r
 import jetbrains.buildServer.util.FileUtil;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
 import java.io.File;\r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.Collection;\r
 import java.util.List;\r
 \r
 import java.util.Collection;\r
 import java.util.List;\r
 \r
@@ -69,13 +68,30 @@ public class CommandFactoryImpl implements CommandFactory {
     return executeNuGet(params.getNuGetParameters(), argz, packagesConfig.getParentFile(), factory);\r
   }\r
 \r
     return executeNuGet(params.getNuGetParameters(), argz, packagesConfig.getParentFile(), factory);\r
   }\r
 \r
+  @NotNull\r
+  public <T> T createPush(@NotNull final NuGetPublishParameters params,\r
+                          @NotNull final File packagePath,\r
+                          @NotNull final Callback<T> factory) throws RunBuildException {\r
+    return executeNuGet(params, Arrays.asList(params.getPublishSource()),\r
+            Arrays.asList(\r
+                    packagePath.getPath(),\r
+                    params.getApiKey()\r
+            ),\r
+            packagePath.getParentFile(),\r
+            factory);\r
+  }\r
+\r
   @NotNull\r
   private <T> T executeNuGet(@NotNull final NuGetFetchParameters nuget,\r
                              @NotNull final Collection<String> arguments,\r
                              @NotNull final File workingDir,\r
                              @NotNull final Callback<T> factory) throws RunBuildException {\r
   @NotNull\r
   private <T> T executeNuGet(@NotNull final NuGetFetchParameters nuget,\r
                              @NotNull final Collection<String> arguments,\r
                              @NotNull final File workingDir,\r
                              @NotNull final Callback<T> factory) throws RunBuildException {\r
+    return executeNuGet(nuget, nuget.getNuGetPackageSources(), arguments, workingDir, factory);\r
+  }\r
+\r
+  private <T> T executeNuGet(NuGetParameters nuget, Collection<String> sources, Collection<String> arguments, File workingDir, Callback<T> factory) throws RunBuildException {\r
     final List<String> argz = new ArrayList<String>(arguments);\r
     final List<String> argz = new ArrayList<String>(arguments);\r
-    for (String source : nuget.getNuGetPackageSources()) {\r
+    for (String source : sources) {\r
       argz.add("-Source");\r
       argz.add(source);\r
     }\r
       argz.add("-Source");\r
       argz.add(source);\r
     }\r