[gradle-plugin] Re-add an aggregate task to run all executables
This commit is contained in:
+4
-4
@@ -259,7 +259,7 @@ See more about multiplatform projects [here](https://kotlinlang.org/docs/referen
|
|||||||
|
|
||||||
The Kotlin/Native plugin creates the following tasks:
|
The Kotlin/Native plugin creates the following tasks:
|
||||||
|
|
||||||
* __compileKonan<ArtifactName><Target>__. The plugin creates such a task for each target declared in `konan.targets` list and
|
* __compileKonan\<ArtifactName>\<Target>__. The plugin creates such a task for each target declared in `konan.targets` list and
|
||||||
for each an artifact defined in a `konanArtifacts` block. Such a task may have different properties depending on the artifact type:
|
for each an artifact defined in a `konanArtifacts` block. Such a task may have different properties depending on the artifact type:
|
||||||
|
|
||||||
##### Properties available for a compiler task (executable, library or bitcode building task):
|
##### Properties available for a compiler task (executable, library or bitcode building task):
|
||||||
@@ -298,7 +298,7 @@ for each an artifact defined in a `konanArtifacts` block. Such a task may have d
|
|||||||
|`linkFiles `|`Collection<FileCollection>`|Additional files linked with the stubs |
|
|`linkFiles `|`Collection<FileCollection>`|Additional files linked with the stubs |
|
||||||
|
|
||||||
|
|
||||||
* __compileKonan<ArtifactName>__. Aggregate task allowing one to build an artifact for several targets. By default it builds
|
* __compileKonan\<ArtifactName>__. Aggregate task allowing one to build an artifact for several targets. By default it builds
|
||||||
the artifact for all supported targets declared for the project. One may change this behavior by specifying the space-separated
|
the artifact for all supported targets declared for the project. One may change this behavior by specifying the space-separated
|
||||||
target list in `konan.build.targets` project property:
|
target list in `konan.build.targets` project property:
|
||||||
|
|
||||||
@@ -311,13 +311,13 @@ target list in `konan.build.targets` project property:
|
|||||||
* __compileKonan__. Aggregate task to build all the Kotlin/Native artifacts for all available targets. `konan.build.targets` project
|
* __compileKonan__. Aggregate task to build all the Kotlin/Native artifacts for all available targets. `konan.build.targets` project
|
||||||
property also may be used to override the target list. The task has no properties to use by a build script.
|
property also may be used to override the target list. The task has no properties to use by a build script.
|
||||||
|
|
||||||
* __run<ArtifactName>__. Such a task is created for each executable supported by current host and allows one to run this
|
* __run\<ArtifactName>__. Such a task is created for each executable supported by current host and allows one to run this
|
||||||
executable. The task is an instance of Gradle's [`Exec`](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html)
|
executable. The task is an instance of Gradle's [`Exec`](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html)
|
||||||
so it supports all settings provided by `Exec`. Additionally, run parameters may be passed to the task using the `runArgs`
|
so it supports all settings provided by `Exec`. Additionally, run parameters may be passed to the task using the `runArgs`
|
||||||
project property:
|
project property:
|
||||||
|
|
||||||
```
|
```
|
||||||
./gradlew run -PrunArgs='foo bar'
|
./gradlew runFoo -PrunArgs='foo bar'
|
||||||
```
|
```
|
||||||
|
|
||||||
The plugin also edits the default `build` and `clean` tasks so that the first one allows one to build all the artifacts supported
|
The plugin also edits the default `build` and `clean` tasks so that the first one allows one to build all the artifacts supported
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ def tasksOf(Closure<Task> filter) {
|
|||||||
.matching { filter(it) && it.enabled && (prefix != null ? it.name.startsWith(prefix) : true) }
|
.matching { filter(it) && it.enabled && (prefix != null ? it.name.startsWith(prefix) : true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
task run {
|
run {
|
||||||
def tasks = tasksOf { it instanceof KonanTest && it.inDevelopersRun }
|
def tasks = tasksOf { it instanceof KonanTest && it.inDevelopersRun }
|
||||||
dependsOn(tasks)
|
dependsOn(tasks)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ konanArtifacts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runTensorflow.dependsOn 'warning'
|
tasks.findByName("runTensorflow")?.dependsOn 'warning'
|
||||||
|
|
||||||
task warning {
|
task warning {
|
||||||
doLast {
|
doLast {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ konanArtifacts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runTorch.dependsOn 'warning'
|
tasks.findByName("runTorch")?.dependsOn 'warning'
|
||||||
|
|
||||||
task warning {
|
task warning {
|
||||||
doLast {
|
doLast {
|
||||||
|
|||||||
+10
-1
@@ -341,7 +341,16 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
doLast { project.cleanKonan() }
|
doLast { project.cleanKonan() }
|
||||||
}
|
}
|
||||||
|
|
||||||
//project.gradle.experimentalFeatures.enable()
|
val runTask = project.getOrCreateTask("run")
|
||||||
|
project.afterEvaluate {
|
||||||
|
project.konanArtifactsContainer
|
||||||
|
.filterIsInstance(KonanProgram::class.java)
|
||||||
|
.forEach { program ->
|
||||||
|
program.forEach { compile ->
|
||||||
|
compile.runTask?.let { runTask.dependsOn(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Enable multiplatform support
|
// Enable multiplatform support
|
||||||
project.pluginManager.apply(KotlinNativePlatformPlugin::class.java)
|
project.pluginManager.apply(KotlinNativePlatformPlugin::class.java)
|
||||||
|
|||||||
@@ -50,11 +50,16 @@ class TaskTests {
|
|||||||
listOf("src", "bar", "kotlin"),
|
listOf("src", "bar", "kotlin"),
|
||||||
"main.kt",
|
"main.kt",
|
||||||
"fun main(args: Array<String>) = println(\"Run Bar: \${args[0]}, \${args[1]}\")")
|
"fun main(args: Array<String>) = println(\"Run Bar: \${args[0]}, \${args[1]}\")")
|
||||||
val result = project.createRunner()
|
val resultFoo = project.createRunner()
|
||||||
.withArguments("runFoo", "-PrunArgs=arg1 arg2")
|
.withArguments("runFoo", "-PrunArgs=arg1 arg2")
|
||||||
.build()
|
.build()
|
||||||
|
val resultAll = project.createRunner()
|
||||||
|
.withArguments("run", "-PrunArgs=arg1 arg2")
|
||||||
|
.build()
|
||||||
|
|
||||||
assertTrue(result.output.contains("Run Foo: arg1, arg2"), "No Foo output!")
|
assertTrue(resultFoo.output.contains("Run Foo: arg1, arg2"), "No Foo output for 'runFoo'")
|
||||||
assertTrue(!result.output.contains("Run Bar: "), "There is Bar output!")
|
assertFalse(resultFoo.output.contains("Run Bar: "), "There is Bar output for 'runFoo'")
|
||||||
|
assertTrue(resultAll.output.contains("Run Foo: arg1, arg2"), "No Foo output for 'run'")
|
||||||
|
assertTrue(resultAll.output.contains("Run Bar: arg1, arg2"), "No Bar output for 'run'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user