package nu.studer.gradle.rocker;

import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.ProjectLayout;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputDirectory;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SkipWhenEmpty;

import javax.inject.Inject;

public class RockerConfig {

    final String name;

    private final Property<Boolean> optimize;
    private final Property<String> extendsClass;
    private final Property<String> extendsModelClass;
    private final Property<String> javaVersion;
    private final Property<String> targetCharset;

    private final DirectoryProperty templateDir;
    private final DirectoryProperty outputDir;
    private final DirectoryProperty classDir;

    @Inject
    public RockerConfig(String name, ObjectFactory objects, ProjectLayout layout) {
        this.name = name;

        this.optimize = objects.property(Boolean.class).convention(Boolean.FALSE);
        this.extendsClass = objects.property(String.class).convention((String) null);
        this.extendsModelClass = objects.property(String.class).convention((String) null);
        this.javaVersion = objects.property(String.class).convention(Runtime.class.getPackage().getSpecificationVersion());
        this.targetCharset = objects.property(String.class).convention("UTF-8");

        this.templateDir = objects.directoryProperty().convention(layout.getProjectDirectory().dir("src/rocker/" + name));
        this.outputDir = objects.directoryProperty().convention(layout.getBuildDirectory().dir("generated-src/rocker/" + name));
        this.classDir = objects.directoryProperty().convention(layout.getBuildDirectory().dir("rocker-hot-reload/" + name));
    }

    @Input
    public Property<Boolean> getOptimize() {
        return optimize;
    }

    @Optional
    @Input
    public Property<String> getExtendsClass() {
        return extendsClass;
    }

    @Optional
    @Input
    public Property<String> getExtendsModelClass() {
        return extendsModelClass;
    }

    @Optional
    @Input
    public Property<String> getJavaVersion() {
        return javaVersion;
    }

    @Optional
    @Input
    public Property<String> getTargetCharset() {
        return targetCharset;
    }

    @SkipWhenEmpty
    @InputDirectory
    @PathSensitive(PathSensitivity.RELATIVE)
    public DirectoryProperty getTemplateDir() {
        return templateDir;
    }

    // declared as output on RockerCompile task
    @Internal
    public DirectoryProperty getOutputDir() {
        return outputDir;
    }

    // do not include in uptodate check, not as input nor as output
    @Internal
    public DirectoryProperty getClassDir() {
        return classDir;
    }

    @Override
    public String toString() {
        return "RockerConfig{" +
            "name='" + name + '\'' +
            ", optimize=" + optimize +
            ", extendsClass='" + extendsClass + '\'' +
            ", extendsModelClass='" + extendsModelClass + '\'' +
            ", javaVersion='" + javaVersion + '\'' +
            ", targetCharset='" + targetCharset + '\'' +
            ", templateDir=" + templateDir +
            ", outputDir=" + outputDir +
            ", classDir=" + classDir +
            '}';
    }

}

@@ -2982,539 +2982,6 @@
  %7D%0A%0A
-    @Override%0A    public String toString() %7B%0A        return %22RockerConfig%7B%22 +%0A            %22name='%22 + name + '%5C'' +%0A            %22, optimize=%22 + optimize +%0A            %22, extendsClass='%22 + extendsClass + '%5C'' +%0A            %22, extendsModelClass='%22 + extendsModelClass + '%5C'' +%0A            %22, javaVersion='%22 + javaVersion + '%5C'' +%0A            %22, targetCharset='%22 + targetCharset + '%5C'' +%0A            %22, templateDir=%22 + templateDir +%0A            %22, outputDir=%22 + outputDir +%0A            %22, classDir=%22 + classDir +%0A            '%7D';%0A    %7D%0A%0A
 %7D%0A

Remove toString() implementation