Publishing a SDK sub-package of your Keywords

I have a huge keywords code base, most of it business logic. (From early on in the lifecycle of this project I have taken on last year, I have refactored the testspace from “manual mode” “low-code” bloat, to high-code-but-highly-effective code base that is heavy on “Custom Keywords” but modular af and easy to reason about.

This code base consist mostly of business logic (e.g. models, page classes, business-logic-specific utils inside the utils classes (e.g. stuff about NPI numbers inside SMDNumberUtils)), that, for obvious reason, I don’t want published into the exported SDK. However, there’s a small backbone of general WebUI utils, record handlers, base model list builders, base model factory class, benchmark utils, … that I do want to make publish core SDK out of.

How can I do so, creating this SDK as a child code project of my main project, and publish this child project to the Katalon Keyword Store…?

1 Like

I do not really see what is your question.

Are you asking us how to create a jar file which contains your classes compiled from the sources in the Keywords/groovy folder?

Katalon Studio offers no built-in support for creating a jar of custom Keyword classes. You need to invent it for yourself.

I did it (create a jar file of custom classes out of Katalon poject) many times. Let me show you an example. I always use Gradle build tool.

If this does not help and you have other issues, please elaborate it.

1 Like

This is what I was looking for at the time!

Thank you so much! You are a godsend to this forum!!

Ima bookmark this, to come back to it when I have time for it!

NOTE: I’ll probably have more questions about this later on… I’ll see you on here at that time!

I’m back!

I have created the SDK project.

I am tryna implement your suggestions, as to make it consumable by other Katalon Studio projects, but it’s not working…

I am facing some issues

My build.gradle for the SDK project

Is like this:

plugins {
  id 'java'
  id 'maven-publish'
  id "com.katalon.gradle-plugin" version "0.1.1"
}

group = 'com.mikewarren'
version = '1.0'

repositories {
  mavenCentral()
}

dependencies {
  implementation 'com.github.javafaker:javafaker:1.0.2'
}

task sourceJar(type: Jar) {
    from sourceSets.main.allSource
    archiveClassifier = 'sources'
}

sourceSets {
    main {
        groovy {
            srcDirs = ['Keywords', 'Libs']
            excludes = ['CustomKeywords.groovy', "Temp*.groovy"]
        }
    }
    test {
        groovy {
            srcDirs = ['Include/scripts/groovy']
        }
    }
}

publishing {
    publications {
        katalonStudioSDK(MavenPublication) {
          artifact sourceJar

            groupId = project.group
            // name = project.rootProject.name
            description = 'Some building blocks for your Katalon Studio project'
            // url = 'https://github.com/MikeWarren2014/KatalonStudioSDK'
            from components.java

            // licenses {
            //     license {
            //         name = 'The Apache License, Version 2.0'
            //         url = 'https://www.apache.org.licenses/LICENSE-2.0.txt'
            //     }
            // }
            // developers {
            //     developer {
            //         id = 'MikeWarren2014'
            //         name = 'Warren,Michael'
            //         email = 'mwarren04011990@gmail.com'
            //     }
            // }
            // scm {
            //     connection = "scm:git:https://github.com/MikeWarren2014/${project.rootProject.name}.git"
            //     developerConnection = "scm:git:git@github.com:MikeWarren2014/${project.rootProject.name}.git"
            //     url = "https://github.com/MikeWarren2014/${project.rootProject.name}"
            // }
        }
    }
    repositories {
        maven {
            url "${project.buildDir}/repo"
        }
    }
}

What happens when you run it

It returns successfully:

Including it in another project

I do so like this:

plugins {
  id 'java'
  id "com.katalon.gradle-plugin" version "0.1.0"
}

repositories {
  mavenCentral()
}

dependencies {
  // sample dependencies
  // rest-assured
  // compile 'io.rest-assured:rest-assured:3.2.0'
  // JsonPath
  // compile 'io.rest-assured:json-path:3.2.0'
  // XmlPath
  // compile 'io.rest-assured:json-path:3.2.0'
  // JSON Schema Validation
  // compile 'io.rest-assured:json-schema-validator:3.2.0'
  implementation 'me.mikewarren.KatalonStudioSDK:1.0'
}

which leaves me the following error:


When I run gradle build --scan, I see that there are no sources to compile!

What am I doing wrong here?!

Are you trying to publish your jar file to the Maven Central repository?

If you want to do so, you have a lot more to learn and do. There are a lot of articles that tell you how to. For example, see Publish a Java Project to Maven Central with Gradle. I would warn you, it requires a lot of your efforts. And, if you just want to use your jar in another project, publishing your artifact to the Maven Central repository is not necessary .

All you need to do is to copy the jar from the source project’s build/libs directory into the target project’s Drivers folder.

At first, you can copy it manually, of course. Secondly, you can write some simple script to copy the file from the source to the target. Thirdly you can publish the jar into the local directory (so called “Maven Local repository”) which could be shared by multiple target projects on your local machine. You can write build.gradle of the target project so that it fetches the jar from the mavelLocal() repository. As far as you do not use the Maven Central repository, the com.katalon.gradle-plugin is of no use at all.

… do you understand? If not, please buy some good Gradle book and read it. It requires a lot of studies.

Directly copying and pasting it works.

After some more careful thinking, it turns out that deploying the project to some central Maven repository is a YAGNI for right now…

I’ll look into the mavenLocal() stuff. I’m pretty sure I can write to some shared repository folder outside the project folder, and then instruct the target script to pull from there…

I’ma have to up my Gradle game. Writing code is the easy stuff in comparison…

The Maven Central repository is a public place to share java libraries unlimited. If you want to share your Java/Gradle libraries only with limited group of people, the Maven Central repository is not appropriate place to host your artifacts.

I often use “Maven Repository on GitHub Packages” instead of the Maven Central repository. See

Having my libraries hosted on the GitHub Packages, my GitHub Actions can refer to those libraries’ jar.

I should probably aim for this instead…

As a matter of fact, I’m tryna wrap my head around this right now…