diff --git a/README.md b/README.md index 644feb6..18a4afb 100644 --- a/README.md +++ b/README.md @@ -115,14 +115,14 @@ test 1 - 213 ms :active, 2022-11-08T20:46:17.854+0100, 2022-11-08T20:46:18.067+0 Options: -| Key | Type | Description | Default | -|-------------------------------------------|---------|--------------------------------------------------------------------|------------------------------------------------------------| -| `formats.html.enabled` | boolean | Generate report in html format | `true` | -| `formats.html.script.embed` | boolean | If true mermaid source will be downloaded and used locally in html | `false` | -| `formats.html.script.src` | url | Url to mermaid which should be used to generate html report | `https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js` | -| `formats.html.mermaid.config.maxTextSize` | int | Limit on the size of text used to generate diagrams | `50000` | -| `formats.json.enabled` | boolean | Generate report in json format | `true` | -| `formats.mermaid.enabled` | boolean | Generate report in mermaid text format | `true` | +| Key | Type | Description | Default | +|------------------------------------------|---------|--------------------------------------------------------------------|------------------------------------------------------------| +| `formats.html.enabled` | boolean | Generate report in html format | `true` | +| `formats.html.script.embed` | boolean | If true mermaid source will be downloaded and used locally in html | `false` | +| `formats.html.script.src` | url | Url to mermaid which should be used to generate html report | `https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js` | +| `formats.html.script.config.maxTextSize` | int | Limit on the size of text used to generate diagrams | `50000` | +| `formats.json.enabled` | boolean | Generate report in json format | `true` | +| `formats.mermaid.enabled` | boolean | Generate report in mermaid text format | `true` | `build.gradle.kts`: @@ -131,13 +131,11 @@ configure { ) { task.getFormats().getHtml().outputLocation .set(createTestsExecutionReportExtension.getFormats().getHtml().outputLocation) - task.getFormats().getHtml().getMermaid().getConfig() + task.getFormats().getHtml().getScript().getConfig() .maxTextSize.set( - createTestsExecutionReportExtension.getFormats().getHtml().getMermaid().getConfig().maxTextSize + createTestsExecutionReportExtension.getFormats().getHtml().getScript().getConfig().maxTextSize ) task.getFormats().getHtml().getScript().src .set(createTestsExecutionReportExtension.getFormats().getHtml().getScript().src) diff --git a/src/main/kotlin/io/github/platan/tests_execution_chart/config/Html.kt b/src/main/kotlin/io/github/platan/tests_execution_chart/config/Html.kt index 1df497e..817a632 100644 --- a/src/main/kotlin/io/github/platan/tests_execution_chart/config/Html.kt +++ b/src/main/kotlin/io/github/platan/tests_execution_chart/config/Html.kt @@ -9,14 +9,7 @@ abstract class Html @Inject constructor(objectFactory: ObjectFactory) : Format(o @Nested abstract fun getScript(): Script - @Nested - abstract fun getMermaid(): HtmlMermaid - open fun script(action: Action) { action.execute(getScript()) } - - open fun mermaid(action: Action) { - action.execute(getMermaid()) - } } diff --git a/src/main/kotlin/io/github/platan/tests_execution_chart/config/HtmlMermaid.kt b/src/main/kotlin/io/github/platan/tests_execution_chart/config/HtmlMermaid.kt deleted file mode 100644 index 2b22cfd..0000000 --- a/src/main/kotlin/io/github/platan/tests_execution_chart/config/HtmlMermaid.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.github.platan.tests_execution_chart.config - -import org.gradle.api.Action -import org.gradle.api.model.ObjectFactory -import org.gradle.api.tasks.Nested -import javax.inject.Inject - -abstract class HtmlMermaid @Inject constructor(objectFactory: ObjectFactory) : Format(objectFactory, "mermaid") { - @Nested - abstract fun getConfig(): HtmlMermaidConfig - - open fun config(action: Action) { - action.execute(getConfig()) - } -} diff --git a/src/main/kotlin/io/github/platan/tests_execution_chart/config/Script.kt b/src/main/kotlin/io/github/platan/tests_execution_chart/config/Script.kt index 9caedca..6fd0d03 100644 --- a/src/main/kotlin/io/github/platan/tests_execution_chart/config/Script.kt +++ b/src/main/kotlin/io/github/platan/tests_execution_chart/config/Script.kt @@ -1,8 +1,10 @@ package io.github.platan.tests_execution_chart.config +import org.gradle.api.Action import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Nested import javax.inject.Inject private const val DEFAULT_SRC = "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js" @@ -14,4 +16,11 @@ abstract class Script @Inject constructor(objectFactory: ObjectFactory) { @get:Input val embed: Property = objectFactory.property(Boolean::class.java).convention(false) + + @Nested + abstract fun getConfig(): ScriptConfig + + open fun config(action: Action) { + action.execute(getConfig()) + } } diff --git a/src/main/kotlin/io/github/platan/tests_execution_chart/config/HtmlMermaidConfig.kt b/src/main/kotlin/io/github/platan/tests_execution_chart/config/ScriptConfig.kt similarity index 80% rename from src/main/kotlin/io/github/platan/tests_execution_chart/config/HtmlMermaidConfig.kt rename to src/main/kotlin/io/github/platan/tests_execution_chart/config/ScriptConfig.kt index 41fe2e0..9b3f651 100644 --- a/src/main/kotlin/io/github/platan/tests_execution_chart/config/HtmlMermaidConfig.kt +++ b/src/main/kotlin/io/github/platan/tests_execution_chart/config/ScriptConfig.kt @@ -7,7 +7,7 @@ import javax.inject.Inject private const val MAX_TEXT_SIZE = 50_000 -abstract class HtmlMermaidConfig @Inject constructor(objectFactory: ObjectFactory) { +abstract class ScriptConfig @Inject constructor(objectFactory: ObjectFactory) { @get:Input val maxTextSize: Property = objectFactory.property(Int::class.java).convention(MAX_TEXT_SIZE) diff --git a/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlGanttDiagramReporter.kt b/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlGanttDiagramReporter.kt index 660248b..a211762 100644 --- a/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlGanttDiagramReporter.kt +++ b/src/main/kotlin/io/github/platan/tests_execution_chart/reporters/html/HtmlGanttDiagramReporter.kt @@ -35,7 +35,7 @@ internal class HtmlGanttDiagramReporter(private val config: Html, private val lo downloadFile(URL(src), "${reportsDir.absolutePath}/$scriptFileName") src = scriptFileName } - val maxTextSize = config.getMermaid().getConfig().maxTextSize.get() + val maxTextSize = config.getScript().getConfig().maxTextSize.get() val htmlReport = template .replace(GRAPH_PLACEHOLDER, mermaid) .replace(MERMAID_SRC_PLACEHOLDER, src) diff --git a/test-projects/spock-single-module/build.gradle b/test-projects/spock-single-module/build.gradle index 04d0705..e1242fc 100644 --- a/test-projects/spock-single-module/build.gradle +++ b/test-projects/spock-single-module/build.gradle @@ -22,12 +22,12 @@ createTestsExecutionReport { formats { html { enabled = true - mermaid { + script { config { maxTextSize = 990 } + src = 'https://cdn.jsdelivr.net/npm/mermaid@8.13.3/dist/mermaid.js' } - script { src = 'https://cdn.jsdelivr.net/npm/mermaid@8.13.3/dist/mermaid.js' } } json { enabled = true } mermaid { enabled = true }