generated from cortinico/kotlin-gradle-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9df635c
commit 94fde53
Showing
10 changed files
with
101 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
plugins { | ||
java | ||
id("com.ncorti.kotlin.gradle.template.plugin") | ||
id("org.skriptlang.gradle.test.plugin") | ||
} | ||
|
||
templateExampleConfig { | ||
message.set("Just trying this gradle plugin...") | ||
tasks.skriptTest { | ||
extraPluginsDirectory = File("build.gradle.kts") | ||
testScriptDirectory = File("build.gradle.kts") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
ID=com.ncorti.kotlin.gradle.template.plugin | ||
ID=org.skriptlang.gradle.test.plugin | ||
VERSION=1.0.0 | ||
GROUP=com.ncorti.kotlin.gradle.template | ||
DISPLAY_NAME=An empty Gradle Plugin from a template | ||
DESCRIPTION=An empty Gradle plugin created from a template | ||
WEBSITE=https://github.com/cortinico/kotlin-gradle-plugin-template | ||
VCS_URL=https://github.com/cortinico/kotlin-gradle-plugin-template | ||
IMPLEMENTATION_CLASS=com.ncorti.kotlin.gradle.template.plugin.TemplatePlugin | ||
GROUP=org.skriptlang.gradle.test | ||
DISPLAY_NAME=A Gradle plugin to run Skript tests | ||
DESCRIPTION=A Gradle plugin to run Skript tests | ||
WEBSITE=https://github.com/SkriptLang/skript-test-gradle-plugin | ||
VCS_URL=https://github.com/SkriptLang/skript-test-gradle-plugin | ||
IMPLEMENTATION_CLASS=org.skriptlang.gradle.test.plugin.TemplatePlugin |
42 changes: 0 additions & 42 deletions
42
...uild/plugin/src/main/java/com/ncorti/kotlin/gradle/template/plugin/TemplateExampleTask.kt
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...-build/plugin/src/main/java/com/ncorti/kotlin/gradle/template/plugin/TemplateExtension.kt
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
plugin-build/plugin/src/main/java/com/ncorti/kotlin/gradle/template/plugin/TemplatePlugin.kt
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
plugin-build/plugin/src/main/java/org/skriptlang/gradle/test/plugin/SkriptTestTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.skriptlang.gradle.test.plugin | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.plugins.BasePlugin | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFile | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.options.Option | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
abstract class SkriptTestTask : DefaultTask() { | ||
init { | ||
description = "Run Skript tests" | ||
group = BasePlugin.BUILD_GROUP | ||
} | ||
|
||
@get:InputFile | ||
@get:Option(option = "testScriptDirectory", description = "The directory containing the test scripts to run") | ||
abstract val testScriptDirectory: RegularFileProperty | ||
|
||
@get:InputFile | ||
@get:Option(option = "extraPluginsDirectory", description = "The directory of extra plugins to put on the test server") | ||
abstract val extraPluginsDirectory: RegularFileProperty | ||
|
||
@get:Input | ||
@get:Option(option = "skriptRepoRef", description = "The Git ref to check out the Skript repo at") | ||
@get:Optional | ||
abstract val skriptRepoRef: Property<String> | ||
|
||
@get:Input | ||
@get:Option(option = "skriptRepo", description = "The Git URL to the Skript repo") | ||
@get:Optional | ||
abstract val skriptRepo: Property<String> | ||
|
||
@get:Input | ||
@get:Option(option = "runVanillaTests", description = "Controls whether the vanilla Skript tests are run") | ||
@get:Optional | ||
abstract val runVanillaTests: Property<Boolean> | ||
|
||
fun runCommand(requiredExitValue: Int, workingDirectory: Path, vararg command: String) { | ||
val processBuilder = ProcessBuilder(command.asList()).directory(workingDirectory.toFile()) | ||
val process = processBuilder.start() | ||
process.waitFor() | ||
if (process.exitValue() != requiredExitValue) { | ||
throw IllegalStateException("${command.joinToString(" ")} returned exit code ${process.exitValue()}") | ||
} | ||
} | ||
|
||
@TaskAction | ||
fun runTests() { | ||
val skriptRepoDir = Files.createTempDirectory("skript-test-skript-repo").toAbsolutePath() | ||
runCommand(0, skriptRepoDir, "git", "init") | ||
runCommand(0, skriptRepoDir, "git", "remote", "add", "origin", skriptRepo.getOrElse("https://github.com/SkriptLang/Skript.git")) | ||
runCommand(0, skriptRepoDir, "git", "fetch", "--depth", "1", "origin", skriptRepoRef.getOrElse("master")) | ||
runCommand(0, skriptRepoDir, "git", "checkout", "FETCH_HEAD") | ||
runCommand(0, skriptRepoDir, "git", "submodule", "update", "--init", "--depth", "1") | ||
try { | ||
runCommand(0, skriptRepoDir, "./gradlew.bat", "quick") | ||
} catch (exception: IllegalStateException) { | ||
throw IllegalStateException("Tests failed") | ||
} | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
plugin-build/plugin/src/main/java/org/skriptlang/gradle/test/plugin/TemplatePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.skriptlang.gradle.test.plugin | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
const val EXTENSION_NAME = "templateExampleConfig" | ||
|
||
abstract class TemplatePlugin : Plugin<Project> { | ||
override fun apply(project: Project) { | ||
project.tasks.register("skriptTest", SkriptTestTask::class.java) | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
...build/plugin/src/test/java/com/ncorti/kotlin/gradle/template/plugin/TemplatePluginTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters