Switch To Kotlin Build Scripts
ScriptCraft/pipeline/head There was a failure building this commit Details

This commit is contained in:
TheBrokenRail 2020-05-25 17:21:56 -04:00
parent cdd27a708f
commit 1e16e2bd04
21 changed files with 463 additions and 493 deletions

12
Jenkinsfile vendored
View File

@ -27,5 +27,17 @@ pipeline {
}
}
}
stage('Build Examples') {
steps {
sh 'cd examples/typescript; ./gradlew build'
sh 'cd examples/javascript; ./gradlew build'
}
post {
success {
archiveArtifacts artifacts: 'examples/typescript/build/libs/*', fingerprint: true
archiveArtifacts artifacts: 'examples/javascript/build/libs/*', fingerprint: true
}
}
}
}
}

View File

@ -1,82 +0,0 @@
plugins {
id 'fabric-loom' version '0.2.7-SNAPSHOT'
id 'maven-publish'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
archivesBaseName = project.archives_base_name
version = project.minecraft_version as Object
group = project.maven_group as Object
minecraft {
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
}
apply from: './typescript.build.gradle'
apply from: './jni.build.gradle'
processResources {
inputs.property 'name', rootProject.name
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand 'name': rootProject.name
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
jar {
from 'LICENSE'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId archivesBaseName
artifact(remapJar) {
builtBy remapJar
}
artifact(apiJar) {
builtBy apiJar
}
}
}
repositories {
maven {
url '/data/maven'
}
}
}

111
build.gradle.kts Normal file
View File

@ -0,0 +1,111 @@
plugins {
id("fabric-loom") version "0.2.7-SNAPSHOT"
id("jni")
id("typescript")
`maven-publish`
}
minecraft {
}
base.archivesBaseName = project.property("archives_base_name") as String
version = project.property("minecraft_version")!!
group = project.property("maven_group")!!
dependencies {
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
mappings("net.fabricmc:yarn:${project.property("minecraft_version")}+build.${project.property("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.property("fabric_loader_version")}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_api_version")}")
}
tasks.register<Exec>("eslint") {
group = "verification"
workingDir(project.extra.get("typescriptRoot") as File)
executable("npm")
args("run", "eslint")
dependsOn(tasks["npmInstall"])
}
tasks.register<Exec>("typedoc") {
group = "documentation"
val typedocOut = File(project.extra.get("typescriptRoot") as File, "build/typedoc")
inputs.dir(project.extra.get("typescriptRoot") as File)
outputs.dir(typedocOut)
workingDir(project.extra.get("typescriptRoot") as File)
executable("npm")
args("run", "typedoc")
doFirst {
project.delete {
delete(typedocOut)
}
}
dependsOn(tasks["npmInstall"])
}
tasks.named<Copy>("processResources") {
inputs.property("name", rootProject.name)
from(sourceSets["main"].resources.srcDirs) {
include("fabric.mod.json")
expand("name" to rootProject.name)
}
from(sourceSets["main"].resources.srcDirs) {
exclude("fabric.mod.json")
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
artifacts {
add("archives", tasks["sourcesJar"])
}
tasks.named<Jar>("jar") {
from("LICENSE")
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = project.property("archives_base_name") as String
artifact(tasks["remapJar"])
artifact(tasks["apiJar"])
}
}
repositories {
maven {
url = uri("/data/maven")
}
}
}

View File

@ -0,0 +1,7 @@
repositories {
gradlePluginPortal()
}
plugins {
`kotlin-dsl`
}

View File

@ -0,0 +1,80 @@
val cDir = File(rootProject.projectDir.absolutePath, "src/main/c")
class JNIPlatform(val name: String, val libExtension: String, rootDir: File) {
val cmakeArgs: Array<String> = arrayOf("-DCMAKE_TOOLCHAIN_FILE=${rootDir.absolutePath}/cmake/${name}-toolchain.cmake")
}
val jniPlatforms = arrayOf(
JNIPlatform("linux-x86_64", ".so", rootDir),
JNIPlatform("linux-x86", ".so", rootDir),
JNIPlatform("linux-armhf", ".so", rootDir),
JNIPlatform("linux-arm64", ".so", rootDir),
JNIPlatform("windows-x86_64", ".dll", rootDir),
JNIPlatform("windows-x86", ".dll", rootDir)
)
tasks.register("cleanJNI") {
group = "jni"
}
tasks.register("compileJNI") {
group = "jni"
}
jniPlatforms.forEach {
val buildDir = File(cDir, "build-${it.name}")
if (!buildDir.exists()) {
buildDir.mkdir()
}
tasks.register<Exec>("cmake-${it.name}") {
group = "jni"
workingDir(buildDir)
executable("cmake")
args(it.cmakeArgs, "..")
}
tasks.register<Exec>("compileJNI-${it.name}") {
group = "jni"
workingDir(buildDir)
executable("make")
dependsOn(tasks["cmake-${it.name}"])
}
tasks.named("compileJNI") {
dependsOn(tasks["compileJNI-${it.name}"])
}
tasks.register<Delete>("cleanJNI-${it.name}") {
group = "jni"
delete(buildDir)
}
tasks.named("cleanJNI") {
dependsOn(tasks["cleanJNI-${it.name}"])
}
}
tasks.named("clean") {
dependsOn(tasks["cleanJNI"])
}
tasks.named<Copy>("processResources") {
dependsOn(tasks["compileJNI"])
jniPlatforms.forEach {
val buildDir = File(cDir, "build-${it.name}")
if (!buildDir.exists()) {
buildDir.mkdir()
}
val file = File(buildDir, "libscriptcraft${it.libExtension}")
inputs.files(file)
from(file.absolutePath) {
into(File("natives", it.name).path)
}
}
}

