package org.implab.gradle.common.dsl;

import java.util.Objects;

import org.gradle.api.Task;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskProvider;

public abstract class TaskGroup implements TasksMixin {
    private final String groupName;

    protected abstract TaskContainer tasks();

    public TaskGroup(String name) {
        Objects.requireNonNull(name, "The group name is required");
        this.groupName = name;
    }

    @Override
    public <T extends Task> TaskProvider<T> task(String taskName, Class<T> clazz) {
        var provider = tasks().register(taskName, clazz);
        provider.configure(t -> t.setGroup(groupName));
        return provider;
    }

}
