Issues with creating and consuming a Katalon Studio SDK

I am trying to create a SDK for use by other Katalon Studio projects.

I set up its build.gradle like:

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"
        }
    }
}



I then run gradle publish, which returns successfully.

I then go to check out the JAR, and it has all my source code in it. This is a good enough sign.

But, when I go try to use it in another project I’m starting up, I face issues:

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.4.2-bin.zip'.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'ZillowScraper'.
A problem occurred configuring root project 'ZillowScraper'.
A problem occurred evaluating root project 'ZillowScraper'.
Could not find method compile() for arguments [me.mikewarren.KatalonStudioSDK:1.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.Java(0)

Both these repositories are on the same machine.

What can I do to fix this, such that I can use this Katalon Studio SDK from any project?

The compile configuration is deprecated since many many years and was finally removed in Gradle 7.0.
As your consumer project is running Gradle 7.4.2, you cannot use compile, but probably implementation.

When I gradle build after that (change the compile to implementation), it returns no errors. However, it doesn’t fetch the dependency project into the current project!

Well, hard to guess without you providing any details about the consumer or at least a build --scan.

In the consumer project, my build.gradle is simply:

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'
}

Here is the build scan

Your compilation tasks have no sources, so they are skipped and afair thus also the dependency resolution.

I’m sorry…how do I provide the sources?

Java files, the thing that implement the logic in that project. I’m quite unsure what you are asking about.

Oh, my bad. This project is in Groovy…

It looks like I better swap that

id 'java'

that the Katalon Studio came up with, for

id 'groovy`

It seems like I should probably specify a groovyVersion to ship with it, for good measure…

1 Like