code reuse, no need to register runners explicitly as agent searches for runner imple...
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 16:41:54 +0000 (18:41 +0200)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 16:41:54 +0000 (18:41 +0200)
nuget-agent/src/META-INF/build-agent-plugin-nuget-install.xml
nuget-agent/src/META-INF/build-agent-plugin-nuget-pack.xml
nuget-agent/src/META-INF/build-agent-plugin-nuget-publish.xml
nuget-agent/src/META-INF/build-agent-plugin-nuget.xml
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/NuGetRunnerBase.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/install/PackagesInstallerRunner.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/install/PackagesInstallerRunnerRegistrar.java [deleted file]
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/pack/PackRunner.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/pack/PackRunnerRegistrar.java [deleted file]
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/publish/PackagesPublishRunner.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/publish/PackagesPublishRunnerRegistrar.java [deleted file]

index dca988b566a2053a8cab2c3c3ef5cc4c156ee432..11074a414ff54767958ad31542fd7f9dc9e3b964 100644 (file)
@@ -5,7 +5,6 @@
                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
        default-autowire="constructor">\r
   <bean class="jetbrains.buildServer.nuget.agent.runner.install.PackagesInstallerRunner"/>\r
-  <bean class="jetbrains.buildServer.nuget.agent.runner.install.PackagesInstallerRunnerRegistrar"/>\r
 \r
   <bean class="jetbrains.buildServer.nuget.agent.runner.install.impl.PackagesWatcher"/>\r
   <bean class="jetbrains.buildServer.nuget.agent.runner.install.impl.PackagesInfoUploader"/>\r
index 96e31b50220f70cc57fe90f8f5e272a265808266..1a1f7905d2b5f66793b83a8b6fab7bd6043961f8 100644 (file)
@@ -6,6 +6,5 @@
        default-autowire="constructor">\r
 \r
   <bean class="jetbrains.buildServer.nuget.agent.runner.pack.PackRunner"/>\r
-  <bean class="jetbrains.buildServer.nuget.agent.runner.pack.PackRunnerRegistrar"/>\r
 \r
 </beans>
\ No newline at end of file
index 899cd071515626ea7312a5ca126065c2f3f4224c..ce06a72691772b881f60317f7c34d4a6264b932c 100644 (file)
@@ -6,6 +6,5 @@
        default-autowire="constructor">\r
 \r
   <bean class="jetbrains.buildServer.nuget.agent.runner.publish.PackagesPublishRunner"/>\r
-  <bean class="jetbrains.buildServer.nuget.agent.runner.publish.PackagesPublishRunnerRegistrar"/>\r
 \r
 </beans>
\ No newline at end of file
index 3b03c16fa1312f6cdee3d9bb415a64dea65492fb..7ef0cffd05098d71a5b984ed8d56c7a51b46db7f 100644 (file)
@@ -22,5 +22,4 @@
   <bean class="jetbrains.buildServer.nuget.agent.dependencies.impl.PackageUsagesImpl"/>\r
   <bean class="jetbrains.buildServer.nuget.agent.dependencies.impl.NuGetPackagesConfigParser" />\r
   <bean class="jetbrains.buildServer.nuget.agent.dependencies.impl.NuGetPackagesCollectorImpl"/>\r
-\r
 </beans>
\ No newline at end of file
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/NuGetRunnerBase.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/NuGetRunnerBase.java
new file mode 100644 (file)
index 0000000..850743b
--- /dev/null
@@ -0,0 +1,64 @@
+/*\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.runner;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.agent.AgentBuildRunner;\r
+import jetbrains.buildServer.agent.AgentBuildRunnerInfo;\r
+import jetbrains.buildServer.agent.BuildAgentConfiguration;\r
+import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;\r
+import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
+import jetbrains.buildServer.nuget.common.DotNetConstants;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ *         Date: 23.08.11 18:32\r
+ */\r
+public abstract class NuGetRunnerBase implements AgentBuildRunner, AgentBuildRunnerInfo {\r
+  protected final Logger LOG = Logger.getInstance(getClass().getName());\r
+\r
+  protected final NuGetActionFactory myActionFactory;\r
+  protected final PackagesParametersFactory myParametersFactory;\r
+\r
+  public NuGetRunnerBase(NuGetActionFactory actionFactory, PackagesParametersFactory parametersFactory) {\r
+    myActionFactory = actionFactory;\r
+    myParametersFactory = parametersFactory;\r
+  }\r
+\r
+  @NotNull\r
+  public AgentBuildRunnerInfo getRunnerInfo() {\r
+    return this;\r
+  }\r
+\r
+  @NotNull\r
+  public abstract String getType();\r
+\r
+  public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {\r
+    if (!agentConfiguration.getSystemInfo().isWindows()) {\r
+      LOG.warn("NuGet packages installer available only under windows");\r
+      return false;\r
+    }\r
+\r
+    if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {\r
+      LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");\r
+      return false;\r
+    }\r
+\r
+    return true;\r
+  }\r
+}\r
index 39c9d0c6b9e910795a635c702c9d72070dadf3de..b633b0c34ed3901d6b0bc1e87706c0feba43d55a 100644 (file)
 \r
 package jetbrains.buildServer.nuget.agent.runner.install;\r
 \r
