Background
I am trying to create a custom plugin named HighligtElement. The project is visible on GitHub at GitHub - kazurayam/HighlightingElementByTestObjectInEachAndEveryStep at pluginify. I am working on a git branch named pluginify.
I learned How to develop Custom Keywords Plugins to find how to create the jar file. I wrote a build.gradle file as follows:
plugins {
id 'java'
id 'groovy'
id 'com.github.johnrengelman.shadow' version '5.0.0'
id "com.katalon.gradle-plugin" version "0.0.7"
}
repositories {
jcenter()
mavenCentral()
}
sourceSets {
main {
groovy {
srcDirs = [ 'Keywords', 'Include/scripts/groovy' ]
srcDir 'Libs'
}
}
}
shadowJar {
exclude 'Temp*.class'
}
katalon {
dependencyPrefix = "com.katalon"
minimize = false
}
I executed the katalonPluginPackage task :
I got a jar file named build/libs/HighlightElementByTestObjectInEachAndEveryStep-all.jar
Problem
I do not like the name of the created jar file: HighlightElementByTestObjectInEachAndEveryStep-all.jar
Rather I want to name it as highlightelement-1.0.0.jar
-
HightlightELementByTestObjectInEachAndEveryStep
is the name of project. I want to keep it as is. I want to find out how to give to the jar a name different from the project name.
- The suffix
-all
is meaningless.I want to append a version number: -X.X.X
.
I think
It is necessary to modify the Gradle plugin com.katalon.gradle-plugin
to mee the above requirements.
1 Like
I did that by adding uploadArchives section, and providing artifactId in build.gradle like this:
uploadArchives {
def versionNo = β$versionNoβ
def repoUrl = ββ
repositories {
mavenDeployer {
repository(url: repoUrl) {
authentication(userName: β*******β, password: β********β)
}
pom.groupId = ββ
pom.version = versionNo
pom.artifactId = ββ
}
}
}
Here Im actually uploading the plugin in nexus and changing its name, may be you can do it by follwing something similar
1 Like
In the build.gradle, I can add a task katalonPluginPackageAndRename
which depends on the katalonPluginPackage
. The katalonPluginPackageAndRename
task will rename the build/libs/HighlightElementByTestObjectInEachAndEveryStep-all.jar
file to build/libs/highlightelement-1.0.0.jar
.
I can do it but do not like to.
I hope the com.katalon.gradle-plugin
is made better.
2 Likes
I have found out how to name the jar as highlightelement-xxx.jar
rather than HighlightElementByTestObjectInEachAndEveryStep-xxx.jar
.
Add settings.gradle
file in the project directory, where I write a single line:
rootProject.name="highlightelement"
as https://github.com/kazurayam/HighlightingElementByTestObjectInEachAndEveryStep/commit/003ce97837fa556c54d510d0aa913195358f78d2
then in the command line I ran
$ gradle katalonPluginPackage
I got
:HighlightingElementByTestObjectInEachAndEveryStep [pluginify]$ ls -la | grep settings
drwxr-xr-x 3 urayamakazuaki staff 96 6 12 06:11 .settings
drwxr-xr-x 4 urayamakazuaki staff 128 6 12 06:11 settings
-rw-r--r-- 1 urayamakazuaki staff 36 7 2 06:30 settings.gradle
:HighlightingElementByTestObjectInEachAndEveryStep [pluginify]$ ls -la build/libs
total 32
drwxr-xr-x 3 urayamakazuaki staff 96 7 2 06:31 .
drwxr-xr-x 7 urayamakazuaki staff 224 6 12 06:12 ..
-rw-r--r-- 1 urayamakazuaki staff 14301 7 2 06:30 highlightelement-all.jar
:HighlightingElementByTestObjectInEachAndEveryStep [pluginify]$
What is the rootProject.name
? See
1 Like
My problem is that I got
HighlightElementByTestObjectInEachAndEveryStep-all.jar
when I execute
$ gradle katalonPluginPackage
. I do not like the jar name. I want to make it named as
highlightelement-0.4.jar
.
Finally I have found out how to configure jar name of my custom plugin which is generated by katalonPluginPackage
task of the katalon gradle-plugin.
- create
<projectDir>/settings.gradle
file and write a line rootProject.name="highlightelement"
- in the
<projectDir>/build.gradle
file,
- write
version = 'x.x.x'
, which is to declare the version of my custom plugin
- wite
shadowJar { classifier = null }
, which is to remove -all
out of the jar name.
I got build.gradle file as this.
and I got a jar file named highlightelement-0.4.jar
as I wanted.
Let me add a memo for myself how I found the way to configure jar name.
- I read the source code of katalon gradle-plugin https://github.com/katalon-studio/gradle-plugin/blob/master/src/main/java/com/katalon/gradle/plugin/KatalonGradlePlugin.java . There I found that the
katalonPluginPackage
task depends on shadowJar
task.
- I found that the
shadowJart
task resolves name of the jar. I checked the documentation of Shadow / Configuring Output Name.
- The documemtation provides enough information how to configure jar name: specify baseName, version and classifier as I want.
1 Like