Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: keep compatility for gatling version < 3.11 #172

Merged
merged 1 commit into from
Apr 22, 2024
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
35 changes: 13 additions & 22 deletions src/main/java/io/gatling/mojo/GatlingMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}

validateGatlingVersion();

// Create results directories
if (!resultsFolder.exists() && !resultsFolder.mkdirs()) {
throw new MojoExecutionException(
Expand Down Expand Up @@ -182,24 +180,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

private void validateGatlingVersion() {
String gatlingVersion =
MojoUtils.findByGroupIdAndArtifactId(
mavenProject.getArtifacts(), GATLING_GROUP_ID, GATLING_MODULE_APP)
.getVersion();

String[] gatlingVersionParts = gatlingVersion.split("\\.");
int gatlingMajorVersion = Integer.valueOf(gatlingVersionParts[0]);
int gatlingMinorVersion = Integer.valueOf(gatlingVersionParts[1]);

if (gatlingMajorVersion < 3 || (gatlingMajorVersion == 3 && gatlingMinorVersion < 11)) {
throw new UnsupportedOperationException(
"Gatling version "
+ gatlingVersion
+ " is unsupported. Minimal supported version is 3.11.0");
}
}

private Set<File> runDirectories() {
File[] directories = resultsFolder.listFiles(File::isDirectory);
return directories == null ? Set.of() : Set.of(directories);
Expand Down Expand Up @@ -398,13 +378,24 @@ private List<String> gatlingArgs(String simulationClass) throws Exception {
addArg(args, "ro", reportsOnly);
addArg(args, "rf", resultsFolder.getCanonicalPath());
addArg(args, "rd", encodedRunDescription);
addArg(args, "l", "maven");
addArg(args, "btv", MavenProject.class.getPackage().getImplementationVersion());

if (noReports) {
args.add("-nr");
}

String[] gatlingVersion =
MojoUtils.findByGroupIdAndArtifactId(
mavenProject.getArtifacts(), GATLING_GROUP_ID, GATLING_MODULE_APP)
.getVersion()
.split("\\.");
int gatlingMajorVersion = Integer.valueOf(gatlingVersion[0]);
int gatlingMinorVersion = Integer.valueOf(gatlingVersion[1]);

if ((gatlingMajorVersion == 3 && gatlingMinorVersion >= 8) || gatlingMajorVersion > 4) {
addArg(args, "l", "maven");
addArg(args, "btv", MavenProject.class.getPackage().getImplementationVersion());
}

return args;
}
}