generated from DanySK/template-for-gradle-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
13 changed files
with
109 additions
and
197 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 |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
build/ | ||
.idea/ | ||
node_modules/ | ||
|
||
.DS_Store |
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
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/io/github/zuccherosintattico/gradle/CheckNodeTask.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,27 @@ | ||
package io.github.zuccherosintattico.gradle | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* A task to check if Node is installed. | ||
*/ | ||
open class CheckNodeTask : DefaultTask() { | ||
init { | ||
group = "Node" | ||
description = "Check if Node is installed" | ||
} | ||
|
||
/** | ||
* The task action to check if Node is installed. | ||
*/ | ||
@TaskAction | ||
fun checkNode() { | ||
val res = Runtime.getRuntime().runCatching { exec("node --version").waitFor() } | ||
if (res.isSuccess) { | ||
logger.quiet("Node is installed") | ||
} else { | ||
logger.error("Node is not installed") | ||
} | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/test/kotlin/io/github/zuccherosintattico/gradle/MyTests.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,52 @@ | ||
package io.github.zuccherosintattico.gradle | ||
|
||
import io.kotest.core.spec.style.AnnotationSpec | ||
import io.kotest.matchers.paths.shouldExist | ||
import org.gradle.testkit.runner.GradleRunner | ||
import java.io.File | ||
import java.nio.file.Files | ||
import kotlin.io.path.createTempDirectory | ||
|
||
class MyTests : AnnotationSpec() { | ||
|
||
@BeforeAll | ||
fun setup() { | ||
val testkitProperties = javaClass.classLoader.getResource("testkit-gradle.properties")?.readText() | ||
checkNotNull(testkitProperties) { | ||
"No file testkit-gradle.properties was generated" | ||
} | ||
} | ||
|
||
@Test | ||
fun `test the plugin`() { | ||
val folder = createTempDirectory("test") | ||
folder.shouldExist() | ||
|
||
val testResources = File("src/test/resources/plugin-base-env").toPath() | ||
Files.walk(testResources) | ||
.filter { it != testResources } | ||
.map { testResources.relativize(it) } | ||
.map { testResources.resolve(it) to folder.resolve(it) } | ||
.forEach { (source, destination) -> | ||
Files.createDirectories(destination.parent) | ||
Files.copy(source, destination) | ||
} | ||
|
||
println(folder.toFile()) | ||
|
||
val result = with(GradleRunner.create()) { | ||
withProjectDir(folder.toFile()) | ||
withArguments("compileTypescript", "--stacktrace") | ||
withPluginClasspath() | ||
build() | ||
} | ||
|
||
result.output.lines().forEach { println(it) } | ||
|
||
// ProcessBuilder("npx", "tsc", "--outDir", "./build/bin", "src/main/typescript/*.ts") | ||
// .directory(folder.toFile()) | ||
// .inheritIO() | ||
// .start() | ||
// .waitFor() | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
src/test/kotlin/org/danilopianini/gradle/test/TestingDSL.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/test/resources/org/danilopianini/gradle/test/test0/build.gradle.kts
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/test/resources/org/danilopianini/gradle/test/test0/settings.gradle.kts
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/test/resources/org/danilopianini/gradle/test/test0/test.yaml
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
plugins { | ||
id("io.github.zuccherosintattico.typescript-gradle-plugin") | ||
} | ||
typescript { | ||
sourceSet = "src/main/typescript" | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/resources/plugin-base-env/src/main/typescript/index.ts
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,10 @@ | ||
class Person { | ||
constructor(public name: string, public age: number) { | ||
} | ||
toString() { | ||
return `${this.name} is ${this.age} years old`; | ||
} | ||
} | ||
|
||
let p = new Person("John", 42); | ||
console.log(p.toString()); |