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

wtf.emulator.EwExecTask Maven / Gradle / Ivy

Go to download

With this Gradle plugin you can run your Android instrumentation tests with emulator.wtf

The newest version!
package wtf.emulator;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.TaskAction;
import org.gradle.workers.WorkQueue;
import org.gradle.workers.WorkerExecutor;
import wtf.emulator.exec.EwWorkAction;
import wtf.emulator.exec.EwWorkParameters;

import javax.inject.Inject;
import java.time.Duration;
import java.util.Map;

@CacheableTask
public abstract class EwExecTask extends DefaultTask {
  @Classpath
  @InputFiles
  public abstract Property getClasspath();

  @Input
  public abstract Property getToken();

  @Optional
  @InputFiles
  @PathSensitive(PathSensitivity.NONE)
  public abstract Property getApks();

  @Optional
  @InputFile
  @PathSensitive(PathSensitivity.NONE)
  public abstract RegularFileProperty getTestApk();

  @Optional
  @InputFile
  @PathSensitive(PathSensitivity.NONE)
  public abstract RegularFileProperty getLibraryTestApk();

  @Optional
  @OutputDirectory
  public abstract DirectoryProperty getOutputsDir();

  @OutputFile
  public abstract RegularFileProperty getOutputFile();

  @Optional
  @Input
  public abstract ListProperty getOutputTypes();

  @Optional
  @Input
  public abstract Property getRecordVideo();

  @Optional
  @Input
  public abstract ListProperty> getDevices();

  @Optional
  @Input
  public abstract Property getUseOrchestrator();

  @Optional
  @Input
  public abstract Property getClearPackageData();

  @Optional
  @Input
  public abstract Property getWithCoverage();

  @Optional
  @InputFiles
  @PathSensitive(PathSensitivity.NONE)
  public abstract Property getAdditionalApks();

  @Optional
  @Input
  public abstract MapProperty getEnvironmentVariables();

  @Optional
  @Input
  public abstract Property getNumUniformShards();

  @Optional
  @Input
  public abstract Property getNumBalancedShards();

  @Optional
  @Input
  public abstract Property getNumShards();

  @Optional
  @Input
  public abstract Property getShardTargetRuntime();

  @Optional
  @Input
  public abstract ListProperty getDirectoriesToPull();

  @Optional
  @Input
  public abstract Property getSideEffects();

  @Optional
  @Input
  public abstract Property getTestTimeout();

  @Optional
  @Input
  public abstract Property getFileCacheEnabled();

  @Optional
  @Input
  public abstract Property getFileCacheTtl();

  @Optional
  @Input
  public abstract Property getTestCacheEnabled();

  @Optional
  @Input
  public abstract Property getNumFlakyTestAttempts();

  @Optional
  @Input
  public abstract Property getFlakyTestRepeatMode();

  @Optional
  @Input
  public abstract Property getDisplayName();

  @Optional
  @Input
  public abstract Property getScmUrl();

  @Optional
  @Input
  public abstract Property getScmCommitHash();

  @Optional
  @Input
  public abstract Property getScmRefName();

  @Optional
  @Input
  public abstract Property getScmPrUrl();

  @Optional
  @Input
  public abstract Property getIgnoreFailures();

  @Optional
  @Input
  public abstract Property getAsync();

  @Internal
  public abstract RegularFileProperty getWorkingDir();

  @Inject
  public abstract WorkerExecutor getWorkerExecutor();

  @Optional
  @Input
  public abstract Property getPrintOutput();

  @Optional
  @Input
  public abstract Property getTestTargets();

  @Optional
  @Input
  public abstract Property getProxyHost();

  @Optional
  @Input
  public abstract Property getProxyPort();

  @Optional
  @Input
  public abstract Property getProxyUser();

  @Optional
  @Input
  public abstract Property getProxyPassword();

  @TaskAction
  public void runTests() {
    WorkQueue workQueue = getWorkerExecutor().noIsolation();
    workQueue.submit(EwWorkAction.class, this::fillWorkParameters);
  }

  protected void fillWorkParameters(EwWorkParameters p) {
    p.getClasspath().set(getClasspath().get().getFiles());
    p.getToken().set(getToken());
    p.getApks().set(getApks());
    p.getTestApk().set(getTestApk());
    p.getLibraryTestApk().set(getLibraryTestApk());
    p.getOutputsDir().set(getOutputsDir());
    p.getOutputs().set(getOutputTypes());
    p.getRecordVideo().set(getRecordVideo());
    p.getDevices().set(getDevices());
    p.getUseOrchestrator().set(getUseOrchestrator());
    p.getClearPackageData().set(getClearPackageData());
    p.getWithCoverage().set(getWithCoverage());
    p.getAdditionalApks().set(getAdditionalApks());
    p.getEnvironmentVariables().set(getEnvironmentVariables());
    p.getNumUniformShards().set(getNumUniformShards());
    p.getNumBalancedShards().set(getNumBalancedShards());
    p.getNumShards().set(getNumShards());
    p.getShardTargetRuntime().set(getShardTargetRuntime());
    p.getDirectoriesToPull().set(getDirectoriesToPull());
    p.getSideEffects().set(getSideEffects());
    p.getTimeout().set(getTestTimeout());
    p.getFileCacheEnabled().set(getFileCacheEnabled());
    p.getFileCacheTtl().set(getFileCacheTtl());
    p.getTestCacheEnabled().set(getTestCacheEnabled());
    p.getNumFlakyTestAttempts().set(getNumFlakyTestAttempts());
    p.getFlakyTestRepeatMode().set(getFlakyTestRepeatMode());
    p.getDisplayName().set(getDisplayName());
    p.getScmUrl().set(getScmUrl());
    p.getScmCommitHash().set(getScmCommitHash());
    p.getScmRefName().set(getScmRefName());
    p.getScmPrUrl().set(getScmPrUrl());
    p.getWorkingDir().set(getWorkingDir());
    p.getIgnoreFailures().set(getIgnoreFailures());
    p.getAsync().set(getAsync());
    p.getPrintOutput().set(getPrintOutput());
    p.getTestTargets().set(getTestTargets());
    p.getProxyHost().set(getProxyHost());
    p.getProxyPort().set(getProxyPort());
    p.getProxyUser().set(getProxyUser());
    p.getProxyPassword().set(getProxyPassword());
    p.getOutputFile().set(getOutputFile());
    p.getTaskPath().set(getPath());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy