diff --git a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java index 5cfed1392..120e08272 100644 --- a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java +++ b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.command.CustomClickAction; import com.cleanroommc.groovyscript.command.GSCommand; import com.cleanroommc.groovyscript.compat.content.GroovyResourcePack; @@ -8,8 +9,8 @@ import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.TinkersConstruct; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.core.mixin.DefaultResourcePackAccessor; -import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; import com.cleanroommc.groovyscript.documentation.Documentation; +import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; import com.cleanroommc.groovyscript.event.EventHandler; import com.cleanroommc.groovyscript.gameobjects.GameObjectHandlerManager; import com.cleanroommc.groovyscript.helper.JsonHelper; @@ -53,7 +54,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.relauncher.FMLLaunchHandler; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; @@ -164,6 +164,10 @@ public static void initializeGroovyPreInit() { @ApiStatus.Internal public static long runGroovyScriptsInLoader(LoadStage loadStage) { // called via mixin between fml post init and load complete + if (!getRunConfig().isLoaderConfigured(loadStage.getName())) { + GroovyLog.get().infoMC("Skipping load stage {}, since no scripts are configured!", loadStage.getName()); + return -1; + } if (scriptMod == null) scriptMod = Loader.instance().getIndexedModList().get(getRunConfig().getPackId()); ModContainer current = Loader.instance().activeModContainer(); Loader.instance().setActiveModContainer(scriptMod); diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java index 4ef602088..2a1349ec8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java @@ -55,7 +55,15 @@ public boolean readData(File basePath) { } } - private File getDataFile(File basePath) { + public void deleteCache(File cachePath) { + try { + Files.deleteIfExists(getDataFile(cachePath).toPath()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + protected File getDataFile(File basePath) { return new File(basePath, this.name + ".clz"); } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java index c9e4b5a7b..4c1d8c560 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java @@ -1,8 +1,13 @@ package com.cleanroommc.groovyscript.sandbox; import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.helper.JsonHelper; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import groovy.lang.GroovyClassLoader; import org.apache.commons.lang3.builder.ToStringBuilder; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; @@ -13,6 +18,7 @@ class CompiledScript extends CompiledClass { final String path; final List innerClasses = new ArrayList<>(); long lastEdited; + List preprocessors = null; public CompiledScript(String path, long lastEdited) { this(path, null, lastEdited); @@ -54,6 +60,64 @@ public void ensureLoaded(GroovyClassLoader classLoader, File basePath) { } } + @NotNull + public JsonObject toJson() { + JsonObject jsonEntry = new JsonObject(); + jsonEntry.addProperty("name", this.name); + jsonEntry.addProperty("path", this.path); + jsonEntry.addProperty("lm", this.lastEdited); + if (!this.innerClasses.isEmpty()) { + JsonArray inner = new JsonArray(); + for (CompiledClass comp : this.innerClasses) { + inner.add(comp.name); + } + jsonEntry.add("inner", inner); + } + if (this.preprocessors != null && !this.preprocessors.isEmpty()) { + JsonArray jsonPp = new JsonArray(); + for (String pp : this.preprocessors) { + jsonPp.add(pp); + } + jsonEntry.add("preprocessors", jsonPp); + } + return jsonEntry; + } + + public static CompiledScript fromJson(JsonObject json, File scriptRoot, File cacheRoot) { + CompiledScript cs = new CompiledScript(json.get("path").getAsString(), JsonHelper.getString(json, null, "name"), json.get("lm").getAsLong()); + if (new File(scriptRoot, cs.path).exists()) { + if (json.has("inner")) { + for (JsonElement element : json.getAsJsonArray("inner")) { + cs.innerClasses.add(new CompiledClass(element.getAsString())); + } + } + if (json.has("preprocessors")) { + cs.preprocessors = new ArrayList<>(); + for (JsonElement element : json.getAsJsonArray("preprocessors")) { + cs.preprocessors.add(element.getAsString()); + } + } + return cs; + } + // script file no longer exists -> delete cache + cs.deleteCache(cacheRoot); + return null; + } + + @Override + public void deleteCache(File cachePath) { + super.deleteCache(cachePath); + for (CompiledClass cc : this.innerClasses) { + cc.deleteCache(cachePath); + } + } + + public boolean checkPreprocessors(File basePath) { + return this.preprocessors == null || + this.preprocessors.isEmpty() || + Preprocessor.validatePreprocessor(new File(basePath, this.path), this.preprocessors); + } + @Override public String toString() { return new ToStringBuilder(this) diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java index cfcc31cc5..d8f98f89f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java @@ -78,7 +78,7 @@ protected void startRunning() { protected void stopRunning() { this.running.set(false); - currentSandbox.set(null); + currentSandbox.remove(); } protected GroovyScriptEngine createScriptEngine() { @@ -126,6 +126,7 @@ protected void loadScripts(GroovyScriptEngine engine, Binding binding, Set for (File scriptFile : getScriptFiles()) { if (!executedClasses.contains(scriptFile)) { Class clazz = loadScriptClass(engine, scriptFile); + if (clazz == GroovyLog.class) continue; // preprocessor returned false if (clazz == null) { GroovyLog.get().errorMC("Error loading script for {}", scriptFile.getPath()); GroovyLog.get().errorMC("Did you forget to register your class file in your run config?"); @@ -151,6 +152,7 @@ protected void loadClassScripts(GroovyScriptEngine engine, Binding binding, Set< for (File classFile : getClassFiles()) { if (executedClasses.contains(classFile)) continue; Class clazz = loadScriptClass(engine, classFile); + if (clazz == GroovyLog.class) continue; // preprocessor returned false if (clazz == null) { // loading script fails if the file is a script that depends on a class file that isn't loaded yet // we cant determine if the file is a script or a class diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java index ad95c634c..bd2f015ff 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java @@ -28,7 +28,6 @@ import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.control.customizers.ImportCustomizer; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; @@ -40,21 +39,25 @@ public class GroovyScriptSandbox extends GroovySandbox { - private final File cachePath; - private final File basePath; + private final File cacheRoot; + private final File scriptRoot; private final ImportCustomizer importCustomizer = new ImportCustomizer(); private final Map, AtomicInteger> storedExceptions; - + /** + * Version of the cache. Used to auto delete current cache if changes to the cache system were made. + * 1: Default + */ + private int cacheVersion = 1; private final Map index = new Object2ObjectOpenHashMap<>(); public static final boolean WRITE_CACHE = true; private LoadStage currentLoadStage; - public GroovyScriptSandbox(File basePath, File cachePath) throws MalformedURLException { - super(new URL[]{basePath.toURI().toURL()}); - this.basePath = basePath; - this.cachePath = cachePath; + public GroovyScriptSandbox(File scriptRoot, File cacheRoot) throws MalformedURLException { + super(new URL[]{scriptRoot.toURI().toURL()}); + this.scriptRoot = scriptRoot; + this.cacheRoot = cacheRoot; registerBinding("Mods", ModSupport.INSTANCE); registerBinding("Log", GroovyLog.get()); registerBinding("EventManager", GroovyEventManager.INSTANCE); @@ -92,22 +95,21 @@ public GroovyScriptSandbox(File basePath, File cachePath) throws MalformedURLExc } private void readIndex() { - JsonElement jsonElement = JsonHelper.loadJson(new File(this.cachePath, "_index.json")); + this.index.clear(); + JsonElement jsonElement = JsonHelper.loadJson(new File(this.cacheRoot, "_index.json")); if (jsonElement == null || !jsonElement.isJsonObject()) return; JsonObject json = jsonElement.getAsJsonObject(); - JsonArray index = json.getAsJsonArray("index"); - for (JsonElement element : index) { + this.cacheVersion = json.get("version").getAsInt(); + if (this.cacheVersion != 1) { + // only version 1 allowed currently + deleteClassCache(); + return; + } + for (JsonElement element : json.getAsJsonArray("index")) { if (element.isJsonObject()) { - JsonObject jsonEntry = element.getAsJsonObject(); - CompiledScript compiledScript = new CompiledScript(jsonEntry.get("path").getAsString(), jsonEntry.get("name").getAsString(), jsonEntry.get("lm").getAsLong()); - if (new File(this.basePath, compiledScript.path).exists()) { - if (jsonEntry.has("inner")) { - for (JsonElement element1 : jsonEntry.getAsJsonArray("inner")) { - compiledScript.innerClasses.add(new CompiledClass(element1.getAsString())); - } - } - this.index.put(compiledScript.path, compiledScript); - //entry.readData(this.cachePath); + CompiledScript cs = CompiledScript.fromJson(element.getAsJsonObject(), this.scriptRoot, this.cacheRoot); + if (cs != null) { + this.index.put(cs.path, cs); } } } @@ -117,29 +119,13 @@ private void writeIndex() { if (!WRITE_CACHE) return; JsonObject json = new JsonObject(); json.addProperty("!DANGER!", "DO NOT EDIT THIS FILE!!!"); + json.addProperty("version", this.cacheVersion); JsonArray index = new JsonArray(); json.add("index", index); for (Map.Entry entry : this.index.entrySet()) { - JsonObject jsonEntry = compiledClassToJson(entry.getValue()); - index.add(jsonEntry); - } - JsonHelper.saveJson(new File(this.cachePath, "_index.json"), json); - } - - @NotNull - private static JsonObject compiledClassToJson(CompiledScript compiledScript) { - JsonObject jsonEntry = new JsonObject(); - jsonEntry.addProperty("name", compiledScript.getName()); - jsonEntry.addProperty("path", compiledScript.path); - jsonEntry.addProperty("lm", compiledScript.lastEdited); - if (!compiledScript.innerClasses.isEmpty()) { - JsonArray inner = new JsonArray(); - for (CompiledClass comp : compiledScript.innerClasses) { - inner.add(comp.name); - } - jsonEntry.add("inner", inner); + index.add(entry.getValue().toJson()); } - return jsonEntry; + JsonHelper.saveJson(new File(this.cacheRoot, "_index.json"), json); } public void checkSyntax() { @@ -203,12 +189,13 @@ private String getShortPath(String path) { if (File.separatorChar != '/') { path = path.replace('/', File.separatorChar); } - String base = this.basePath.toString(); + String base = this.scriptRoot.toString(); int index = path.indexOf(base); if (index < 0) throw new IllegalArgumentException(); return path.substring(index + base.length() + 1); } + // TODO auto delete cache for deleted scripts @ApiStatus.Internal public void onCompileClass(SourceUnit su, String path, Class clazz, byte[] code, boolean inner) { String shortPath = getShortPath(path); @@ -221,13 +208,12 @@ public void onCompileClass(SourceUnit su, String path, Class clazz, byte[] co !su.getAST().getMainClassName().equals(clazz.getName())) { inner = true; } - GroovyLog.get().debugMC("Compiled class {}, path {}. Inner: {}", clazz.getName(), shortPath, inner); boolean finalInner = inner; CompiledScript comp = this.index.computeIfAbsent(truePath, k -> new CompiledScript(k, finalInner ? -1 : 0)); CompiledClass innerClass = comp; if (inner) innerClass = comp.findInnerClass(clazz.getName()); - innerClass.onCompile(code, clazz, this.cachePath); + innerClass.onCompile(code, clazz, this.cacheRoot); } @ApiStatus.Internal @@ -236,8 +222,8 @@ public Class onRecompileClass(GroovyClassLoader classLoader, URL source, Stri CompiledScript cs = this.index.get(getShortPath(path)); Class c = null; if (cs != null) { - if (cs.clazz == null && cs.readData(this.cachePath)) { - cs.ensureLoaded(classLoader, this.cachePath); + if (cs.clazz == null && cs.readData(this.cacheRoot)) { + cs.ensureLoaded(classLoader, this.cacheRoot); } c = cs.clazz; } @@ -246,31 +232,50 @@ public Class onRecompileClass(GroovyClassLoader classLoader, URL source, Stri @Override protected Class loadScriptClass(GroovyScriptEngine engine, File file) { - GroovyLog.get().debugMC("Loading script {}", file); - long lastModified = new File(this.basePath, file.toString()).lastModified(); - CompiledScript comp = this.index.get(file.toString()); - - if (comp != null && lastModified <= comp.lastEdited && comp.clazz == null && comp.readData(this.cachePath)) { - - GroovyLog.get().debugMC(" script {} is already compiled", file); - comp.ensureLoaded(engine.getGroovyClassLoader(), this.cachePath); + File relativeFile = this.scriptRoot.toPath().relativize(file.toPath()).toFile(); + long lastModified = file.lastModified(); + CompiledScript comp = this.index.get(relativeFile.toString()); + + if (comp != null && lastModified <= comp.lastEdited && comp.clazz == null && comp.readData(this.cacheRoot)) { + // class is not loaded, but the cached class bytes are still valid + if (!comp.checkPreprocessors(this.scriptRoot)) { + return GroovyLog.class; + } + GroovyLog.get().debugMC(" script {} is already compiled", relativeFile); + comp.ensureLoaded(engine.getGroovyClassLoader(), this.cacheRoot); } else if (comp == null || comp.clazz == null || lastModified > comp.lastEdited) { + // class is not loaded and class bytes don't exist yet or script has been edited + GroovyLog.get().debugMC(" compiling script {}", relativeFile); if (comp == null) { - comp = new CompiledScript(file.toString(), 0); - this.index.put(file.toString(), comp); + comp = new CompiledScript(relativeFile.toString(), 0); + this.index.put(relativeFile.toString(), comp); + } + if (lastModified > comp.lastEdited || comp.preprocessors == null) { + // recompile preprocessors if there is no data or script was edited + comp.preprocessors = Preprocessor.parsePreprocessors(file); + } + comp.lastEdited = lastModified; + if (!comp.checkPreprocessors(this.scriptRoot)) { + // delete class bytes to make sure it's recompiled once the preprocessors returns true + comp.deleteCache(this.cacheRoot); + comp.clazz = null; + comp.data = null; + return GroovyLog.class; } - GroovyLog.get().debugMC(" compiling script {}", file); - Class clazz = super.loadScriptClass(engine, file); + Class clazz = super.loadScriptClass(engine, relativeFile); if (comp.clazz == null) { - GroovyLog.get().debugMC("Class for {} was loaded, but didnt receive class created callback! Index: {}", file, this.index); + // should not happen + GroovyLog.get().debugMC("Class for {} was loaded, but didnt receive class created callback! Index: {}", relativeFile, this.index); comp.clazz = clazz; } - comp.lastEdited = lastModified; - } else { - GroovyLog.get().debugMC(" script {} is already compiled and loaded", file); - comp.ensureLoaded(engine.getGroovyClassLoader(), this.cachePath); + // class is loaded and script wasn't edited + if (!comp.checkPreprocessors(this.scriptRoot)) { + return GroovyLog.class; + } + GroovyLog.get().debugMC(" script {} is already compiled and loaded", relativeFile); + comp.ensureLoaded(engine.getGroovyClassLoader(), this.cacheRoot); } return comp.clazz; } @@ -317,12 +322,12 @@ protected void postRun() { @Override public Collection getClassFiles() { - return GroovyScript.getRunConfig().getClassFiles(this.currentLoadStage.getName()); + return GroovyScript.getRunConfig().getClassFiles(this.scriptRoot, this.currentLoadStage.getName()); } @Override public Collection getScriptFiles() { - return GroovyScript.getRunConfig().getSortedFiles(this.currentLoadStage.getName()); + return GroovyScript.getRunConfig().getSortedFiles(this.scriptRoot, this.currentLoadStage.getName()); } @Nullable @@ -337,7 +342,7 @@ public ImportCustomizer getImportCustomizer() { @ApiStatus.Internal public void deleteClassCache() { try { - FileUtils.cleanDirectory(new File(this.basePath, "compiled")); + FileUtils.cleanDirectory(this.cacheRoot); } catch (IOException e) { GroovyScript.LOGGER.throwing(e); } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java index 98ef44cdd..77577d253 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java @@ -8,8 +8,6 @@ import com.google.common.base.CaseFormat; import io.sommers.packmode.api.PackModeAPI; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectMap; -import it.unimi.dsi.fastutil.objects.ObjectIterator; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Loader; @@ -17,9 +15,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; +import java.util.*; import java.util.function.BiPredicate; public class Preprocessor { @@ -40,7 +36,8 @@ public static void registerPreprocessor(String name, BiPredicate registerPreprocessor("PACKMODE", Preprocessor::checkPackmode); } - public static boolean validatePreprocessors(File file) { + public static List parsePreprocessors(File file) { + List preprocessors = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file))) { boolean isComment = false; String line; @@ -56,22 +53,36 @@ public static boolean validatePreprocessors(File file) { line = line.substring(2).trim(); if (line.isEmpty()) continue; } else if (!isComment) { - return true; + return preprocessors.isEmpty() ? Collections.emptyList() : preprocessors; } if (isComment && line.endsWith("*/")) { isComment = false; } - if (!processPreprocessor(file, line)) { - return false; + if (isPreprocessor(line)) { + preprocessors.add(line); } } } catch (IOException e) { throw new RuntimeException(e); } + return preprocessors.isEmpty() ? Collections.emptyList() : preprocessors; + } + + public static boolean validatePreprocessor(File file, List preprocessors) { + for (String pp : preprocessors) { + if (!processPreprocessor(file, pp)) { + return false; + } + } return true; } + private static boolean isPreprocessor(String line) { + String s = line.split(":", 2)[0]; + return PREPROCESSORS.containsKey(s.toUpperCase(Locale.ROOT)); + } + private static boolean processPreprocessor(File file, String line) { String[] parts = line.split(":", 2); String[] args = NO_ARGS; @@ -82,13 +93,8 @@ private static boolean processPreprocessor(File file, String line) { } } String s = parts[0]; - for (ObjectIterator>> iterator = PREPROCESSORS.object2ObjectEntrySet().fastIterator(); iterator.hasNext(); ) { - Object2ObjectMap.Entry> entry = iterator.next(); - if (s.equalsIgnoreCase(entry.getKey())) { - return entry.getValue().test(file, args); - } - } - return true; + BiPredicate preprocessor = PREPROCESSORS.get(s.toUpperCase(Locale.ROOT)); + return preprocessor.test(file, args); } private static boolean checkModsLoaded(File file, String[] mods) { @@ -119,7 +125,8 @@ private static boolean checkSide(File file, String[] sides) { private static boolean checkPackmode(File file, String[] modes) { for (String mode : modes) { if (!Packmode.isValidPackmode(mode)) { - List valid = GroovyScript.getRunConfig().isIntegratePackmodeMod() ? PackModeAPI.getInstance().getPackModes() : GroovyScript.getRunConfig().getPackmodeList(); + List valid = GroovyScript.getRunConfig().isIntegratePackmodeMod() ? PackModeAPI.getInstance().getPackModes() + : GroovyScript.getRunConfig().getPackmodeList(); GroovyLog.get().error("The packmode '{}' specified in file '{}' does not exist. Valid values are {}", mode, file.getName(), valid); } else if (Packmode.getPackmode().equals(Alias.autoConvertTo(mode, CaseFormat.LOWER_UNDERSCORE))) { return true; diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java index 2308868c1..d9b060610 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java @@ -283,27 +283,34 @@ public int getPackmodeConfigState() { return packmodeConfigState; } - public Collection getClassFiles(String loader) { + public boolean isLoaderConfigured(String loader) { + List path = this.classes.get(loader); + if (path != null && !path.isEmpty()) return true; + path = this.loaderPaths.get(loader); + return path != null && !path.isEmpty(); + } + + public Collection getClassFiles(File root, String loader) { List paths = this.classes.get("all"); paths = paths == null ? new ArrayList<>() : new ArrayList<>(paths); if (this.classes.containsKey(loader)) { paths.addAll(this.classes.get(loader)); } - return getSortedFilesOf(paths); + return getSortedFilesOf(root, paths); } - public Collection getSortedFiles(String loader) { + public Collection getSortedFiles(File root, String loader) { List paths = loaderPaths.get(loader); if (paths == null || paths.isEmpty()) return Collections.emptyList(); - return getSortedFilesOf(paths); + return getSortedFilesOf(root, paths); } - private Collection getSortedFilesOf(Collection paths) { + private Collection getSortedFilesOf(File root, Collection paths) { Object2IntLinkedOpenHashMap files = new Object2IntLinkedOpenHashMap<>(); String separator = getSeparator(); for (String path : paths) { - File rootFile = new File(GroovyScript.getScriptPath() + File.separator + path); + File rootFile = new File(root, path); if (!rootFile.exists()) { continue; } @@ -311,7 +318,7 @@ private Collection getSortedFilesOf(Collection paths) { try (Stream stream = Files.walk(rootFile.toPath())) { stream.filter(path1 -> isGroovyFile(path1.toString())) .map(Path::toFile) - .filter(Preprocessor::validatePreprocessors) + //.filter(Preprocessor::validatePreprocessors) .sorted(Comparator.comparing(File::getPath)) .forEach(file -> { if (files.containsKey(file)) { @@ -326,8 +333,7 @@ private Collection getSortedFilesOf(Collection paths) { throw new RuntimeException(e); } } - Path mainPath = GroovyScript.getScriptFile().toPath(); - return files.keySet().stream().map(file -> mainPath.relativize(file.toPath()).toFile()).collect(Collectors.toList()); + return new ArrayList<>(files.keySet()); } private static String sanitizePath(String path) {