Skip to content

Commit

Permalink
Merge pull request #618 from Vlatombe/refactor-externalmavenrunner-co…
Browse files Browse the repository at this point in the history
…nstructor

Introduce a more useful `ExternalMavenRunner` constructor
  • Loading branch information
imonteroperez committed Aug 9, 2024
2 parents c01cdff + 9663c79 commit ceb1075
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class PluginCompatTester {

public PluginCompatTester(PluginCompatTesterConfig config) {
this.config = config;
runner = new ExternalMavenRunner(config.getExternalMaven(), config.getMavenSettings(), config.getMavenArgs());
runner = new ExternalMavenRunner(config);
}

@SuppressFBWarnings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.jenkins.tools.test.maven.ExpressionEvaluator;
import org.jenkins.tools.test.maven.ExternalMavenRunner;
import org.jenkins.tools.test.maven.MavenRunner;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
import org.jenkins.tools.test.model.hook.BeforeExecutionContext;
import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeExecution;

Expand All @@ -27,9 +26,7 @@ public abstract class PropertyVersionHook extends PluginCompatTesterHookBeforeEx

@Override
public boolean check(@NonNull BeforeExecutionContext context) {
PluginCompatTesterConfig config = context.getConfig();
MavenRunner runner =
new ExternalMavenRunner(config.getExternalMaven(), config.getMavenSettings(), config.getMavenArgs());
MavenRunner runner = new ExternalMavenRunner(context.getConfig());
ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator(
context.getCloneDirectory(), context.getPlugin().getModule(), runner);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.logging.Logger;
import org.apache.commons.lang.SystemUtils;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;

/** Runs external Maven executable. */
public class ExternalMavenRunner implements MavenRunner {
Expand Down Expand Up @@ -52,6 +53,13 @@ public ExternalMavenRunner(
this.mavenArgs = mavenArgs;
}

/**
* @param config The PCT configuration to extract maven arguments from.
*/
public ExternalMavenRunner(@NonNull PluginCompatTesterConfig config) {
this(config.getExternalMaven(), config.getMavenSettings(), config.getMavenArgs());
}

@Override
@SuppressFBWarnings(value = "COMMAND_INJECTION", justification = "intended behavior")
public void run(
Expand Down

0 comments on commit ceb1075

Please sign in to comment.