package com.gradle.ares

import com.gradle.MyLogger
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.tasks.TaskAction;

/**
 * Created by Glen on 2017/2/8.
 */

public class CheckParamsTask extends DefaultTask {
    Map<String, Set<Task>> tasks = new HashMap<>();

    CheckParamsTask() {
        setGroup("tool")
    }

    @TaskAction
    def checkParams() {

        project.android.applicationVariants.each { variant ->
            MyLogger.error(variant.javaCompile.name)
        }
    }

    @TaskAction
    def printAllTask() {
        project.tasks.findAll { item ->
            String g = item.group
            if (!tasks.containsKey(g)) {
                tasks.put(g, new HashSet<Task>())
            }
            tasks.get(g).add(item)
        }
        tasks.each { k, v ->
            for (Task task : v) {
                println(task.group + "_" + task.name)
            }
            println(k + "_" + v.size())
        }
    }
}
