Skip to content

Commit

Permalink
feat: load package configuration file and upload it with enterprisePa…
Browse files Browse the repository at this point in the history
…ckage target

Ref: MISC-446
  • Loading branch information
Obero committed Jan 30, 2024
1 parent 58649c7 commit 4ba92c2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<maven3.version>3.0</maven3.version>
<header.basedir>${project.basedir}</header.basedir>
<junit.version>5.10.1</junit.version>
<gatling-enterprise-plugin-commons.version>1.9.0-M4</gatling-enterprise-plugin-commons.version>
<gatling-enterprise-plugin-commons.version>1.9.0-M6</gatling-enterprise-plugin-commons.version>

<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<maven-plugin-plugin.version>3.10.2</maven-plugin-plugin.version>
Expand All @@ -56,7 +56,8 @@
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version>
<spotless-maven-plugin.version>2.41.1</spotless-maven-plugin.version>
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
<apache-commons-version>3.14.0</apache-commons-version>
</properties>

<dependencies>
Expand All @@ -78,6 +79,11 @@
<version>${maven3.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache-commons-version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-enterprise-plugin-commons</artifactId>
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/io/gatling/mojo/EnterpriseUploadMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package io.gatling.mojo;

import io.gatling.plugin.BatchEnterprisePlugin;
import io.gatling.plugin.configuration.PackageConfiguration;
import io.gatling.plugin.exceptions.EnterprisePluginException;
import java.io.File;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -51,6 +54,21 @@ public final class EnterpriseUploadMojo extends AbstractEnterprisePluginMojo {

@Override
public void execute() throws MojoFailureException {
final BatchEnterprisePlugin enterprisePlugin = initBatchEnterprisePlugin();

final String projectDirectory = mavenProject.getBasedir().getAbsolutePath();
final String jsonConfig = PackageConfiguration.loadToJson(projectDirectory);

if (StringUtils.isNotBlank(jsonConfig)) {
try {
getLog().info("Package configuration file detected, applying it.");
packageId = enterprisePlugin.uploadPackageConfiguration(jsonConfig);
getLog().info("Package id: " + packageId);
} catch (EnterprisePluginException e) {
throw new MojoFailureException("Failed to upload package configuration", e);
}
}

if (packageId == null && simulationId == null) {
final String msg =
"Missing packageID\n"
Expand All @@ -62,7 +80,6 @@ public void execute() throws MojoFailureException {
}

final File file = enterprisePackage();
final BatchEnterprisePlugin enterprisePlugin = initBatchEnterprisePlugin();

RecoverEnterprisePluginException.handle(
() ->
Expand Down

0 comments on commit 4ba92c2

Please sign in to comment.