improve logging
[teamcity/dotNetPackagesSupport.git] / nuget-server / src / jetbrains / buildServer / nuget / server / exec / NuGetExecutorImpl.java
index 065bbbe991bfe5548ecbcf1846f363861240fc3f..181479cefbf9cb8abc3e79192fc367446395ec81 100644 (file)
@@ -20,7 +20,7 @@ import com.intellij.execution.configurations.GeneralCommandLine;
 import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.ExecResult;\r
 import jetbrains.buildServer.SimpleCommandLineProcessRunner;\r
-import jetbrains.buildServer.plugins.bean.PluginInfo;\r
+import jetbrains.buildServer.util.StringUtil;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
 import java.io.File;\r
@@ -33,23 +33,20 @@ import java.util.List;
 public class NuGetExecutorImpl implements NuGetExecutor {\r
   private static final Logger LOG = Logger.getInstance(NuGetExecutorImpl.class.getName());\r
 \r
-  private final PluginInfo myPluginInfo;\r
+  private final NuGetTeamCityProvider myNuGetTeamCityProvider;\r
 \r
-  public NuGetExecutorImpl(PluginInfo pluginInfo) {\r
-    myPluginInfo = pluginInfo;\r
+  public NuGetExecutorImpl(@NotNull final NuGetTeamCityProvider nuGetTeamCityProvider) {\r
+    myNuGetTeamCityProvider = nuGetTeamCityProvider;\r
   }\r
 \r
   @NotNull\r
-  private File getNuGetRunnerPath() {\r
-    return new File(myPluginInfo.getPluginRoot(), "bin/JetBrains.TeamCity.NuGetRunner.exe");\r
-  }\r
-\r
-  @NotNull\r
-  public <T> T executeNuGet(@NotNull final List<String> arguments,\r
+  public <T> T executeNuGet(@NotNull final File nugetExePath,\r
+                            @NotNull final List<String> arguments,\r
                             @NotNull final NuGetOutputProcessor<T> listener) {\r
 \r
     GeneralCommandLine cmd = new GeneralCommandLine();\r
-    cmd.setExePath(getNuGetRunnerPath().getPath());\r
+    cmd.setExePath(myNuGetTeamCityProvider.getNuGetRunnerPath().getPath());\r
+    cmd.addParameter(nugetExePath.getPath());\r
     cmd.addParameters(arguments);\r
 \r
     if (LOG.isDebugEnabled()) {\r
@@ -60,8 +57,12 @@ public class NuGetExecutorImpl implements NuGetExecutor {
 \r
     if (LOG.isDebugEnabled()) {\r
       LOG.debug("Exited with code: " + result.getExitCode());\r
-      LOG.debug("Output: " + result.getStdout());\r
-      LOG.error("Error: " + result.getStderr());\r
+      if (!StringUtil.isEmptyOrSpaces(result.getStdout())) {\r
+        LOG.debug("Output: " + result.getStdout());\r
+      }\r
+      if (!StringUtil.isEmptyOrSpaces(result.getStderr())) {\r
+        LOG.debug("Error: " + result.getStderr());\r
+      }\r
     }\r
 \r
     listener.onStdOutput(result.getStdout());\r