From d3845422ca3ddb45cae63d5ba1d4325d64672e66 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 1 Mar 2023 07:46:38 -0800 Subject: [PATCH] Remove Node.js logic (#477) --- .../test/hook/MultiParentCompileHook.java | 22 ------- .../hook/NodeCleanupBeforeCompileHook.java | 58 ------------------- 2 files changed, 80 deletions(-) delete mode 100644 src/main/java/org/jenkins/tools/test/hook/NodeCleanupBeforeCompileHook.java diff --git a/src/main/java/org/jenkins/tools/test/hook/MultiParentCompileHook.java b/src/main/java/org/jenkins/tools/test/hook/MultiParentCompileHook.java index e3978db3b..46c89c7e5 100644 --- a/src/main/java/org/jenkins/tools/test/hook/MultiParentCompileHook.java +++ b/src/main/java/org/jenkins/tools/test/hook/MultiParentCompileHook.java @@ -14,7 +14,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Stream; -import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.jenkins.tools.test.PluginCompatTester; import org.jenkins.tools.test.exception.PomExecutionException; @@ -207,28 +206,7 @@ private boolean isSnapshotMultiParentPlugin( } private File setupCompileResources(File path) { - LOGGER.log(Level.INFO, "Cleaning up node modules if necessary"); - removeNodeFolders(path); LOGGER.log(Level.INFO, "Plugin compilation log directory: {0}", path); return new File(path + "/compilePluginLog.log"); } - - private void removeNodeFolders(File path) { - File nodeFolder = new File(path, "node"); - if (nodeFolder.exists() && nodeFolder.isDirectory()) { - try { - FileUtils.deleteDirectory(nodeFolder); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - File nodeModulesFolder = new File(path, "node_modules"); - if (nodeModulesFolder.exists() && nodeModulesFolder.isDirectory()) { - try { - FileUtils.deleteDirectory(nodeFolder); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - } } diff --git a/src/main/java/org/jenkins/tools/test/hook/NodeCleanupBeforeCompileHook.java b/src/main/java/org/jenkins/tools/test/hook/NodeCleanupBeforeCompileHook.java deleted file mode 100644 index 7458f6a33..000000000 --- a/src/main/java/org/jenkins/tools/test/hook/NodeCleanupBeforeCompileHook.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.jenkins.tools.test.hook; - -import edu.umd.cs.findbugs.annotations.NonNull; -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.apache.commons.io.FileUtils; -import org.jenkins.tools.test.model.PluginCompatTesterConfig; -import org.jenkins.tools.test.model.hook.BeforeCompilationContext; -import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeCompile; - -public class NodeCleanupBeforeCompileHook extends PluginCompatTesterHookBeforeCompile { - - private static final Logger LOGGER = - Logger.getLogger(NodeCleanupBeforeCompileHook.class.getName()); - - @Override - public void action(@NonNull BeforeCompilationContext context) { - PluginCompatTesterConfig config = context.getConfig(); - boolean shouldExecuteHook = - config.getIncludePlugins().contains("sse-gateway") - || config.getIncludePlugins().contains("workflow-cps"); - - if (shouldExecuteHook) { - File pluginDir = context.getPluginDir(); - LOGGER.log(Level.INFO, "Executing node and node_modules cleanup hook"); - compile(pluginDir); - } else { - LOGGER.log(Level.INFO, "Hook not triggered; continuing"); - } - } - - private void compile(File path) { - LOGGER.log(Level.INFO, "Calling removeNodeFolders"); - removeNodeFolders(path); - } - - private void removeNodeFolders(File path) { - File nodeFolder = new File(path, "node"); - if (nodeFolder.isDirectory()) { - try { - FileUtils.deleteDirectory(nodeFolder); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - File nodeModulesFolder = new File(path, "node_modules"); - if (nodeModulesFolder.isDirectory()) { - try { - FileUtils.deleteDirectory(nodeFolder); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - } -}