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