Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
Expand Down Expand Up @@ -114,6 +115,16 @@ public abstract class AbstractRecordMojo extends AbstractK6Mojo {
@Parameter(property = "k6.thinkTime.interactionDelay", defaultValue = "0.5")
protected double interactionDelay;

/**
* Current Maven session. Used to propagate the active local repository and
* user settings file to the forked Maven that runs the recorded test, so
* the fork resolves project SNAPSHOTs from the same repository the outer
* build is using (e.g. the maven-invoker-plugin's isolated
* {@code target/local-repo}).
*/
@Parameter(defaultValue = "${session}", readonly = true, required = true)
protected MavenSession session;

protected SourceHasher sourceHasher;

/**
Expand Down Expand Up @@ -344,6 +355,27 @@ protected List<String> buildBaseTestCommand(String currentTestClass) {
command.add("-Dserver.port=" + appPort);
command.add("-DfailIfNoTests=false");

// Propagate the outer build's local repository and settings to the
// fork. The maven-invoker-plugin runs ITs against an isolated
// target/local-repo containing freshly built SNAPSHOTs that the
// user's ~/.m2 does not have; without this, the fork resolves
// against ~/.m2 alone and fails to find e.g. vaadin-testbench-*:
// 10.2-SNAPSHOT.
if (session != null) {
if (session.getLocalRepository() != null
&& session.getLocalRepository().getBasedir() != null) {
command.add("-Dmaven.repo.local="
+ session.getLocalRepository().getBasedir());
}
File userSettings = session.getRequest() != null
? session.getRequest().getUserSettingsFile()
: null;
if (userSettings != null && userSettings.isFile()) {
command.add("-s");
command.add(userSettings.getAbsolutePath());
}
}

if (mavenArgs != null && !mavenArgs.isEmpty()) {
for (String arg : mavenArgs.split("\\s+")) {
command.add(arg);
Expand Down
Loading