Create a custom action with Gradle

You can create a custom action in NeoLoad using Gradle as your build system in IntelliJ IDEA. This topic walks you through setting up a Gradle project, implementing the required classes, and installing the custom action in NeoLoad. For more information about Gradle, check out their documentation (opens in new tab).

Before you start

Choose the correct Java Development Kit (JDK) based on your NeoLoad version:

  • JDK 21 for NeoLoad 2025.1 or later.

  • JDK 11 for earlier versions.

Configure Gradle

Before you configure the project in Gradle, make sure to check these indications:

  • Open IntelliJ IDEA and create a new project.

  • Select Gradle as the build system.

  • Choose the Java language.

In your build.gradle.kts file, paste the following configuration:

Copy
plugins {
    id("java")
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
    maven(url = uri("https://maven.neotys.com/content/groups/public/"))
}

dependencies {
    implementation("com.neotys.actions:neotys-custom-action-api:2.16.2")
    annotationProcessor("com.google.auto.service:auto-service:1.1.1")
    compileOnly("com.google.auto.service:auto-service:1.1.1")
}

Build the custom action

Follow these step to build your custom action:

  1. Implement the Action class:

    • Create a new Java class that implements com.neotys.extensions.action.Action

    • Add the @AutoService(Action.class) annotation

    • Implement all required methods, including: getType(), getDefaultParameters(), getDescription(), getMinimumNeoLoadVersion(), (return Optional.absent()), getMaximumNeoLoadVersion(), (return Optional.absent())

  2. Add a custom icon (optional):

    • Save a 20x20 px icon in the resources/{your.package.name} directory

    • Implement the getIcon() method:

    Copy
    @Override
    public Icon getIcon() {
        return new ImageIcon(Objects.requireNonNull(getClass().getResource("icon.png")));
    }
  3. Create and link the ActionEngine class:

    • Create a class that implements com.neotys.extensions.action.engine.ActionEngine

    • Fill in the execute method to define behavior and result

    • Link the engine to your Action class using getEngineClass() or relevant binding

  4. Install the custom action in NeoLoad:

    • Run Maven > install from the IntelliJ UI

    • Copy the generated JAR from the target folder

    • Place the JAR in <NeoLoad install dir>/extlib (global use), or project-dir/lib/extlib (project-specific use)

For more information on custom actions, check out custom actions API.