Linkage #20

Zusammengeführt
Lixfel hat 24 Commits von Linkage nach master 2022-09-23 12:45:21 +02:00 zusammengeführt
Nur Änderungen aus Commit de02138e8d werden angezeigt - Alle Commits anzeigen

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