Update Docs and Gradle
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
This commit is contained in:
parent
9cc3eb2a88
commit
e80e229efb
@ -7,7 +7,15 @@ Inside the JAR, JS source files are in ```<JAR Root>/scriptcraft```, and inside
|
||||
An external libraries API can be accessed using an ```import``` statement.
|
||||
|
||||
## TypeScript
|
||||
TypeScript-based projects use thw ```com.thebrokenrail.scriptcraft.plugin``` Gradle plugin, this plugin will handle installing TypeScript and download any API type declarations. The TypeScript root using this Gradle plugin is at ```src/main/ts```.
|
||||
TypeScript-based projects use the ```com.thebrokenrail.scriptcraft.plugin``` Gradle plugin, this plugin will handle installing TypeScript and download any API type declarations. The TypeScript root using this Gradle plugin is at ```src/main/ts```.
|
||||
|
||||
### Custom TypeScript Root
|
||||
The root for the TypeScript sub-project can be changed with:
|
||||
```groovy
|
||||
scriptcraft {
|
||||
root = new File(project.rootDir, "a/b/c")
|
||||
}
|
||||
```
|
||||
|
||||
### External Libraries
|
||||
To access an external libraries' API in addition to an ```import``` statement, the TypeScript compiler must have access to the external libraries' type declarations. The ScriptCraft Gradle plugin generates and downloads these using JAR files called API JARs.
|
||||
|
@ -1,11 +1,50 @@
|
||||
# Module Resolution
|
||||
All ScriptCraft mods have a folder called ```scriptcraft``` in the root of their JAR file, when ScriptCraft is loaded all of these are combined to form a single "virtual" root. It is recommended to use namespaces to avoid conflicts with other mods.
|
||||
|
||||
## Supported File Types
|
||||
- ```.js```
|
||||
- ```.mjs```
|
||||
- ```.json```
|
||||
## Examples
|
||||
|
||||
## Extra Details
|
||||
- If the import path is a folder, ScriptCraft will load the ```index``` file, and if it doesn't exist it will try to load ```<Folder>/index```.
|
||||
- If the specified import does not exist, it will try to load the import appended with each supported file type.
|
||||
### Relative
|
||||
Test Code:
|
||||
```javascript
|
||||
import '../path';
|
||||
```
|
||||
|
||||
Test Code Path:
|
||||
```
|
||||
/some/thing/index.js
|
||||
```
|
||||
|
||||
Module Resolution trace:
|
||||
```
|
||||
/some/path
|
||||
/some/path.js
|
||||
/some/path.json
|
||||
/some/path.mjs
|
||||
/some/path/index
|
||||
/some/path/index.js
|
||||
/some/path/index.json
|
||||
/some/path/index.mjs
|
||||
```
|
||||
|
||||
### Non-Relative
|
||||
Test Code:
|
||||
```javascript
|
||||
import 'path';
|
||||
```
|
||||
|
||||
Test Code Path:
|
||||
```
|
||||
/some/thing/index.js
|
||||
```
|
||||
|
||||
Module Resolution trace:
|
||||
```
|
||||
/path
|
||||
/path.js
|
||||
/path.json
|
||||
/path.mjs
|
||||
/path/index
|
||||
/path/index.js
|
||||
/path/index.json
|
||||
/path/index.mjs
|
||||
```
|
@ -9,26 +9,18 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.thebrokenrail.scriptcraft"
|
||||
base.archivesBaseName = "plugin"
|
||||
version = "1.0.0"
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
register("scriptcraft-plugin") {
|
||||
id = "${group}.${base.archivesBaseName}"
|
||||
id = "${group}.${project.name}"
|
||||
implementationClass = "ScriptCraftPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
project.afterEvaluate {
|
||||
publications {
|
||||
named<MavenPublication>("pluginMaven") {
|
||||
artifactId = base.archivesBaseName
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("/data/maven")
|
||||
|
@ -8,7 +8,7 @@ import java.io.File
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
class ScriptCraftPlugin : Plugin<Project> {
|
||||
open class TypeScriptConfig(rootDir: File) {
|
||||
open class Config(rootDir: File) {
|
||||
var root: File = File(rootDir, "src/main/ts")
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class ScriptCraftPlugin : Plugin<Project> {
|
||||
@InputDirectory
|
||||
fun getInput(): Callable<File> {
|
||||
return Callable {
|
||||
project.the<TypeScriptConfig>().root
|
||||
project.the<Config>().root
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class ScriptCraftPlugin : Plugin<Project> {
|
||||
if (File(dir).isAbsolute) {
|
||||
File(dir)
|
||||
} else {
|
||||
File(project.the<TypeScriptConfig>().root, dir)
|
||||
File(project.the<Config>().root, dir)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -66,7 +66,7 @@ class ScriptCraftPlugin : Plugin<Project> {
|
||||
}
|
||||
project.exec {
|
||||
workingDir(Callable {
|
||||
project.the<TypeScriptConfig>().root
|
||||
project.the<Config>().root
|
||||
})
|
||||
|
||||
executable("npm")
|
||||
@ -78,20 +78,20 @@ class ScriptCraftPlugin : Plugin<Project> {
|
||||
@InputFile
|
||||
fun getInput(): Callable<File> {
|
||||
return Callable {
|
||||
File(project.the<TypeScriptConfig>().root, "package.json")
|
||||
File(project.the<Config>().root, "package.json")
|
||||
}
|
||||
}
|
||||
|
||||
@OutputDirectory
|
||||
fun getOutput(): Callable<File> {
|
||||
return Callable {
|
||||
File(project.the<TypeScriptConfig>().root, "node_modules")
|
||||
File(project.the<Config>().root, "node_modules")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
val extension = project.extensions.create<TypeScriptConfig>("typescript", projectDir)
|
||||
val extension = project.extensions.create<Config>("scriptcraft", projectDir)
|
||||
|
||||
val typescript = configurations.create("typescript") {
|
||||
isTransitive = false
|
||||
|
@ -8,7 +8,7 @@ plugins {
|
||||
minecraft {
|
||||
}
|
||||
|
||||
base.archivesBaseName = project.property("archives_base_name") as String
|
||||
val displayName = project.property("display_name")
|
||||
version = project.property("minecraft_version")!!
|
||||
group = project.property("maven_group")!!
|
||||
|
||||
@ -42,11 +42,11 @@ tasks.register<ScriptCraftPlugin.NPMTask>("typedoc") {
|
||||
}
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
inputs.property("name", rootProject.name)
|
||||
inputs.property("name", displayName)
|
||||
|
||||
from(sourceSets["main"].resources.srcDirs) {
|
||||
include("fabric.mod.json")
|
||||
expand("name" to rootProject.name)
|
||||
expand("name" to displayName)
|
||||
}
|
||||
|
||||
from(sourceSets["main"].resources.srcDirs) {
|
||||
@ -66,6 +66,10 @@ java {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
tasks.named<Javadoc>("javadoc") {
|
||||
title = "ScriptCraft"
|
||||
}
|
||||
|
||||
// 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.
|
||||
@ -84,8 +88,6 @@ tasks.named<Jar>("jar") {
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifactId = project.property("archives_base_name") as String
|
||||
|
||||
artifact(tasks["remapJar"])
|
||||
artifact(tasks["apiJar"])
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import java.io.File
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
class JNIPlugin : Plugin<Project> {
|
||||
open class JNIConfig(private val project: Project) {
|
||||
open class Config(private val project: Project) {
|
||||
var root: File = File(project.rootDir, "src/main/c")
|
||||
|
||||
fun addPlatform(name: String, libExtension: String) = project.run {
|
||||
@ -76,6 +76,6 @@ class JNIPlugin : Plugin<Project> {
|
||||
dependsOn(tasks["compileJNI"])
|
||||
}
|
||||
|
||||
project.extensions.create<JNIConfig>("jni", project)
|
||||
project.extensions.create<Config>("jni", project)
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ org.gradle.jvmargs = -Xmx1G
|
||||
|
||||
# Mod Properties
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = scriptcraft
|
||||
display_name = ScriptCraft
|
||||
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
|
@ -12,6 +12,4 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "ScriptCraft"
|
||||
|
||||
includeBuild("../plugin")
|
||||
|
Reference in New Issue
Block a user