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

co.com.bancolombia.task.InternalTask Maven / Gradle / Ivy

Go to download

Gradle plugin to create a clean application in Java that already works, It follows our best practices!

There is a newer version: 3.17.22
Show newest version
package co.com.bancolombia.task;

import co.com.bancolombia.task.annotations.CATask;
import co.com.bancolombia.utils.SonarCheck;
import co.com.bancolombia.utils.Utils;
import co.com.bancolombia.utils.offline.UpdateProjectDependencies;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import lombok.Getter;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.options.Option;
import org.gradle.api.tasks.options.OptionValues;

@CATask(name = "internalTask", shortcut = "it", description = "Run non final user task")
public class InternalTask extends AbstractCleanArchitectureDefaultTask {
  private Action action = Action.SONAR_CHECK;

  @Option(option = "action", description = "Set task action to run")
  public void setAction(Action action) {
    this.action = action;
  }

  @OptionValues("action")
  public List getInputOptions() {
    return Arrays.asList(Action.values());
  }

  @Getter @Internal private boolean success = false;

  @Override
  public void execute() throws IOException {
    switch (Objects.requireNonNull(action)) {
      case SONAR_CHECK:
        SonarCheck.parse(getProject());
        break;
      case UPDATE_DEPENDENCIES:
        String basePath = getProject().getProjectDir().toString();
        List files = Utils.getAllFilesWithGradleExtension(basePath);
        logger.lifecycle(
            "Updating project dependencies from root {} in files \n {}", basePath, files);
        UpdateProjectDependencies.builder().withFiles(files).build().run();
        break;
    }
    success = true;
  }

  public enum Action {
    SONAR_CHECK,
    UPDATE_DEPENDENCIES
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy