mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
quick-e2e: Add CopyFileService to handle file copying and update Main class to utilize it
This commit is contained in:
@@ -2,6 +2,7 @@ package de.oliver.quicke2e;
|
|||||||
|
|
||||||
import de.oliver.quicke2e.config.Configuration;
|
import de.oliver.quicke2e.config.Configuration;
|
||||||
import de.oliver.quicke2e.config.Context;
|
import de.oliver.quicke2e.config.Context;
|
||||||
|
import de.oliver.quicke2e.steps.copyFile.CopyFileService;
|
||||||
import de.oliver.quicke2e.steps.eula.EulaService;
|
import de.oliver.quicke2e.steps.eula.EulaService;
|
||||||
import de.oliver.quicke2e.steps.gradle.GradleService;
|
import de.oliver.quicke2e.steps.gradle.GradleService;
|
||||||
import de.oliver.quicke2e.steps.ops.OPsService;
|
import de.oliver.quicke2e.steps.ops.OPsService;
|
||||||
@@ -40,6 +41,11 @@ public class Main {
|
|||||||
|
|
||||||
GradleService gradle = new GradleService();
|
GradleService gradle = new GradleService();
|
||||||
gradle.runTask(":plugins:fancyholograms:shadowJar");
|
gradle.runTask(":plugins:fancyholograms:shadowJar");
|
||||||
|
gradle.runTask(":plugins:fancyvisuals:shadowJar");
|
||||||
|
|
||||||
|
CopyFileService copyFile = new CopyFileService();
|
||||||
|
copyFile.copyFile(context, "plugins/fancyholograms/build/libs", "FancyHolograms-.*\\.jar", "plugins");
|
||||||
|
copyFile.copyFile(context, "plugins/fancyvisuals/build/libs", "FancyVisuals-.*\\.jar", "plugins");
|
||||||
|
|
||||||
StartServerService startServer = new StartServerService();
|
StartServerService startServer = new StartServerService();
|
||||||
startServer.startServer(context);
|
startServer.startServer(context);
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package de.oliver.quicke2e.steps.copyFile;
|
||||||
|
|
||||||
|
import de.oliver.quicke2e.config.Context;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CopyFileService {
|
||||||
|
|
||||||
|
public void copyFile(Context context, String sourceFolder, String source, String destination) {
|
||||||
|
String realSource = source;
|
||||||
|
|
||||||
|
if (source.contains("*")) {
|
||||||
|
Pattern pattern = Pattern.compile(source);
|
||||||
|
try {
|
||||||
|
Optional<Path> first = Files.walk(Path.of(sourceFolder))
|
||||||
|
.filter(Files::isRegularFile)
|
||||||
|
.filter(path -> pattern.matcher(path.getFileName().toString()).matches())
|
||||||
|
.findFirst();
|
||||||
|
if (first.isPresent()) {
|
||||||
|
realSource = first.get().toString();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Path target = context.serverEnvPath().resolve(destination + "/" + Path.of(realSource).getFileName());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.copy(Path.of(realSource), target, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ public class GradleService {
|
|||||||
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
|
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
|
process.waitFor();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user