Skip to content

Commit

Permalink
fix(Issue-1788): replace deleted task report
Browse files Browse the repository at this point in the history
Signed-off-by: l-1squared <[email protected]>
  • Loading branch information
l-1squared committed Nov 28, 2024
1 parent 37787bd commit 11e0048
Showing 1 changed file with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -67,23 +80,23 @@ public AbstractReportGenerator createGenerator() {
@Internal
public abstract ReportGenerator.Format getFormat();

@Override public File getCustomCssFile() {
@Override @Nullable public File getCustomCssFile() {
return customCssFile;
}

@Override public void setCustomCssFile( File customCssFile ) {
this.customCssFile = customCssFile;
}

@Override public File getCustomJsFile() {
@Override @Nullable public File getCustomJsFile() {
return customJsFile;
}

@Override public void setCustomJsFile( File customJsFile ) {
this.customJsFile = customJsFile;
}

@Override public String getTitle() {
@Override @Nullable public String getTitle() {
return title;
}

Expand All @@ -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<Boolean> 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);
}

}

0 comments on commit 11e0048

Please sign in to comment.