package com.github.blindpirate.gogradle.core;

import com.github.blindpirate.gogradle.core.dependency.DefaultDependencyResolutionStrategy;
import com.github.blindpirate.gogradle.core.dependency.DependencyHelper;
import com.github.blindpirate.gogradle.core.dependency.resolve.DependencyResolutionStrategy;
import com.github.blindpirate.gogradle.core.dependency.GolangDependencySet;
import com.github.blindpirate.gogradle.core.dependency.GolangDependency;
import com.github.blindpirate.gogradle.core.pack.AbstractPakcageModule;
import org.gradle.api.artifacts.Dependency;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * A {@link FileSystemModule} is a directory in file system,
 * regardless of stable or transient
 */
public abstract class FileSystemModule extends AbstractPakcageModule implements GolangDependency {

    private Path rootDir;

    private long updateTime;

    private GolangDependencySet dependencies;

    private DependencyResolutionStrategy dependencyResolutionStrategy
            = new DefaultDependencyResolutionStrategy();

    // Interface method in Dependency. Do not implement them temporarily.
    @Override
    public String getGroup() {
        return null;
    }

    @Override
    public String getVersion() {
        return null;
    }

    @Override
    public boolean contentEquals(Dependency dependency) {
        return false;
    }

    @Override
    public Dependency copy() {
        return null;
    }

    public abstract GolangPackageModule vendor(Path relativePathToVendor);

    protected void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    public FileSystemModule(String name, Path rootDir) {
        super(name);
        this.rootDir = rootDir;
    }

    protected Path addVendorPrefix(Path relativePathToVendor) {
        String relativeToParentModule = "vendor" + File.separator + relativePathToVendor;
        return Paths.get(relativeToParentModule);
    }

    public GolangDependencySet getDependencies() {
        if (dependencies == null) {
            dependencies =
                    DependencyHelper.resolveDirectDependencies(dependencyResolutionStrategy, this);
        }
        return dependencies;
    }

    @Override
    public Path getRootDir() {
        return rootDir;
    }

    @Override
    public long getUpdateTime() {
        return updateTime;
    }

    @Override
    public GolangPackageModule getPackage() {
        return this;
    }

}

@@ -101,207 +101,22 @@
 y.De
-faultDependencyResolutionStrategy;%0Aimport com.github.blindpirate.gogradle.core.dependency.DependencyHelper;%0Aimport com.github.blindpirate.gogradle.core.dependency.resolve.DependencyResolutionStrategy
+pendencyHelper
 ;%0Aim
@@ -184,19 +184,16 @@
 pendency
-Set
 ;%0Aimport
@@ -249,32 +249,35 @@
 GolangDependency
+Set
 ;%0Aimport com.git
@@ -313,34 +313,34 @@
 .pack.AbstractPa
-k
 c
+k
 ageModule;%0Aimpor
@@ -337,52 +337,8 @@
 ule;
-%0Aimport org.gradle.api.artifacts.Dependency;
 %0A%0Aim
@@ -579,10 +579,10 @@
 ctPa
-k
 c
+k
 ageM
@@ -731,698 +731,77 @@
    p
-rivate DependencyResolutionStrategy dependencyResolutionStrategy%0A            = new DefaultDependencyResolutionStrategy();%0A%0A    // Interface method in Dependency. Do not implement them temporarily.%0A    @Override%0A    public String getGroup() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public String getVersion() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public boolean contentEquals(Dependency dependency) %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    public Dependency copy() %7B%0A        return null;%0A    %7D%0A%0A    public abstract GolangPackageModule vendor(Path relativePathToVendor);%0A%0A    protected void setUpdateTime(long updateTime) %7B%0A        this.updateTime = updateTime;%0A    %7D
+ublic abstract GolangPackageModule vendor(Path relativePathToVendor);
 %0A%0A  
@@ -851,16 +851,33 @@
  rootDir
+, long updateTime
 ) %7B%0A    
@@ -917,32 +917,70 @@
 tDir = rootDir;%0A
+        this.updateTime = updateTime;%0A
     %7D%0A%0A    prote
@@ -1298,102 +1298,46 @@
 es =
-%0A                    DependencyHelper.resolveDirectDependencies(dependencyResolutionStrategy, 
+ DependencyHelper.produceDependencies(
 this

remove redundant methods