Skip to content
Permalink
Browse files
code reuse, no need to register runners explicitly as agent searches …
…for runner implementations
  • Loading branch information
jonnyzzz committed Aug 23, 2011
1 parent 42c8178 commit fd232f43bc08ff0d91b257d2aca5ebc3a6aef1e4
@@ -5,7 +5,6 @@
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
default-autowire="constructor">
<bean class="jetbrains.buildServer.nuget.agent.runner.install.PackagesInstallerRunner"/>
<bean class="jetbrains.buildServer.nuget.agent.runner.install.PackagesInstallerRunnerRegistrar"/>

<bean class="jetbrains.buildServer.nuget.agent.runner.install.impl.PackagesWatcher"/>
<bean class="jetbrains.buildServer.nuget.agent.runner.install.impl.PackagesInfoUploader"/>
@@ -6,6 +6,5 @@
default-autowire="constructor">

<bean class="jetbrains.buildServer.nuget.agent.runner.pack.PackRunner"/>
<bean class="jetbrains.buildServer.nuget.agent.runner.pack.PackRunnerRegistrar"/>

</beans>
@@ -6,6 +6,5 @@
default-autowire="constructor">

<bean class="jetbrains.buildServer.nuget.agent.runner.publish.PackagesPublishRunner"/>
<bean class="jetbrains.buildServer.nuget.agent.runner.publish.PackagesPublishRunnerRegistrar"/>

</beans>
@@ -22,5 +22,4 @@
<bean class="jetbrains.buildServer.nuget.agent.dependencies.impl.PackageUsagesImpl"/>
<bean class="jetbrains.buildServer.nuget.agent.dependencies.impl.NuGetPackagesConfigParser" />
<bean class="jetbrains.buildServer.nuget.agent.dependencies.impl.NuGetPackagesCollectorImpl"/>

</beans>
@@ -0,0 +1,64 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package jetbrains.buildServer.nuget.agent.runner;

import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.agent.AgentBuildRunner;
import jetbrains.buildServer.agent.AgentBuildRunnerInfo;
import jetbrains.buildServer.agent.BuildAgentConfiguration;
import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;
import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;
import jetbrains.buildServer.nuget.common.DotNetConstants;
import org.jetbrains.annotations.NotNull;

/**
* @author Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 23.08.11 18:32
*/
public abstract class NuGetRunnerBase implements AgentBuildRunner, AgentBuildRunnerInfo {
protected final Logger LOG = Logger.getInstance(getClass().getName());

protected final NuGetActionFactory myActionFactory;
protected final PackagesParametersFactory myParametersFactory;

public NuGetRunnerBase(NuGetActionFactory actionFactory, PackagesParametersFactory parametersFactory) {
myActionFactory = actionFactory;
myParametersFactory = parametersFactory;
}

@NotNull
public AgentBuildRunnerInfo getRunnerInfo() {
return this;
}

@NotNull
public abstract String getType();

public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {
if (!agentConfiguration.getSystemInfo().isWindows()) {
LOG.warn("NuGet packages installer available only under windows");
return false;
}

if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {
LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");
return false;
}

return true;
}
}
@@ -16,37 +16,31 @@

package jetbrains.buildServer.nuget.agent.runner.install;

import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.agent.*;
import jetbrains.buildServer.agent.AgentRunningBuild;
import jetbrains.buildServer.agent.BuildProcess;
import jetbrains.buildServer.agent.BuildRunnerContext;
import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;
import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStages;
import jetbrains.buildServer.nuget.agent.runner.install.impl.*;
import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStagesImpl;
import jetbrains.buildServer.nuget.agent.parameters.NuGetFetchParameters;
import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;
import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;
import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;
import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;
import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStages;
import jetbrains.buildServer.nuget.agent.runner.install.impl.InstallStagesImpl;
import jetbrains.buildServer.nuget.agent.runner.install.impl.PackagesInstallerBuilder;
import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;
import jetbrains.buildServer.nuget.common.DotNetConstants;
import jetbrains.buildServer.nuget.common.PackagesConstants;
import org.jetbrains.annotations.NotNull;

