All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.gesellix.gradle.docker.tasks.DockerStopTask Maven / Gradle / Ivy

package de.gesellix.gradle.docker.tasks;

import de.gesellix.docker.engine.EngineResponse;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;

public class DockerStopTask extends GenericDockerTask {

  private final Property containerId;

  @Input
  public Property getContainerId() {
    return containerId;
  }

  private EngineResponse result;

  @Internal
  public EngineResponse getResult() {
    return result;
  }

  @Inject
  public DockerStopTask(ObjectFactory objectFactory) {
    super(objectFactory);
    setDescription("Stop a running container");

    containerId = objectFactory.property(String.class);
  }

  @TaskAction
  public EngineResponse stop() {
    getLogger().info("docker stop");
    result = getDockerClient().stop(getContainerId().get());
    return result;
  }

  /**
   * @see #getContainerId()
   * @deprecated This setter will be removed, please use the Property instead.
   */
  @Deprecated
  public void setContainerId(String containerId) {
    this.containerId.set(containerId);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy