Add inputs & output definitions to script assembler plugin

Also have assembler scripts be output into build directory

Partially fixes #2665
This commit is contained in:
swazrgb
2020-06-11 06:34:16 +02:00
parent 2734e7acf1
commit f375f7503a
3 changed files with 33 additions and 9 deletions

View File

@@ -148,6 +148,12 @@ tasks {
archiveClassifier.set("shaded") archiveClassifier.set("shaded")
} }
processResources {
dependsOn(":runelite-script-assembler-plugin:indexMojo")
from("${buildDir}/scripts")
}
withType<BootstrapTask> { withType<BootstrapTask> {
group = "openosrs" group = "openosrs"
} }

View File

@@ -39,28 +39,34 @@ dependencies {
tasks { tasks {
register<JavaExec>("assembleMojo") { register<JavaExec>("assembleMojo") {
inputs.files(
fileTree("${project.extra["rootPath"]}/runelite-client/src/main/scripts")
)
outputs.dir("${project.extra["rootPath"]}/runelite-client/build/scripts/runelite");
classpath = project.sourceSets.main.get().runtimeClasspath classpath = project.sourceSets.main.get().runtimeClasspath
main = "net.runelite.script.AssembleMojo" main = "net.runelite.script.AssembleMojo"
args(listOf( args(listOf(
"${project.extra["rootPath"]}/runelite-client/src/main/scripts", "${project.extra["rootPath"]}/runelite-client/src/main/scripts",
"${project.extra["rootPath"]}/runelite-client/src/main/resources/runelite" "${project.extra["rootPath"]}/runelite-client/build/scripts/runelite"
)) ))
} }
register<JavaExec>("indexMojo") { register<JavaExec>("indexMojo") {
inputs.files(
fileTree("${project.extra["rootPath"]}/runelite-client/build/scripts/runelite")
)
outputs.file("${project.extra["rootPath"]}/runelite-client/build/scripts/runelite/index");
dependsOn("assembleMojo") dependsOn("assembleMojo")
classpath = project.sourceSets.main.get().runtimeClasspath classpath = project.sourceSets.main.get().runtimeClasspath
main = "net.runelite.script.IndexMojo" main = "net.runelite.script.IndexMojo"
args(listOf( args(listOf(
"${project.extra["rootPath"]}/runelite-client/src/main/resources/runelite", "${project.extra["rootPath"]}/runelite-client/build/scripts/runelite",
"${project.extra["rootPath"]}/runelite-client/src/main/resources/runelite/index" "${project.extra["rootPath"]}/runelite-client/build/scripts/runelite/index"
)) ))
} }
compileJava {
outputs.upToDateWhen {false}
finalizedBy("indexMojo")
}
} }

View File

@@ -25,6 +25,8 @@
package net.runelite.script; package net.runelite.script;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.common.io.MoreFiles;
import com.google.common.io.RecursiveDeleteOption;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@@ -86,6 +88,16 @@ public class AssembleMojo extends AbstractMojo
File scriptOut = new File(outputDirectory, Integer.toString(IndexType.CLIENTSCRIPT.getNumber())); File scriptOut = new File(outputDirectory, Integer.toString(IndexType.CLIENTSCRIPT.getNumber()));
scriptOut.mkdirs(); scriptOut.mkdirs();
// Clear the target directory to remove stale entries
try
{
MoreFiles.deleteDirectoryContents(scriptOut.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
}
catch (IOException e)
{
throw new MojoExecutionException("Could not clear scriptOut: " + scriptOut, e);
}
for (File scriptFile : scriptDirectory.listFiles((dir, name) -> name.endsWith(".rs2asm"))) for (File scriptFile : scriptDirectory.listFiles((dir, name) -> name.endsWith(".rs2asm")))
{ {
log.debug("Assembling " + scriptFile); log.debug("Assembling " + scriptFile);