Skip to content

Commit

Permalink
chore: use gatling-shared-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Apr 24, 2024
1 parent cbe186b commit d5eac2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<header.basedir>${project.basedir}</header.basedir>
<junit.version>5.10.2</junit.version>
<gatling-enterprise-plugin-commons.version>1.9.1</gatling-enterprise-plugin-commons.version>
<gatling-shared-cli.version>0.0.1</gatling-shared-cli.version>

<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<maven-plugin-plugin.version>3.12.0</maven-plugin-plugin.version>
Expand Down Expand Up @@ -84,6 +85,11 @@
<artifactId>gatling-enterprise-plugin-commons</artifactId>
<version>${gatling-enterprise-plugin-commons.version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-shared-cli</artifactId>
<version>${gatling-shared-cli.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/io/gatling/mojo/GatlingMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.gatling.plugin.SimulationSelector;
import io.gatling.plugin.model.BuildPlugin;
import io.gatling.plugin.util.Fork;
import io.gatling.shared.cli.GatlingCliOptions;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -374,13 +375,13 @@ private List<String> gatlingArgs(String simulationClass) throws Exception {
: null;

List<String> args = new ArrayList<>();
addArg(args, "s", simulationClass);
addArg(args, "ro", reportsOnly);
addArg(args, "rf", resultsFolder.getCanonicalPath());
addArg(args, "rd", encodedRunDescription);
addArg(args, GatlingCliOptions.Simulation.abbr, simulationClass);
addArg(args, GatlingCliOptions.ReportsOnly.abbr, reportsOnly);
addArg(args, GatlingCliOptions.ResultsFolder.abbr, resultsFolder.getCanonicalPath());
addArg(args, GatlingCliOptions.RunDescription.abbr, encodedRunDescription);

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

String[] gatlingVersion =
Expand All @@ -392,8 +393,11 @@ private List<String> gatlingArgs(String simulationClass) throws Exception {
int gatlingMinorVersion = Integer.valueOf(gatlingVersion[1]);

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

return args;
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/io/gatling/mojo/RecorderMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import io.gatling.plugin.GatlingConstants;
import io.gatling.plugin.util.Fork;
import io.gatling.shared.cli.RecorderCliOptions;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -131,11 +132,17 @@ public void execute() throws MojoExecutionException, MojoFailureException {
private List<String> recorderArgs(
Path simulationsDirectory, String format, Path testResourcesDirectory) throws Exception {
List<String> arguments = new ArrayList<>();
addArg(arguments, "sf", simulationsDirectory.toFile().getCanonicalPath());
addArg(arguments, "fmt", format);
addArg(arguments, "rf", testResourcesDirectory.toFile().getCanonicalPath());
addArg(arguments, "pkg", packageName);
addArg(arguments, "cn", className);
addArg(
arguments,
RecorderCliOptions.SimulationsFolder.abbr,
simulationsDirectory.toFile().getCanonicalPath());
addArg(arguments, RecorderCliOptions.Format.abbr, format);
addArg(
arguments,
RecorderCliOptions.ResourcesFolder.abbr,
testResourcesDirectory.toFile().getCanonicalPath());
addArg(arguments, RecorderCliOptions.Package.abbr, packageName);
addArg(arguments, RecorderCliOptions.ClassName.abbr, className);
return arguments;
}
}

0 comments on commit d5eac2f

Please sign in to comment.