package com.github.blindpirate.gogradle.task;

import com.google.common.collect.ImmutableMap;
import org.gradle.api.Task;

import javax.inject.Singleton;
import java.util.HashMap;
import java.util.Map;

@Singleton
public class GolangTaskContainer {
    // prepare everything
    public static final String PREPARE_TASK_NAME = "prepare";
    // produce all dependencies by analyzing build.gradle
    public static final String RESOLVE_BUILD_DEPENDENCIES_TASK_NAME = "resolveBuildDependencies";
    public static final String RESOLVE_TEST_DEPENDENCIES_TASK_NAME = "resolveTestDependencies";
    // show dependencies tree
    public static final String DEPENDENCIES_TASK_NAME = "dependencies";

    public static final String CHECK_TASK_NAME = "check";
    public static final String LOCK_TASK_NAME = "lock";
    public static final String BUILD_TASK_NAME = "build";
    public static final String CLEAN_TASK_NAME = "clean";
    public static final String INSTALL_BUILD_DEPENDENCIES_TASK_NAME = "installBuildDependencies";
    public static final String INSTALL_TEST_DEPENDENCIES_TASK_NAME = "installTestDependencies";
    public static final String TEST_TASK_NAME = "test";
    public static final String VENDOR_TASK_NAME = "vendor";
    public static final String COVERAGE_CHECK_TASK_NAME = "coverageCheck";

    public static final Map<String, Class<? extends Task>> TASKS = ImmutableMap.<String, Class<? extends Task>>builder()
            .put(PREPARE_TASK_NAME, PrepareTask.class)
            .put(RESOLVE_BUILD_DEPENDENCIES_TASK_NAME, ResolveBuildDependenciesTask.class)
            .put(RESOLVE_TEST_DEPENDENCIES_TASK_NAME, ResolveTestDependenciesTask.class)
            .put(DEPENDENCIES_TASK_NAME, DependenciesTask.class)
            .put(BUILD_TASK_NAME, BuildTask.class)
            .put(TEST_TASK_NAME, TestTask.class)
            .put(VENDOR_TASK_NAME, VendorTask.class)
            .put(INSTALL_BUILD_DEPENDENCIES_TASK_NAME, InstallBuildDependenciesTask.class)
            .put(INSTALL_TEST_DEPENDENCIES_TASK_NAME, InstallTestDependenciesTask.class)
            .put(CLEAN_TASK_NAME, CleanTask.class)
            .put(CHECK_TASK_NAME, CheckTask.class)
            .put(LOCK_TASK_NAME, LockTask.class)
            .build();

    private Map<Class<? extends Task>, Task> tasks = new HashMap<>();

    public <T extends Task> void put(Class<T> clazz, T task) {
        this.tasks.put(clazz, task);
    }

    @SuppressWarnings("unchecked")
    public <T extends Task> T get(Class<T> clazz) {
        return (T) this.tasks.get(clazz);
    }
}

@@ -36,24 +36,194 @@
 adle.task;%0A%0A
+import com.github.blindpirate.gogradle.ide.GoglandTask;%0Aimport com.github.blindpirate.gogradle.ide.IdeaTask;%0Aimport com.github.blindpirate.gogradle.ide.RenameVendorTask;%0A
 import com.g
@@ -253,24 +253,24 @@
 mutableMap;%0A
-
 import org.g
@@ -1395,16 +1395,213 @@
 endor%22;%0A
+    public static final String IDEA_TASK_NAME = %22ideaGolang%22;%0A    public static final String GOGLAND_TASK_NAME = %22gogland%22;%0A    public static final String RENAME_VENDOR_TASK_NAME = %22renameVendor%22;%0A
     publ
@@ -2516,32 +2516,32 @@
 heckTask.class)%0A
-
             .put
@@ -2565,32 +2565,202 @@
 LockTask.class)%0A
+            .put(IDEA_TASK_NAME, IdeaTask.class)%0A            .put(GOGLAND_TASK_NAME, GoglandTask.class)%0A            .put(RENAME_VENDOR_TASK_NAME, RenameVendorTask.class)%0A
             .bui

Add IDE tasks