diff --git a/src/main/kotlin/de/smartsquare/squit/SquitPlugin.kt b/src/main/kotlin/de/smartsquare/squit/SquitPlugin.kt index c8c1698b..eb87381a 100644 --- a/src/main/kotlin/de/smartsquare/squit/SquitPlugin.kt +++ b/src/main/kotlin/de/smartsquare/squit/SquitPlugin.kt @@ -29,6 +29,7 @@ class SquitPlugin : Plugin { it.extension = extension it.dependsOn("squitPreProcess") + it.outputs.upToDateWhen { false } } project.tasks.create("squitPostProcess", SquitPostProcessTask::class.java) { diff --git a/src/main/kotlin/de/smartsquare/squit/task/SquitPostProcessTask.kt b/src/main/kotlin/de/smartsquare/squit/task/SquitPostProcessTask.kt index a0d145a6..ea408ec3 100644 --- a/src/main/kotlin/de/smartsquare/squit/task/SquitPostProcessTask.kt +++ b/src/main/kotlin/de/smartsquare/squit/task/SquitPostProcessTask.kt @@ -33,7 +33,7 @@ open class SquitPostProcessTask : DefaultTask() { /** * The directory of the test sources. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @InputDirectory val processedSourcesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, SOURCES_DIRECTORY) @@ -41,7 +41,7 @@ open class SquitPostProcessTask : DefaultTask() { /** * The directory of the previously requested responses. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @InputDirectory val actualResponsesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, RESPONSES_DIRECTORY, RAW_DIRECTORY) @@ -49,7 +49,7 @@ open class SquitPostProcessTask : DefaultTask() { /** * The directory to save the results in. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @OutputDirectory val processedActualResponsesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, RESPONSES_DIRECTORY, PROCESSED_DIRECTORY) diff --git a/src/main/kotlin/de/smartsquare/squit/task/SquitPreProcessTask.kt b/src/main/kotlin/de/smartsquare/squit/task/SquitPreProcessTask.kt index c598dad2..b42611af 100644 --- a/src/main/kotlin/de/smartsquare/squit/task/SquitPreProcessTask.kt +++ b/src/main/kotlin/de/smartsquare/squit/task/SquitPreProcessTask.kt @@ -43,7 +43,7 @@ open class SquitPreProcessTask : DefaultTask() { /** * The tags to filter by. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:Input val tags = when (project.hasProperty("tags")) { true -> project.property("tags") as String? @@ -53,14 +53,14 @@ open class SquitPreProcessTask : DefaultTask() { /** * If all excluded or ignored tests should be run nevertheless. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:Input val shouldUnexclude by lazy { project.properties.containsKey("unexclude") } /** * The properties of the project parsed into a [Config] object. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:Input val projectConfig: Config by lazy { ConfigValueFactory.fromMap(project.properties @@ -72,14 +72,14 @@ open class SquitPreProcessTask : DefaultTask() { /** * The directory of the test sources. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:InputDirectory val sourcesPath by lazy { extension.sourcesPath } /** * The directory to save the results in. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:OutputDirectory val processedSourcesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, SOURCES_DIRECTORY) diff --git a/src/main/kotlin/de/smartsquare/squit/task/SquitRequestTask.kt b/src/main/kotlin/de/smartsquare/squit/task/SquitRequestTask.kt index a4983c97..0befd357 100644 --- a/src/main/kotlin/de/smartsquare/squit/task/SquitRequestTask.kt +++ b/src/main/kotlin/de/smartsquare/squit/task/SquitRequestTask.kt @@ -57,7 +57,7 @@ open class SquitRequestTask : DefaultTask() { /** * The class name of the jdbc [Driver] to use. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:Input val jdbcDriverClassNames by lazy { extension.jdbcDrivers @@ -73,7 +73,7 @@ open class SquitRequestTask : DefaultTask() { /** * The directory of the test sources. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:InputDirectory val processedSourcesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, SOURCES_DIRECTORY) @@ -81,7 +81,7 @@ open class SquitRequestTask : DefaultTask() { /** * The directory to save the results in. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:OutputDirectory val actualResponsesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, RESPONSES_DIRECTORY, RAW_DIRECTORY) diff --git a/src/main/kotlin/de/smartsquare/squit/task/SquitTestTask.kt b/src/main/kotlin/de/smartsquare/squit/task/SquitTestTask.kt index 5eeb1c7b..7d7ba73e 100644 --- a/src/main/kotlin/de/smartsquare/squit/task/SquitTestTask.kt +++ b/src/main/kotlin/de/smartsquare/squit/task/SquitTestTask.kt @@ -2,6 +2,7 @@ package de.smartsquare.squit.task import com.typesafe.config.Config import com.typesafe.config.ConfigFactory +import com.typesafe.config.Optional import de.smartsquare.squit.SquitExtension import de.smartsquare.squit.entity.SquitResult import de.smartsquare.squit.io.FilesUtils @@ -11,7 +12,9 @@ import de.smartsquare.squit.report.XmlReportWriter import de.smartsquare.squit.util.Constants.CONFIG import de.smartsquare.squit.util.Constants.DIFF import de.smartsquare.squit.util.Constants.ERROR +import de.smartsquare.squit.util.Constants.META import de.smartsquare.squit.util.Constants.PROCESSED_DIRECTORY +import de.smartsquare.squit.util.Constants.RAW_DIRECTORY import de.smartsquare.squit.util.Constants.RESPONSES_DIRECTORY import de.smartsquare.squit.util.Constants.SOURCES_DIRECTORY import de.smartsquare.squit.util.Constants.SQUIT_DIRECTORY @@ -22,6 +25,7 @@ import okhttp3.MediaType import org.gradle.api.DefaultTask import org.gradle.api.GradleException import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Internal import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.OutputFile @@ -31,6 +35,7 @@ import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths import kotlin.properties.Delegates +import kotlin.streams.toList /** * Task for comparing the actual responses to the expected responses and generating a report. @@ -43,23 +48,41 @@ open class SquitTestTask : DefaultTask() { /** * The directory of the test sources. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:InputDirectory val processedSourcesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, SOURCES_DIRECTORY) /** - * The directory of the previously requested responses. + * The directory of the previously (processed) requested responses. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:InputDirectory val processedResponsesPath: Path = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, RESPONSES_DIRECTORY, PROCESSED_DIRECTORY) + /** + * Collection of meta.json files for up-to-date checking. + */ + @Suppress("MemberVisibilityCanBePrivate", "unused") + @get:InputFiles + @get:Optional + val metaPaths: List by lazy { + val rawDirectoryPath = Paths.get(project.buildDir.path, SQUIT_DIRECTORY, RESPONSES_DIRECTORY, RAW_DIRECTORY) + + if (Files.exists(rawDirectoryPath)) { + Files.walk(rawDirectoryPath).use { stream -> + stream.filter { Files.isRegularFile(it) && it.fileName.toString() == META }.toList() + } + } else { + emptyList() + } + } + /** * The directory to generate the xml report file into. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:OutputFile val xmlReportFilePath: Path by lazy { extension.reportsPath.resolve("xml").resolve("main.xml") @@ -68,7 +91,7 @@ open class SquitTestTask : DefaultTask() { /** * The directory to generate the xml report file into. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:OutputDirectory val htmlReportDirectoryPath: Path by lazy { extension.reportsPath.resolve("html") @@ -77,7 +100,7 @@ open class SquitTestTask : DefaultTask() { /** * The directory to copy failed tests into. */ - @Suppress("MemberVisibilityCanPrivate") + @Suppress("MemberVisibilityCanBePrivate") @get:OutputDirectory val failureResultDirectory by lazy { extension.reportsPath.resolve("failures") ?: throw IllegalArgumentException("reportPath cannot be null")