/**
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 07.07.11 13:55
*/
public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunnerInfo {
private static final Logger LOG = Logger.getInstance(PackagesInstallerRunner.class.getName());

private final NuGetActionFactory myNuGetActionFactory;
private final PackagesParametersFactory myParametersFactory;

public PackagesInstallerRunner(@NotNull final NuGetActionFactory nuGetActionFactory,
public class PackagesInstallerRunner extends NuGetRunnerBase {
public PackagesInstallerRunner(@NotNull final NuGetActionFactory actionFactory,
@NotNull final PackagesParametersFactory parametersFactory) {
myNuGetActionFactory = nuGetActionFactory;
myParametersFactory = parametersFactory;
super(actionFactory, parametersFactory);
}

@NotNull
@@ -72,7 +66,7 @@ private void createStages(@NotNull final BuildRunnerContext context,
parameters,
context.getBuild().getBuildLogger(),
new PackagesInstallerBuilder(
myNuGetActionFactory,
myActionFactory,
stages,
context,
installParameters,
@@ -82,27 +76,8 @@ private void createStages(@NotNull final BuildRunnerContext context,
stages.getLocateStage().pushBuildProcess(locate);
}

@NotNull
public AgentBuildRunnerInfo getRunnerInfo() {
return this;
}

@NotNull
public String getType() {
return PackagesConstants.INSTALL_RUN_TYPE;
}

public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {
if (!agentConfiguration.getSystemInfo().isWindows()) {
LOG.warn("NuGet packages installer available only under windows");
return false;
}

if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {
LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");
return false;
}

return true;
}
}

This file was deleted.

@@ -16,32 +16,27 @@

package jetbrains.buildServer.nuget.agent.runner.pack;

import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.agent.*;
import jetbrains.buildServer.agent.AgentRunningBuild;
import jetbrains.buildServer.agent.BuildProcess;
import jetbrains.buildServer.agent.BuildRunnerContext;
import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;
import jetbrains.buildServer.nuget.agent.parameters.NuGetPackParameters;
import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;
import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;
import jetbrains.buildServer.nuget.agent.util.CompositeBuildProcess;
import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;
import jetbrains.buildServer.nuget.common.DotNetConstants;
import jetbrains.buildServer.nuget.common.PackagesConstants;
import org.jetbrains.annotations.NotNull;

/**
* @author Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 23.08.11 12:11
*/
public class PackRunner implements AgentBuildRunner, AgentBuildRunnerInfo {
private static final Logger LOG = Logger.getInstance(PackRunner.class.getName());

private final NuGetActionFactory myActionFactory;
private final PackagesParametersFactory myParametersFactory;

public class PackRunner extends NuGetRunnerBase {
public PackRunner(@NotNull final NuGetActionFactory actionFactory,
@NotNull final PackagesParametersFactory parametersFactory) {
myActionFactory = actionFactory;
myParametersFactory = parametersFactory;
super(actionFactory, parametersFactory);
}

@NotNull
@@ -54,28 +49,8 @@ public BuildProcess createBuildProcess(@NotNull final AgentRunningBuild runningB
return process;
}

@NotNull
public AgentBuildRunnerInfo getRunnerInfo() {
return this;
}

@NotNull
public String getType() {
return PackagesConstants.PACK_RUN_TYPE;
}

public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {
if (!agentConfiguration.getSystemInfo().isWindows()) {
LOG.warn("NuGet packages installer available only under windows");
return false;
}

if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {
LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");
return false;
}

return true;
}

}

This file was deleted.

@@ -16,15 +16,16 @@

package jetbrains.buildServer.nuget.agent.runner.publish;

import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.agent.*;
import jetbrains.buildServer.agent.AgentRunningBuild;
import jetbrains.buildServer.agent.BuildProcess;
import jetbrains.buildServer.agent.BuildRunnerContext;
import jetbrains.buildServer.nuget.agent.commands.NuGetActionFactory;
import jetbrains.buildServer.nuget.agent.parameters.NuGetPublishParameters;
import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;
import jetbrains.buildServer.nuget.agent.runner.NuGetRunnerBase;
import jetbrains.buildServer.nuget.agent.util.CompositeBuildProcess;
import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;
import jetbrains.buildServer.nuget.common.DotNetConstants;
import jetbrains.buildServer.nuget.common.PackagesConstants;
import org.jetbrains.annotations.NotNull;

@@ -34,16 +35,10 @@
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 21.07.11 15:15
*/
public class PackagesPublishRunner implements AgentBuildRunner, AgentBuildRunnerInfo {
private static final Logger LOG = Logger.getInstance(PackagesPublishRunner.class.getName());

private final NuGetActionFactory myActionFactory;
private final PackagesParametersFactory myParametersFactory;

public class PackagesPublishRunner extends NuGetRunnerBase {
public PackagesPublishRunner(@NotNull final NuGetActionFactory actionFactory,
@NotNull final PackagesParametersFactory parametersFactory) {
myActionFactory = actionFactory;
myParametersFactory = parametersFactory;
super(actionFactory, parametersFactory);
}

@NotNull
@@ -63,27 +58,8 @@ public void fileFound(@NotNull File file) throws RunBuildException {
return process;
}

@NotNull
public AgentBuildRunnerInfo getRunnerInfo() {
return this;
}

@NotNull
public String getType() {
return PackagesConstants.PUBLISH_RUN_TYPE;
}

public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {
if (!agentConfiguration.getSystemInfo().isWindows()) {
LOG.warn("NuGet packages installer available only under windows");
return false;
}

if (!agentConfiguration.getConfigurationParameters().containsKey(DotNetConstants.DOT_NET_FRAMEWORK_4_x86)) {
LOG.warn("NuGet requires .NET Framework 4.0 x86 installed");
return false;
}

return true;
}
}

0 comments on commit fd232f4

Please sign in to comment.