Skip to content

Commit

Permalink
JS unit testing task will be skipped if there are no tests in the pro…
Browse files Browse the repository at this point in the history
…ject
  • Loading branch information
mrapplexz committed Apr 10, 2019
1 parent 0ae9143 commit 1b01617
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
projectVersion=1.4.0
projectVersion=1.4.1
projectDescription=A Gradle plugin that simplifies the creation of %type% multiplatform Kotlin projects.
projectChangelog=MultiGradle now uses new Kotlin Multiplatform plugin
projectChangelog=JS unit testing task will be skipped if there are no tests in the project

nodeVersion=1.3.1
kotlinVersion=1.3.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import com.moowork.gradle.node.NodePlugin
import com.moowork.gradle.node.npm.NpmTask
import com.moowork.gradle.node.task.NodeTask
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.Sync
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import ru.pearx.multigradle.util.MultiGradleExtension
import ru.pearx.multigradle.util.invoke
import java.nio.file.Files

internal fun Project.jsInitializer() {
apply<NodePlugin>()
Expand Down Expand Up @@ -85,5 +88,18 @@ internal fun Project.jsInitializer() {
named<Test>("jsTest") {
dependsOn(jsTestRunMocha)
}

listOf<TaskProvider<out Task>>(jsTestRunMocha, jsTestSyncNodeModules, jsTestInstallPackages, named("npmSetup"), named("nodeSetup")).forEach { task ->
task.configure {
onlyIf {
try {
Files.newDirectoryStream(jsTestCompilation.output.classesDirs.first().toPath()).use { f -> f.iterator().hasNext() }
}
catch(e: Exception) {
false
}
}
}
}
}
}

0 comments on commit 1b01617

Please sign in to comment.