View File

@ -0,0 +1,101 @@
val typescriptRoot = File(rootDir.absolutePath, "src/main/ts")
extra.set("typescriptRoot", typescriptRoot)
val typescriptOut = File(typescriptRoot, "build/ts")
val nodeModules = File(typescriptRoot, "node_modules")
val typescriptDependencies = File(typescriptRoot, "build/dependencies")
configurations {
create("typescript") {
isTransitive = false
}
}
tasks.register<Sync>("extractTypescriptDependencies") {
group = "typescript"
dependsOn(configurations["typescript"])
from(Callable {
configurations["typescript"].map {
zipTree(it).matching {
exclude("META-INF", "META-INF/**")
}
}
})
into(typescriptDependencies)
}
tasks.register<Exec>("npmInstall") {
group = "typescript"
inputs.file(File(typescriptRoot, "package.json"))
outputs.dir(nodeModules)
workingDir(typescriptRoot)
executable("npm")
args("install")
doFirst {
project.delete {
delete(nodeModules)
}
}
dependsOn(tasks["extractTypescriptDependencies"])
}
tasks.register<Exec>("typescript") {
group = "typescript"
inputs.dir(typescriptRoot)
outputs.dirs(typescriptOut)
workingDir(typescriptRoot)
executable("npm")
args("run", "build")
doFirst {
project.delete {
delete(typescriptOut)
}
}
dependsOn(tasks["npmInstall"])
}
tasks.register<Jar>("apiJar") {
group = "typescript"
val dtsOut = File(typescriptRoot, "build/dts")
into("/types") {
from(File(typescriptRoot, "types"))
}
into("/src") {
from(dtsOut)
}
archiveClassifier.set("api")
dependsOn(tasks["typescript"])
}
artifacts {
add("archives", tasks["apiJar"])
}
tasks.named<Copy>("processResources") {
dependsOn(tasks["typescript"])
from(typescriptOut.absolutePath) {
into("scriptcraft")
}
}

View File

