Skip to content

Commit

Permalink
chore: keep compatility for gatling version < 3.11
Browse files Browse the repository at this point in the history
Ref: 7335906
  • Loading branch information
bastien-gatling authored and slandelle committed Apr 22, 2024
1 parent 352ae97 commit 02bbb7d
Showing 1 changed file with 13 additions and 22 deletions.
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;
}
}

0 comments on commit 02bbb7d

Please sign in to comment.