Linkage #20
@ -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
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren