Skip to main content

How to resolve external dependencies for a plugin in Katalon Studio

This article shows you how to resolve external dependencies for a plugin.

Upload your dependencies to Maven Central Repository

Note:
  • If your dependencies are already available on the Maven Central Repository, skip this step.

To upload your dependencies to the Maven Central Repository, you can refer to this guide in the Maven document: Guide to uploading artifacts to the Central Repository.

Add your dependencies to the build.gradle file

Once your dependencies are available on Maven Central Repository, you can add them to the build.gradle file. You can refer to the build.gradle file in our sample project here on GitHub: Zip custom keywords plugin.

To open the build.gradle file in Katalon Studio, do as follows:

  1. Go to File > New > Project, check the Generate build.gradle file box

    Katalon Studio will generate a default build.gradle template.

    The build.gradle template

  2. Add your dependencies to the build.gradle file. For example, we want to add our external dependencies to the Zip custom keywords plugin. We enter the following code in the build.gradle file:

    For Gradle 7

    plugins {
    id 'java-library'
    id 'groovy'
    id 'com.github.johnrengelman.shadow' version '7.1.2'
    id 'com.katalon.gradle-plugin' version '0.1.1'
    }

    repositories {
    mavenCentral()
    }

    def pluginSources = [
    'Keywords',
    'Test Listeners',
    'Include/scripts/groovy'
    ]

    sourceSets {
    main {
    groovy {
    srcDirs = pluginSources
    srcDir 'Libs' // generated by Katalon Studio
    }
    }
    }

    shadowJar {
    exclude 'Temp*.class'
    }

    groovydoc {
    source = pluginSources
    docTitle = 'Zip Custom Keywords'
    }

    dependencies {
    implementation 'net.lingala.zip4j:zip4j:1.3.2'
    }

    The build.gradle file for Gradle 7

    For Gradle 5-6

    plugins {

    id 'java'

    id 'groovy'

    id 'com.github.johnrengelman.shadow' version '4.0.4'

    id "com.katalon.gradle-plugin" version "0.0.7"

    }

    repositories {

    jcenter()

    mavenCentral()

    }

    sourceSets {

    main {

    groovy {

    srcDirs = ['Keywords', 'Libs', 'Test Listeners', 'Include/scripts/groovy']

    }

    }

    }

    dependencies {

    compile 'net.lingala.zip4j:zip4j:1.3.2'

    }

    shadowJar {

    exclude 'Temp*.class'

    }

    katalon {

    dependencyPrefix = "com.katalon"

    minimize = false

    }

    The build.gradle file for Gradle 5-6

By doing this, your dependencies are repackaged to avoid conflicts with other plugins.

Repackaged dependencies in Gradle

See also