@ -1,67 +0,0 @@
plugins {
id 'fabric-loom' version '0.2.7-SNAPSHOT'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
archivesBaseName = project.archives_base_name
def mod_version = project.mod_version as Object
version = "${mod_version}+${project.minecraft_version}"
group = project.maven_group as Object
minecraft {
}
repositories {
maven {
url 'https://maven.thebrokenrail.com/'
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
modImplementation "com.thebrokenrail:scriptcraft:${project.minecraft_version}"
include "com.thebrokenrail:scriptcraft:${project.minecraft_version}"
}
processResources {
inputs.property 'version', mod_version
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand 'version': mod_version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
jar {
from 'LICENSE'
}

View File

@ -0,0 +1,66 @@
plugins {
id("fabric-loom") version "0.2.7-SNAPSHOT"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
base.archivesBaseName = project.property("archives_base_name") as String
val modVersion = project.property("mod_version")
version = "${modVersion}+${project.property("minecraft_version")}"
group = project.property("maven_group")!!
minecraft {
}
repositories {
maven {
url = uri("https://maven.thebrokenrail.com/")
}
}
dependencies {
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
mappings("net.fabricmc:yarn:${project.property("minecraft_version")}+build.${project.property("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.property("fabric_loader_version")}")
modImplementation("com.thebrokenrail:scriptcraft:${project.property("minecraft_version")}")
include("com.thebrokenrail:scriptcraft:${project.property("minecraft_version")}")
}
tasks.named<Copy>("processResources") {
inputs.property("version", modVersion)
from(sourceSets["main"].resources.srcDirs) {
include("fabric.mod.json")
expand("version" to modVersion)
}
from(sourceSets["main"].resources.srcDirs) {
exclude("fabric.mod.json")
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
artifacts {
add("archives", tasks["sourcesJar"])
}
tasks.named<Jar>("jar") {
from("LICENSE")
}

View File

@ -1 +0,0 @@
../../settings.gradle

View File

@ -0,0 +1 @@
../../settings.gradle.kts

View File

@ -1,19 +1,22 @@
# TypeScript Example
This is an example of a Minecraft mod made in TypeScript using ScriptCraft.
#### Files
## Files
- ```src/main/ts```: Contains TypeScript Code
- ```src/main/java```: Contains Bootstrap Java Code
#### Notes
## Notes
- This will also work with JavaScript if you set ```compilerOptions.allowJs``` and optionally ```compilerOptions.checkJs``` in ```src/main/ts/tsconfig.json``` to ```true```
- NPM dependencies are not bundled
- API JARs are not bundled
#### ```typescript``` Gradle Configuration
## ```typescript``` Gradle Configuration
The ```typescript``` gradle configuration will extract the specified API JAR into ```src/main/ts/build/dependencies```.
#### API JAR Format
## API JARs
An API JAR can be built with ```./gradlew apiJar```.
### File Structure
```
- API JAR Root
- src/

View File

@ -1,71 +0,0 @@
plugins {
id 'fabric-loom' version '0.2.7-SNAPSHOT'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
archivesBaseName = project.archives_base_name
def mod_version = project.mod_version as Object
version = "${mod_version}+${project.minecraft_version}"
group = project.maven_group as Object
minecraft {
}
repositories {
maven {
url 'https://maven.thebrokenrail.com/'
}
}
apply from: './typescript.build.gradle'
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
modImplementation "com.thebrokenrail:scriptcraft:${project.minecraft_version}"
include "com.thebrokenrail:scriptcraft:${project.minecraft_version}"
typescript "com.thebrokenrail:scriptcraft:${project.minecraft_version}:api"
}
processResources {
inputs.property 'version', mod_version
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand 'version': mod_version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
jar {
from 'LICENSE'
}

View File

@ -0,0 +1,69 @@
plugins {
id("fabric-loom") version "0.2.7-SNAPSHOT"
id("typescript")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
base.archivesBaseName = project.property("archives_base_name") as String
val modVersion = project.property("mod_version")
version = "${modVersion}+${project.property("minecraft_version")}"
group = project.property("maven_group")!!
minecraft {
}
repositories {
maven {
url = uri("https://maven.thebrokenrail.com/")
}
}
dependencies {
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
mappings("net.fabricmc:yarn:${project.property("minecraft_version")}+build.${project.property("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.property("fabric_loader_version")}")
modImplementation("com.thebrokenrail:scriptcraft:${project.property("minecraft_version")}")
include("com.thebrokenrail:scriptcraft:${project.property("minecraft_version")}")
typescript("com.thebrokenrail:scriptcraft:${project.property("minecraft_version")}:api")
}
tasks.named<Copy>("processResources") {
inputs.property("version", modVersion)
from(sourceSets["main"].resources.srcDirs) {
include("fabric.mod.json")
expand("version" to modVersion)
}
from(sourceSets["main"].resources.srcDirs) {
exclude("fabric.mod.json")
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
artifacts {
add("archives", tasks["sourcesJar"])
}
tasks.named<Jar>("jar") {
from("LICENSE")
}

View File

@ -1 +0,0 @@
../../settings.gradle

View File

@ -0,0 +1 @@
../../settings.gradle.kts

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"lib": ["es2020"],
"module": "es2020",
"target": "es2020",
"removeComments": true,
"typeRoots": ["build/dependencies/types"],
"paths": {
"*": ["*", "../build/dependencies/src/*"]
},
"baseUrl": "src",
"outDir": "build/ts",
"moduleResolution": "node",
"resolveJsonModule": true
},
"include": [
"src/**/*"
]
}

View File

@ -0,0 +1 @@
../../../../../src/main/ts/tsconfig.json

View File

@ -1,73 +0,0 @@
def typescriptRoot = 'src/main/ts'
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def typescriptOut = new File(typescriptRootFile, 'build/ts')
def nodeModules = new File(typescriptRootFile, 'node_modules')
task npmInstall(group: 'typescript', type: Exec) {
inputs.file new File(typescriptRootFile, 'package.json')
outputs.dir nodeModules
workingDir typescriptRootFile
executable 'npm'
args 'install'
doFirst {
project.delete {
delete nodeModules
}
}
}
def typescriptDependencies = new File(typescriptRootFile, 'build/dependencies')
configurations {
typescript {
transitive false
}
}
task extractTypescriptDependencies(type: Sync, group: 'typescript') {
dependsOn configurations.typescript
from {
configurations.typescript.collect {
zipTree(it).matching {
exclude 'META-INF', 'META-INF/**'
}
}
}
into typescriptDependencies
}
task typescript(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dirs typescriptOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'build'
doFirst {
project.delete {
delete typescriptOut
}
}
}
typescript.dependsOn npmInstall
typescript.dependsOn extractTypescriptDependencies
processResources.dependsOn typescript
processResources {
from(typescriptOut.absolutePath) {
into 'scriptcraft'
}
}

View File

@ -1,74 +0,0 @@
def cDir = new File(rootProject.projectDir.absolutePath, 'src/main/c')
class JNIPlatform {
String name
String[] cmakeArgs
String libExtension
JNIPlatform(String name, String libExtension, File rootDir) {
this.name = name
this.cmakeArgs = ["-DCMAKE_TOOLCHAIN_FILE=${rootDir.absolutePath}/cmake/${name}-toolchain.cmake"] as String[]
this.libExtension = libExtension
}
}
JNIPlatform[] jniPlatforms = [
new JNIPlatform("linux-x86_64", ".so", rootDir),
new JNIPlatform("linux-x86", ".so", rootDir),
new JNIPlatform("linux-armhf", ".so", rootDir),
new JNIPlatform("linux-arm64", ".so", rootDir),
new JNIPlatform("windows-x86_64", ".dll", rootDir),
new JNIPlatform("windows-x86", ".dll", rootDir)
]
task cleanJNI {}
task compileJNI {}
for (JNIPlatform platform : jniPlatforms) {
def buildDir = new File(cDir, "build-${platform.name}")
if (!buildDir.exists()) {
buildDir.mkdir()
}
tasks.create(name: "cmake-${platform.name}", group: 'jni', type: Exec) {
workingDir buildDir
executable 'cmake'
args platform.cmakeArgs + ['..']
}
tasks.create(name: "compileJNI-${platform.name}", group: 'jni', type: Exec) {
workingDir buildDir
executable 'make'
dependsOn tasks.getByName("cmake-${platform.name}")
}
compileJNI.dependsOn tasks.getByName("compileJNI-${platform.name}")
tasks.create(name: "cleanJNI-${platform.name}", group: 'jni', type: Delete) {
delete buildDir.absolutePath
}
cleanJNI.dependsOn tasks.getByName("cleanJNI-${platform.name}")
}
clean.dependsOn cleanJNI
processResources.dependsOn compileJNI
processResources {
for (JNIPlatform platform : jniPlatforms) {
def buildDir = new File(cDir, "build-${platform.name}")
if (!buildDir.exists()) {
buildDir.mkdir()
}
def file = new File(buildDir, 'libscriptcraft' + platform.libExtension)
inputs.files file
from(file.absolutePath) {
into new File('natives', platform.name).path
}
}
}

View File

@ -2,11 +2,11 @@ pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
gradlePluginPortal()
}
}
rootProject.name = 'ScriptCraft'
rootProject.name = "ScriptCraft"

View File

@ -8,10 +8,13 @@
"module": "es2020",
"target": "es2020",
"removeComments": true,
"typeRoots": ["types"],
"rootDir": "src",
"baseUrl": "src",
"outDir": "build/ts",
"typeRoots": ["types", "build/dependencies/types"],
"paths": {
"*": ["*", "../build/dependencies/src/*"]
},
"declaration": true,
"declarationDir": "build/dts",
"moduleResolution": "node",

View File

@ -1,93 +0,0 @@
def typescriptRoot = 'src/main/ts'
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def nodeModules = new File(typescriptRootFile, 'node_modules')
task npmInstall(group: 'typescript', type: Exec) {
inputs.file new File(typescriptRootFile, 'package.json')
outputs.dir nodeModules
workingDir typescriptRootFile
executable 'npm'
args 'install'
}
def typescriptOut = new File(typescriptRootFile, 'build/ts')
def dtsOut = new File(typescriptRootFile, 'build/dts')
task typescript(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dirs typescriptOut, dtsOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'build'
doFirst {
project.delete {
delete typescriptOut, dtsOut
}
}
}
typescript.dependsOn npmInstall
task apiJar(group: 'typescript', type: Jar) {
into('/types') {
from new File(typescriptRootFile as File, 'types')
}
into('/src') {
from dtsOut
}
classifier 'api'
}
apiJar.dependsOn typescript
artifacts {
archives apiJar
}
task eslint(group: 'typescript', type: Exec) {
workingDir typescriptRootFile
executable 'npm'
args 'run', 'eslint'
}
eslint.dependsOn npmInstall
processResources.dependsOn typescript
def typedocOut = new File(typescriptRootFile, 'build/typedoc')
task typedoc(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dir typedocOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'typedoc'
doFirst {
project.delete {
delete typedocOut
}
}
}
typedoc.dependsOn npmInstall
processResources {
from(typescriptOut.absolutePath) {
into 'scriptcraft'
}
}