Add plugin.yml discovery by traversal
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-09-23 11:49:27 +02:00
Ursprung 4dd552d08d
Commit de02138e8d

Datei anzeigen

@ -38,6 +38,8 @@ import javax.tools.Diagnostic;
import java.io.*; import java.io.*;
import java.io.Writer; import java.io.Writer;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -88,22 +90,23 @@ public class LinkageProcessor extends AbstractProcessor {
mainClass(); mainClass();
} }
@SneakyThrows
private void mainClass() { private void mainClass() {
File file = new File(System.getProperty("user.dir")); File file = new File(System.getProperty("user.dir"));
String subModuleName = file.getName(); Optional<File> pluginYMLFile = Files.walk(file.toPath())
if (subModuleName.contains(".")) subModuleName = subModuleName.substring(0, subModuleName.indexOf('.')); .map(Path::toFile)
.filter(f -> f.getName().equals("plugin.yml"))
Optional<String> main = getMainName(new File(file, "src/plugin.yml")); .findFirst();
if (!main.isPresent()) main = getMainName(new File(file, "src/main/resources/plugin.yml")); if (!pluginYMLFile.isPresent()) {
if (!main.isPresent()) main = getMainName(new File(file, subModuleName + "_Core/src/plugin.yml"));
if (!main.isPresent()) main = getMainName(new File(file, subModuleName + "_Core/src/main/resources/plugin.yml"));
if (!main.isPresent()) main = getMainName(new File(file, subModuleName + "_Main/src/plugin.yml"));
if (!main.isPresent()) main = getMainName(new File(file, subModuleName + "_Main/src/main/resources/plugin.yml"));
if (!main.isPresent()) {
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find plugin.yml"); messager.printMessage(Diagnostic.Kind.ERROR, "Could not find plugin.yml");
return; return;
} }
pluginMain = main.get(); Optional<String> mainName = getMainName(pluginYMLFile.get());
if (!mainName.isPresent()) {
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find main class in plugin.yml");
return;
}
pluginMain = mainName.get();
} }
@SneakyThrows @SneakyThrows