package com.github.blindpirate.gogradle.task;

import com.github.blindpirate.gogradle.build.BuildManager;
import com.github.blindpirate.gogradle.core.dependency.GolangDependency;
import com.github.blindpirate.gogradle.core.dependency.tree.DependencyTreeNode;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;

import static com.github.blindpirate.gogradle.core.GolangTaskContainer.RESOLVE_TASK_NAME;

public class InstallDependenciesTask extends AbstractGolangTask {
    @Inject
    private BuildManager buildManager;

    public InstallDependenciesTask() {
        dependsOn(RESOLVE_TASK_NAME);
    }

    @TaskAction
    void installDependencies() {
        DependencyTreeNode rootNode = getTask(ResolveTask.class).getDependencyTree();
        rootNode.flatten()
                .stream()
                .map(GolangDependency::resolve)
                .forEach(buildManager::installDependency);
    }
}

@@ -368,20 +368,20 @@
 ogradle.
-core
+task
 .GolangT
@@ -413,16 +413,79 @@
 _NAME;%0A%0A
+// TODO old dependencies should be deleted before installation%0A
 public c
@@ -698,16 +698,23 @@
 ion%0A    
+public 
 void ins

move GolangTaskContaner to task package