-import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.RunBuildException;\r
-import jetbrains.buildServer.agent.*;\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.BuildProcess;\r
+import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;\r
-import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStages;\r
-import jetbrains.buildServer.nuget.agent.runner.install.impl.*;\r
-import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStagesImpl;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetFetchParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
+import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;\r
+import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStages;\r
+import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStagesImpl;\r
 import jetbrains.buildServer.nuget.agent.runner.install.impl.PackagesInstallerBuilder;\r
 import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
-import jetbrains.buildServer.nuget.common.DotNetConstants;\r
 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
@@ -37,16 +37,10 @@ import org.jetbrains.annotations.NotNull;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 07.07.11 13:55\r
  */\r
-public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunnerInfo {\r
-  private static final Logger LOG = Logger.getInstance(PackagesInstallerRunner.class.getName());\r
-\r
-  private final NuGetActionFactory myNuGetActionFactory;\r
-  private final PackagesParametersFactory myParametersFactory;\r
-\r
-  public PackagesInstallerRunner(@NotNull final NuGetActionFactory nuGetActionFactory,\r
+public class PackagesInstallerRunner extends NuGetRunnerBase {\r
+  public PackagesInstallerRunner(@NotNull final NuGetActionFactory actionFactory,\r
                                  @NotNull final PackagesParametersFactory parametersFactory) {\r
-    myNuGetActionFactory = nuGetActionFactory;\r
-    myParametersFactory = parametersFactory;\r
+    super(actionFactory, parametersFactory);\r
   }\r
 \r
   @NotNull\r
@@ -72,7 +66,7 @@ public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunn
             parameters,\r
             context.getBuild().getBuildLogger(),\r
             new PackagesInstallerBuilder(\r
-                    myNuGetActionFactory,\r
+                    myActionFactory,\r
                     stages,\r
                     context,\r
                     installParameters,\r
@@ -83,26 +77,7 @@ public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunn
   }\r
 \r
   @NotNull\r
-  public AgentBuildRunnerInfo getRunnerInfo() {\r
-    return this;\r
-  }\r
-\r
-  @NotNull\r
   public String getType() {\r
     return PackagesConstants.INSTALL_RUN_TYPE;\r
   }\r
-\r
-  public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {\r
-    if (!agentConfiguration.getSystemInfo().isWindows()) {\r
-      LOG.warn("NuGet packages installer available only under windows");\r
-      return false;\r
-    }\r
-\r
-    if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {\r
-      LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");\r
-      return false;\r
-    }\r
-\r
-    return true;\r
-  }\r
 }\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/install/PackagesInstallerRunnerRegistrar.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/install/PackagesInstallerRunnerRegistrar.java
deleted file mode 100644 (file)
index e59c113..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*\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.runner.install;\r
-\r
-import jetbrains.buildServer.agent.impl.BuildRunnerRegistry;\r
-import org.jetbrains.annotations.NotNull;\r
-\r
-/**\r
- * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
- * Date: 07.07.11 15:39\r
- */\r
-public class PackagesInstallerRunnerRegistrar {\r
-  public PackagesInstallerRunnerRegistrar(@NotNull final BuildRunnerRegistry reg,\r
-                                          @NotNull final PackagesInstallerRunner runner) {\r
-    reg.registerRunner(runner);\r
-  }\r
-}\r
index 622343d92641d805804d86be421dd86e66384911..e5e6e4df471859091200d30a7d401dfe0c73a70c 100644 (file)
 \r
 package jetbrains.buildServer.nuget.agent.runner.pack;\r
 \r
-import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.RunBuildException;\r
-import jetbrains.buildServer.agent.*;\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.BuildProcess;\r
+import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetPackParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
+import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;\r
 import jetbrains.buildServer.nuget.agent.util.CompositeBuildProcess;\r
 import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
-import jetbrains.buildServer.nuget.common.DotNetConstants;\r
 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
@@ -32,16 +33,10 @@ import org.jetbrains.annotations.NotNull;
  * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
  *         Date: 23.08.11 12:11\r
  */\r
-public class PackRunner implements AgentBuildRunner, AgentBuildRunnerInfo {\r
-  private static final Logger LOG = Logger.getInstance(PackRunner.class.getName());\r
-\r
-  private final NuGetActionFactory myActionFactory;\r
-  private final PackagesParametersFactory myParametersFactory;\r
-\r
+public class PackRunner extends NuGetRunnerBase {\r
   public PackRunner(@NotNull final NuGetActionFactory actionFactory,\r
                     @NotNull final PackagesParametersFactory parametersFactory) {\r
-    myActionFactory = actionFactory;\r
-    myParametersFactory = parametersFactory;\r
+    super(actionFactory, parametersFactory);\r
   }\r
 \r
   @NotNull\r
@@ -55,27 +50,7 @@ public class PackRunner implements AgentBuildRunner, AgentBuildRunnerInfo {
   }\r
 \r
   @NotNull\r
-  public AgentBuildRunnerInfo getRunnerInfo() {\r
-    return this;\r
-  }\r
-\r
-  @NotNull\r
   public String getType() {\r
     return PackagesConstants.PACK_RUN_TYPE;\r
   }\r
-\r
-  public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {\r
-    if (!agentConfiguration.getSystemInfo().isWindows()) {\r
-      LOG.warn("NuGet packages installer available only under windows");\r
-      return false;\r
-    }\r
-\r
-    if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {\r
-      LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");\r
-      return false;\r
-    }\r
-\r
-    return true;\r
-  }\r
-\r
 }\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/pack/PackRunnerRegistrar.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/pack/PackRunnerRegistrar.java
deleted file mode 100644 (file)
index 11abdc2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*\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.runner.pack;\r
-\r
-import jetbrains.buildServer.agent.impl.BuildRunnerRegistry;\r
-import org.jetbrains.annotations.NotNull;\r
-\r
-/**\r
- * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
- *         Date: 23.08.11 12:13\r
- */\r
-public class PackRunnerRegistrar {\r
-  public PackRunnerRegistrar(@NotNull final BuildRunnerRegistry reg,\r
-                             @NotNull final PackRunner runner) {\r
-    reg.registerRunner(runner);\r
-  }\r
-}\r
index 427bfa54a69cb0b7a10b3dbb7c25f5b7d393b384..7266e5958e5299cd9c0e22d780ad1d83b02980eb 100644 (file)
 \r
 package jetbrains.buildServer.nuget.agent.runner.publish;\r
 \r
-import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.RunBuildException;\r
-import jetbrains.buildServer.agent.*;\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.BuildProcess;\r
+import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetPublishParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
+import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;\r
 import jetbrains.buildServer.nuget.agent.util.CompositeBuildProcess;\r
 import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
-import jetbrains.buildServer.nuget.common.DotNetConstants;\r
 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
@@ -34,16 +35,10 @@ import java.io.File;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 21.07.11 15:15\r
  */\r
-public class PackagesPublishRunner implements AgentBuildRunner, AgentBuildRunnerInfo {\r
-  private static final Logger LOG = Logger.getInstance(PackagesPublishRunner.class.getName());\r
-\r
-  private final NuGetActionFactory myActionFactory;\r
-  private final PackagesParametersFactory myParametersFactory;\r
-\r
+public class PackagesPublishRunner extends NuGetRunnerBase {\r
   public PackagesPublishRunner(@NotNull final NuGetActionFactory actionFactory,\r
                                @NotNull final PackagesParametersFactory parametersFactory) {\r
-    myActionFactory = actionFactory;\r
-    myParametersFactory = parametersFactory;\r
+    super(actionFactory, parametersFactory);\r
   }\r
 \r
   @NotNull\r
@@ -64,26 +59,7 @@ public class PackagesPublishRunner implements AgentBuildRunner, AgentBuildRunner
   }\r
 \r
   @NotNull\r
-  public AgentBuildRunnerInfo getRunnerInfo() {\r
-    return this;\r
-  }\r
-\r
-  @NotNull\r
   public String getType() {\r
     return PackagesConstants.PUBLISH_RUN_TYPE;\r
   }\r
-\r
-  public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {\r
-    if (!agentConfiguration.getSystemInfo().isWindows()) {\r
-      LOG.warn("NuGet packages installer available only under windows");\r
-      return false;\r
-    }\r
-\r
-    if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {\r
-      LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");\r
-      return false;\r
-    }\r
-\r
-    return true;\r
-  }\r
 }
\ No newline at end of file
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/publish/PackagesPublishRunnerRegistrar.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/publish/PackagesPublishRunnerRegistrar.java
deleted file mode 100644 (file)
index 3226d1e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*\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.runner.publish;\r
-\r
-import jetbrains.buildServer.agent.impl.BuildRunnerRegistry;\r
-import org.jetbrains.annotations.NotNull;\r
-\r
-/**\r
- * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
- * Date: 21.07.11 20:00\r
- */\r
-public class PackagesPublishRunnerRegistrar {\r
-  public PackagesPublishRunnerRegistrar(@NotNull final BuildRunnerRegistry reg,\r
-                                        @NotNull final PackagesPublishRunner runner) {\r
-    reg.registerRunner(runner);\r
-  }\r
-}\r