Fix Gradle
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit

This commit is contained in:
TheBrokenRail 2020-05-30 22:15:53 -04:00
parent d8b0a1ddbe
commit 3bea7e841b
2 changed files with 17 additions and 10 deletions

View File

@ -5,18 +5,22 @@ import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.Exec import org.gradle.api.tasks.Exec
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
import java.io.File import java.io.File
import java.util.concurrent.Callable
class JNIPlugin : Plugin<Project> { class JNIPlugin : Plugin<Project> {
open class JNIConfig(private val project: Project) { open class JNIConfig(private val project: Project) {
fun addPlatform(name: String, libExtension: String) = project.run { var root: File = File(project.rootDir, "src/main/c")
val cDir = File(projectDir.absolutePath, "src/main/c")
val buildDir = File(cDir, "build-${name}") fun addPlatform(name: String, libExtension: String) = project.run {
val buildDir = Callable {
File(root, "build-${name}")
}
tasks.register<Exec>("cmake-${name}") { tasks.register<Exec>("cmake-${name}") {
doFirst { doFirst {
if (!buildDir.exists()) { val file = buildDir.call()
buildDir.mkdir() if (!file.exists()) {
file.mkdir()
} }
} }

View File

@ -15,8 +15,9 @@ class TypeScriptPlugin : Plugin<Project> {
open class NPMTask : DefaultTask() { open class NPMTask : DefaultTask() {
@get:Input @get:Input
lateinit var taskName: String lateinit var taskName: String
@get:Optional
@get:Input @get:Input
lateinit var outputDir: String var outputDir: String? = null
@TaskAction @TaskAction
fun exec() { fun exec() {
@ -39,14 +40,16 @@ class TypeScriptPlugin : Plugin<Project> {
} }
} }
@Optional
@OutputDirectory @OutputDirectory
fun getOutput(): Callable<File>? { fun getOutput(): Callable<File>? {
return if (this::outputDir.isInitialized) { val dir = outputDir
return if (dir != null) {
Callable { Callable {
if (File(outputDir).isAbsolute) { if (File(dir).isAbsolute) {
File(outputDir) File(dir)
} else { } else {
File(project.the<TypeScriptConfig>().root, outputDir) File(project.the<TypeScriptConfig>().root, dir)
} }
} }
} else { } else {