File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
gradle/build-logic/common-plugins/src/main/kotlin/tasks Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ package tasks
2+
3+ import org.gradle.api.file.DirectoryProperty
4+ import org.gradle.api.file.RegularFileProperty
5+ import org.gradle.api.tasks.*
6+
7+ /* *
8+ * A sample [JavaExec] task that executes class from runtime classpath is as follows:
9+ * ```kotlin
10+ * val execTask by registering(JavaExec::class) {
11+ * doFirst { ... }
12+ * group = "build"
13+ * mainClass = "app.Main"
14+ * classpath = sourceSets.main.get().runtimeClasspath
15+ * args = listOf(....)
16+ * outputs.dir(outDir)
17+ * doLast { }
18+ * finalizedBy(copyTask)
19+ * }
20+ * ```
21+ */
22+ @CacheableTask
23+ abstract class ExecTask : JavaExec () {
24+
25+ @get:InputFile
26+ @get:PathSensitive(PathSensitivity .RELATIVE )
27+ abstract val sourceFile: RegularFileProperty
28+
29+ @get:OutputDirectory abstract val outputDir: DirectoryProperty
30+
31+ init {
32+ group = " build"
33+ mainClass.set(" app.Main" )
34+ argumentProviders.add { listOf (outputDir.get().asFile.path, sourceFile.get().asFile.path) }
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments