diff --git a/jgiven-gradle-plugin/src/main/java/com/tngtech/jgiven/gradle/internal/AbstractJGivenReportImpl.java b/jgiven-gradle-plugin/src/main/java/com/tngtech/jgiven/gradle/internal/AbstractJGivenReportImpl.java index 7b0ebf793c..254c147cbd 100644 --- a/jgiven-gradle-plugin/src/main/java/com/tngtech/jgiven/gradle/internal/AbstractJGivenReportImpl.java +++ b/jgiven-gradle-plugin/src/main/java/com/tngtech/jgiven/gradle/internal/AbstractJGivenReportImpl.java @@ -9,22 +9,35 @@ import com.tngtech.jgiven.report.html5.Html5ReportConfig; import com.tngtech.jgiven.report.text.PlainTextReportConfig; import com.tngtech.jgiven.report.text.PlainTextReportGenerator; +import groovy.lang.Closure; +import org.gradle.api.NonNullApi; import org.gradle.api.Task; -import org.gradle.api.reporting.internal.TaskGeneratedSingleDirectoryReport; +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.provider.Property; +import org.gradle.api.reporting.Report; import org.gradle.api.tasks.Internal; +import org.gradle.util.internal.ConfigureUtil; +import javax.annotation.Nullable; import java.io.File; -public abstract class AbstractJGivenReportImpl extends TaskGeneratedSingleDirectoryReport implements JGivenReport { +@NonNullApi +public abstract class AbstractJGivenReportImpl implements JGivenReport { private File customCssFile; private File customJsFile; private String title; private boolean excludeEmptyScenarios = false; private boolean thumbnailsAreShown = true; + private final String taskPath; + private final String name; + private final String relativeEntryPath; public AbstractJGivenReportImpl( String name, Task task, String relativeEntryPath ) { - super( name, task, relativeEntryPath ); + this.name = name; + this.taskPath = task.getPath(); + this.relativeEntryPath = relativeEntryPath; + this.getRequired().convention(false); } public AbstractReportGenerator createGenerator() { @@ -67,7 +80,7 @@ public AbstractReportGenerator createGenerator() { @Internal public abstract ReportGenerator.Format getFormat(); - @Override public File getCustomCssFile() { + @Override @Nullable public File getCustomCssFile() { return customCssFile; } @@ -75,7 +88,7 @@ public AbstractReportGenerator createGenerator() { this.customCssFile = customCssFile; } - @Override public File getCustomJsFile() { + @Override @Nullable public File getCustomJsFile() { return customJsFile; } @@ -83,7 +96,7 @@ public AbstractReportGenerator createGenerator() { this.customJsFile = customJsFile; } - @Override public String getTitle() { + @Override @Nullable public String getTitle() { return title; } @@ -107,4 +120,41 @@ public AbstractReportGenerator createGenerator() { this.thumbnailsAreShown = thumbnailsAreShown; } + @Override + public File getEntryPoint() { + return new File(this.getOutputLocation().getAsFile().getOrNull(), this.relativeEntryPath); + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDisplayName() { + return "Report generated by task '" + taskPath + "' (" + name + ")"; + } + + @Override + public abstract Property getRequired(); + + @Override + public abstract DirectoryProperty getOutputLocation(); + + @Override + @Deprecated + public void setDestination(File file) { + throw new UnsupportedOperationException("Use outputLocation instead"); + } + + @Override + public Report.OutputType getOutputType() { + return Report.OutputType.DIRECTORY; + } + + @Override + public Report configure(Closure configure) { + return ConfigureUtil.configureSelf(configure, this); + } + }