// Path: src/main/java/de/undercouch/gradle/tasks/download/internal/WorkerExecutorHelper.java
// public abstract class WorkerExecutorHelper {
//     /**
//      * Creates a new instance of the {@link WorkerExecutorHelper} depending
//      * on the Gradle version
//      * @param objectFactory creates Gradle model objects
//      * @return the helper
//      */
//     public static WorkerExecutorHelper newInstance(ObjectFactory objectFactory) {
//         if (GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("5.6")) >= 0) {
//             return objectFactory.newInstance(DefaultWorkerExecutorHelper.class);
//         }
//         return new LegacyWorkerExecutorHelper();
//     }
// 
//     /**
//      * Execute a job asynchronously
//      * @param job the job to execute
//      */
//     public abstract void submit(Job job);
// 
//     /**
//      * Wait for all jobs of the current build operation to complete
//      */
//     public abstract void await();
// 
//     /**
//      * Returns {@code true} if {@link #await()} MUST be called at the end of
//      * the task. This mostly applies to Gradle versions that don't have a
//      * Worker API and therefore cannot let the task continue to run in parallel
//      * to others.
//      * @return {@code true} if {@link #await()} must be called
//      */
//     public abstract boolean needsAwait();
// }


import de.undercouch.gradle.tasks.download.internal.WorkerExecutorHelper;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.internal.operations.BuildOperationCategory;
import org.gradle.internal.operations.BuildOperationDescriptor;
import org.gradle.internal.operations.BuildOperationState;
import org.gradle.internal.operations.CurrentBuildOperationRef;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
                        .build(), 0);
        op.setRunning(true);
        CurrentBuildOperationRef.instance().set(op);

        return (Download)project.task(taskParams, "downloadFile");
    }

    protected Project makeProject() {
        return makeProject(null);
    }

    protected Project makeProject(@Nullable Action<Project> projectConfiguration) {
        Project project = ProjectBuilder.builder().withProjectDir(projectDir).build();

        if (projectConfiguration != null) {
            projectConfiguration.execute(project);
        }

        Map<String, Object> applyParams = new HashMap<>();
        applyParams.put("plugin", "de.undercouch.download");
        project.apply(applyParams);

        return project;
    }

    protected void execute(Task t) {
        List<Action<? super Task>> actions = t.getActions();
        for (Action<? super Task> a : actions) {
            a.execute(t);
        }
// Path: src/main/java/de/undercouch/gradle/tasks/download/internal/WorkerExecutorHelper.java
// public abstract class WorkerExecutorHelper {
//     /**
//      * Creates a new instance of the {@link WorkerExecutorHelper} depending
//      * on the Gradle version
//      * @param objectFactory creates Gradle model objects
//      * @return the helper
//      */
//     public static WorkerExecutorHelper newInstance(ObjectFactory objectFactory) {
//         if (GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("5.6")) >= 0) {
//             return objectFactory.newInstance(DefaultWorkerExecutorHelper.class);
//         }
//         return new LegacyWorkerExecutorHelper();
//     }
// 
//     /**
//      * Execute a job asynchronously
//      * @param job the job to execute
//      */
//     public abstract void submit(Job job);
// 
//     /**
//      * Wait for all jobs of the current build operation to complete
//      */
//     public abstract void await();
// 
//     /**
//      * Returns {@code true} if {@link #await()} MUST be called at the end of
//      * the task. This mostly applies to Gradle versions that don't have a
//      * Worker API and therefore cannot let the task continue to run in parallel
//      * to others.
//      * @return {@code true} if {@link #await()} must be called
//      */
//     public abstract boolean needsAwait();
// }


// Path: src/test/java/de/undercouch/gradle/tasks/download/TestBase.java
import de.undercouch.gradle.tasks.download.internal.WorkerExecutorHelper;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.internal.operations.BuildOperationCategory;
import org.gradle.internal.operations.BuildOperationDescriptor;
import org.gradle.internal.operations.BuildOperationState;
import org.gradle.internal.operations.CurrentBuildOperationRef;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

                        .build(), 0);
        op.setRunning(true);
        CurrentBuildOperationRef.instance().set(op);

        return (Download)project.task(taskParams, "downloadFile");
    }

    protected Project makeProject() {
        return makeProject(null);
    }

    protected Project makeProject(@Nullable Action<Project> projectConfiguration) {
        Project project = ProjectBuilder.builder().withProjectDir(projectDir).build();

        if (projectConfiguration != null) {
            projectConfiguration.execute(project);
        }

        Map<String, Object> applyParams = new HashMap<>();
        applyParams.put("plugin", "de.undercouch.download");
        project.apply(applyParams);

        return project;
    }

    protected void execute(Task t) {
        List<Action<? super Task>> actions = t.getActions();
        for (Action<? super Task> a : actions) {
            a.execute(t);
        }
        WorkerExecutorHelper.newInstance(t.getProject().getObjects()).await();