Skip to content

Commit

Permalink
Remove ESLint logic (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Mar 3, 2023
1 parent fc5b653 commit 211bd88
Showing 1 changed file with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import org.apache.commons.lang.StringUtils;
import org.jenkins.tools.test.PluginCompatTester;
import org.jenkins.tools.test.exception.PomExecutionException;
Expand All @@ -37,8 +34,6 @@ public class MultiParentCompileHook extends PluginCompatTesterHookBeforeCompile

protected MavenRunner runner;

public static final String ESLINTRC = ".eslintrc";

public MultiParentCompileHook() {
LOGGER.log(Level.INFO, "Loaded multi-parent compile hook");
}
Expand All @@ -57,30 +52,12 @@ public void action(@NonNull BeforeCompilationContext context) throws PomExecutio
File pluginDir = context.getPluginDir();
LOGGER.log(Level.INFO, "Plugin dir is {0}", pluginDir);

File localCheckoutDir = config.getLocalCheckoutDir();
if (localCheckoutDir != null) {
Path pluginSourcesDir = localCheckoutDir.toPath();
boolean isMultipleLocalPlugins = config.getIncludePlugins().size() > 1;
// We are running for local changes, let's copy the .eslintrc file if we can. If we
// are using localCheckoutDir with multiple plugins the .eslintrc must be located at
// the top level. If not it must be located on the parent of the localCheckoutDir.
if (!isMultipleLocalPlugins) {
pluginSourcesDir = pluginSourcesDir.getParent();
}
// Copy the file if it exists
try (Stream<Path> walk = Files.walk(pluginSourcesDir, 1)) {
walk.filter(this::isEslintFile).forEach(eslintrc -> copy(eslintrc, pluginDir));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

// We need to compile before generating effective pom overriding jenkins.version
// only if the plugin is not already compiled
if (!context.ranCompile()) {
compile(
pluginDir,
localCheckoutDir,
config.getLocalCheckoutDir(),
context.getParentFolder(),
context.getPlugin().name);
context.setRanCompile(true);
Expand Down Expand Up @@ -108,21 +85,6 @@ public boolean check(@NonNull BeforeCompilationContext context) {
return false;
}

private boolean isEslintFile(Path file) {
return file.getFileName().toString().equals(ESLINTRC);
}

private void copy(Path eslintrc, File pluginFolder) {
try {
Files.copy(
eslintrc,
new File(pluginFolder.getParent(), ESLINTRC).toPath(),
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new UncheckedIOException("Unable to copy eslintrc file", e);
}
}

private void compile(File path, File localCheckoutDir, String parentFolder, String pluginName)
throws PomExecutionException {
if (isSnapshotMultiParentPlugin(parentFolder, path, localCheckoutDir)) {
Expand Down

0 comments on commit 211bd88

Please sign in to comment.