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.
|
An external libraries API can be accessed using an ```import``` statement.
|
||||||
|
|
||||||
## TypeScript
|
## 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
|
### 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.
|
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
|
# 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.
|
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
|
## Examples
|
||||||
- ```.js```
|
|
||||||
- ```.mjs```
|
|
||||||
- ```.json```
|
|
||||||
|
|
||||||
## Extra Details
|
### Relative
|
||||||
- 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```.
|
Test Code:
|
||||||
- If the specified import does not exist, it will try to load the import appended with each supported file type.
|
```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"
|
group = "com.thebrokenrail.scriptcraft"
|
||||||
base.archivesBaseName = "plugin"
|
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
register("scriptcraft-plugin") {
|
register("scriptcraft-plugin") {
|
||||||
id = "${group}.${base.archivesBaseName}"
|
id = "${group}.${project.name}"
|
||||||
implementationClass = "ScriptCraftPlugin"
|
implementationClass = "ScriptCraftPlugin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
project.afterEvaluate {
|
|
||||||
publications {
|
|
||||||
named<MavenPublication>("pluginMaven") {
|
|
||||||
artifactId = base.archivesBaseName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = uri("/data/maven")
|
url = uri("/data/maven")
|
||||||
|
@ -8,7 +8,7 @@ import java.io.File
|
|||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
class ScriptCraftPlugin : Plugin<Project> {
|
class ScriptCraftPlugin : Plugin<Project> {
|
||||||
open class TypeScriptConfig(rootDir: File) {
|
open class Config(rootDir: File) {
|
||||||
var root: File = File(rootDir, "src/main/ts")
|
var root: File = File(rootDir, "src/main/ts")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class ScriptCraftPlugin : Plugin<Project> {
|
|||||||
@InputDirectory
|
@InputDirectory
|
||||||
fun getInput(): Callable<File> {
|
fun getInput(): Callable<File> {
|
||||||
return Callable {
|
return Callable {
|
||||||
project.the<TypeScriptConfig>().root
|
project.the<Config>().root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class ScriptCraftPlugin : Plugin<Project> {
|
|||||||
if (File(dir).isAbsolute) {
|
if (File(dir).isAbsolute) {
|
||||||
File(dir)
|
File(dir)
|
||||||
} else {
|
} else {
|
||||||
File(project.the<TypeScriptConfig>().root, dir)
|
File(project.the<Config>().root, dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -66,7 +66,7 @@ class ScriptCraftPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
project.exec {
|
project.exec {
|
||||||
workingDir(Callable {
|
workingDir(Callable {
|
||||||
project.the<TypeScriptConfig>().root
|
project.the<Config>().root
|
||||||
})
|
})
|
||||||
|
|
||||||
executable("npm")
|
executable("npm")
|
||||||
@ -78,20 +78,20 @@ class ScriptCraftPlugin : Plugin<Project> {
|
|||||||
@InputFile
|
@InputFile
|
||||||
fun getInput(): Callable<File> {
|
fun getInput(): Callable<File> {
|
||||||
return Callable {
|
return Callable {
|
||||||
File(project.the<TypeScriptConfig>().root, "package.json")
|
File(project.the<Config>().root, "package.json")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OutputDirectory
|
@OutputDirectory
|
||||||
fun getOutput(): Callable<File> {
|
fun getOutput(): Callable<File> {
|
||||||
return Callable {
|
return Callable {
|
||||||
File(project.the<TypeScriptConfig>().root, "node_modules")
|
File(project.the<Config>().root, "node_modules")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(project: Project): Unit = project.run {
|
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") {
|
val typescript = configurations.create("typescript") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
|
@ -8,7 +8,7 @@ plugins {
|
|||||||
minecraft {
|
minecraft {
|
||||||
}
|
}
|
||||||
|
|
||||||
base.archivesBaseName = project.property("archives_base_name") as String
|
val displayName = project.property("display_name")
|
||||||
version = project.property("minecraft_version")!!
|
version = project.property("minecraft_version")!!
|
||||||
group = project.property("maven_group")!!
|
group = project.property("maven_group")!!
|
||||||
|
|
||||||
@ -42,11 +42,11 @@ tasks.register<ScriptCraftPlugin.NPMTask>("typedoc") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Copy>("processResources") {
|
tasks.named<Copy>("processResources") {
|
||||||
inputs.property("name", rootProject.name)
|
inputs.property("name", displayName)
|
||||||
|
|
||||||
from(sourceSets["main"].resources.srcDirs) {
|
from(sourceSets["main"].resources.srcDirs) {
|
||||||
include("fabric.mod.json")
|
include("fabric.mod.json")
|
||||||
expand("name" to rootProject.name)
|
expand("name" to displayName)
|
||||||
}
|
}
|
||||||
|
|
||||||
from(sourceSets["main"].resources.srcDirs) {
|
from(sourceSets["main"].resources.srcDirs) {
|
||||||
@ -66,6 +66,10 @@ java {
|
|||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
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
|
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||||
// if it is present.
|
// if it is present.
|
||||||
// If you remove this task, sources will not be generated.
|
// If you remove this task, sources will not be generated.
|
||||||
@ -84,8 +88,6 @@ tasks.named<Jar>("jar") {
|
|||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("mavenJava") {
|
create<MavenPublication>("mavenJava") {
|
||||||
artifactId = project.property("archives_base_name") as String
|
|
||||||
|
|
||||||
artifact(tasks["remapJar"])
|
artifact(tasks["remapJar"])
|
||||||
artifact(tasks["apiJar"])
|
artifact(tasks["apiJar"])
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import java.io.File
|
|||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
class JNIPlugin : Plugin<Project> {
|
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")
|
var root: File = File(project.rootDir, "src/main/c")
|
||||||
|
|
||||||
fun addPlatform(name: String, libExtension: String) = project.run {
|
fun addPlatform(name: String, libExtension: String) = project.run {
|
||||||
@ -76,6 +76,6 @@ class JNIPlugin : Plugin<Project> {
|
|||||||
dependsOn(tasks["compileJNI"])
|
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
|
# Mod Properties
|
||||||
maven_group = com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
archives_base_name = scriptcraft
|
display_name = ScriptCraft
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# 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")
|
includeBuild("../plugin")
|
||||||
|
Reference in New Issue
Block a user