TestLinkAPIClient cannot be resolved to a type, already I added "testlink-java-api" dependency in maven, language used is java - selenium

TestLinkAPIClient cannot be resolved to a type, already I added “testlink-java-api” dependency in pom.xml.
Its maven project by using java
please find the below code
package com.tesco.pom.baseClass;
import br.eti.kinoshita.testlinkjavaapi.TestLinkAPIException;
public class ExecuteTestLinkResults implements TestLinkIntegration {
public static void reportTestCaseResult(String Project, String TestPlan,
String TestCase, String Build, String notes, String teststatus) throws TestLinkAPIException {
TestLinkAPIClient testlinkAPIClient = new TestLinkAPIClient(APIKEY, URL);
testlinkAPIClient.reportTestCaseResult(Project, TestPlan, TestCase, Build, notes,
teststatus);
}
}

TestLinkAPIClient does not provide any Maven dependency because it is a third party tool.
So you have to download and add jar files for that you can follow this link:
https://code.google.com/archive/p/dbfacade-testlink-rpc-api/downloads
Download "testlink-api-client-2.0.tar.gz" and import this jar file and start doing your work.
If you still want jar as Maven dependency then you can try and install jar files by following this link:
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Related

Add files to jar in gradle kotlin

My usecase is to copy files from another dependency and add it to the jar. For a build.gradle file it is done as
task copyConfiguration(type: Copy) {
from("${brazilGradle.path('[ABC]pkg.src')}")
into "${brazilGradle.buildDir}/schema"
}
sourceSets.main.resources {
srcDir "${brazilGradle.buildDir}/schema"
include 'src/*'
}
What will be the equivalent translation for build.gradle.kts?
Edit : I was able to copy the file using
task<Copy>("copyDdlSchemas") {
from("${brazilGradle.path("[ABC]pkg.src")}")
into("${brazilGradle.buildDir}/schema")
}
Need help with syntax to upload it to jar.
If what you want is the kotlin gradle equivalent of the sourceSets section in the question, it'll look like below:
sourceSets["main"].resources {
srcDir("${brazilGradle.buildDir}/schema")
include("src/*")
}
Once the files are part of the source set, they'll automatically get included in the jar file generated by the default jar task.

Compose gradle community plugins requiring a version in a binary plugin

I'm writing a binary plugin that's pushed as an artifact to a remote repository to be re-used. One of the things I want to accomplish with this plugin is to compose a set of additional plugins that should always be present. When composing official gradle plugins like the java plugin, that works fine. But I can't find the strategy for composing a community plugin requiring a version that would use this syntax in a build.gradle.kts file:
plugins {
id("com.diffplug.spotless") version "6.1.0"
}
All of the APIs I'm discovering in the gradle plugin library makes no reference of specifying a version, which makes me think I need to configure it elsewhere, like how a build can specify defaults in the pluginManagement block in settings.gradle.
This is a distilled version of how I'm trying to apply this.
import org.gradle.api.Plugin
import org.gradle.api.Project
class MyPlugin : Plugin<Project> {
override fun apply(target: Project) {
// This works OK
target.plugins.apply("java")
// This is a community plugin, so it requires a version be set and fails
target.plugins.apply("com.diffplug.spotless")
}
}
Is there an API I'm missing? Or am I approaching this from the wrong direction?
Solved this by following aSemy's advice in a comment. I stopped trying to declare community plugins by ID and switched to applying the class of the plugin, after adding it to my plugin's classpath.
build.gradle.kts
dependencies {
api("com.diffplug.spotless:spotless-plugin-gradle:6.3.0")
}
Plugin class:
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
class MyPlugin : Plugin<Project> {
override fun apply(target: Project) {
target.plugins.apply("java")
target.plugins.apply(SpotlessPlugin::class.java)
}
}

"Content is not allowed in prolog." IntelliJ Ultimate

The file I can download, for some reason I am getting a "Content is not allowed in prolog." error.
I am using IntelliJ IDEA 2021.1.3 (Ultimate Edition)
This is what my build.gradle.kts looks like:
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
plugins {
application
kotlin("jvm") version "1.5.21"
}
group = "com.pnerdyx"
version = "0.0.1"
application {
mainClass.set("com.pnerdyx.ApplicationKt")
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation("io.ktor:ktor-server-core:$ktor_version")
implementation("io.ktor:ktor-auth:$ktor_version")
implementation("io.ktor:ktor-auth-jwt:$ktor_version")
implementation("io.ktor:ktor-locations:$ktor_version")
implementation("io.ktor:ktor-server-host-common:$ktor_version")
implementation("io.ktor:ktor-webjars:$ktor_version")
implementation("org.webjars:jquery:3.2.1")
implementation("io.ktor:ktor-thymeleaf:$ktor_version")
implementation("io.ktor:ktor-gson:$ktor_version")
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
testImplementation("io.ktor:ktor-server-tests:$ktor_version")
testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlin_version")
}
What went wrong:
Execution failed for task ':compileKotlin'.
Could not resolve all files for configuration ':compileClasspath'.
Could not resolve com.typesafe:config:1.3.1.
Required by:
project : > io.ktor:ktor-server-core:1.6.1
Could not resolve com.typesafe:config:1.3.1.
Could not parse POM https://repo.maven.apache.org/maven2/com/typesafe/config/1.3.1/config-1.3.1.pom
Content is not allowed in prolog.
Could not resolve com.typesafe:config:1.3.1.
Could not parse POM https://jcenter.bintray.com/com/typesafe/config/1.3.1/config-1.3.1.pom
> Content is not allowed in prolog.
Link to project
Yup, turned out to be a path issue for Gradle in IntelliJ. I also had several version of gradle installed, decided to clean that up, and put the latest in the opt directory, and add the path to my environment file.

Gradle: Converting a copy task from groovy to kotlin gradle script

I am stuck with converting a groovy gradle script to kotlin script. I am trying to use pf4j in my project and have started converting their example build.gradle to .gradle.kts. Example can be found here: https://github.com/pf4j/pf4j/blob/master/demo_gradle/plugins/build.gradle
Since I got stuck I am trying it just for one plugin right now, however their example is applying the task to all subprojects. So be aware of the difference.
So I tried to replace their build example with the following gradle.kts file:
val pluginClass: String by project
val pluginId: String by project
val pluginProvider: String by project
val version: String by project
val pf4jVersion: String by project
dependencies {
implementation(project(":api"))
implementation("org.pf4j:pf4j:${pf4jVersion}")
annotationProcessor("org.pf4j:pf4j:${pf4jVersion}")
}
val buildPluginArchive = task("plugin", Jar::class) {
manifest {
attributes["Plugin-Class"] = pluginClass
attributes["Plugin-Id"] = pluginId
attributes["Plugin-Version"] = version
attributes["Plugin-Provider"] = pluginProvider
}
archiveBaseName.set("plugin-${pluginId}")
into("classes") {
from(sourceSets.main.get().output)
}
dependsOn(configurations.runtimeClasspath)
into("lib") {
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
archiveExtension.set("zip")
}
tasks {
"build" {
dependsOn(buildPluginArchive)
}
}
And it works and generates a zip, but the contents do not match the original. Firstly the lib folder does not only contain jar files, but also a folder structure (and more important a META-INF folder with MANIFEST.MF file that confuses the plugin loader). And it is missing the MANIFEST.MF in the classes/META-INF folder.
I suspect the issue being somwhere with this configuration in the original build.gradle:
into('classes') {
with jar
}
I just could not find any meaningful documentation about what "with jar" actually does or how to replicate the behavior in gradle.kts.
How can I get the same output as the demo with a gradle.kts configuration?
I just could not find any meaningful documentation about what "with jar" actually does
with is a method from the Jar task type. See the method details section of the Jar task, scroll to the bottom and you'll find information the with method. It's signature is:
CopySpec with(CopySpec... sourceSpecs)
Now if you were to look at the API documentation for Jar, you'll see that with actually comes from CopySpec which Jar implements thanks to its super class.
The jar part in with jar is referring to the task named jar which is created by the Java plugin.
With all of that said, a more idiomatic approach for the with part would be:
tasks {
val plugin by registering(Jar::class) {
into("classes") {
with(jar.get())
}
}
build {
dependsOn(plugin)
}
}

What's the difference between jython-standalone-2.7.0.jar and jython-2.7.0.jar

I wrote a Java example, the code is:
import org.python.core.PyObject;
import org.python.util.PythonInterpreter;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.List;
class JythonExample {
public static void main(String args[]) throws ScriptException {
listEngines();
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine pyEngine = mgr.getEngineByName("python");
try {
pyEngine.eval("print \"Python - Hello, world!\"");
} catch (Exception ex) {
ex.printStackTrace();
}
final PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("print \"Python - Hello, world!\"");
PyObject result = interpreter.eval("2 + 3");
System.out.println(result.toString());
}
public static void listEngines(){
ScriptEngineManager mgr = new ScriptEngineManager();
List<ScriptEngineFactory> factories =
mgr.getEngineFactories();
for (ScriptEngineFactory factory: factories) {
System.out.println("ScriptEngineFactory Info");
String engName = factory.getEngineName();
String engVersion = factory.getEngineVersion();
String langName = factory.getLanguageName();
String langVersion = factory.getLanguageVersion();
System.out.printf("\tScript Engine: %s (%s)\n",
engName, engVersion);
List<String> engNames = factory.getNames();
for(String name: engNames) {
System.out.printf("\tEngine Alias: %s\n", name);
}
System.out.printf("\tLanguage: %s (%s)\n",
langName, langVersion);
}
}
}
In my pom.xml, if I use:
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.0</version>
</dependency>
then I can run java -jar target/jython-example-1.0-SNAPSHOT.jar successfuly, by the way, I used maven-assembly-plugin to build a runnable jar.
if I use:
<dependency>
<groupId>org.python</groupId>
<artifactId>jython</artifactId>
<version>2.7.0</version>
</dependency>
then when I run java -jar target/jython-example-1.0-SNAPSHOT.jar, I'll always get the following error:
ScriptEngineFactory Info
Script Engine: jython (2.7.0)
Engine Alias: python
Engine Alias: jython
Language: python (2.7)
ScriptEngineFactory Info
Script Engine: Oracle Nashorn (1.8.0_31)
Engine Alias: nashorn
Engine Alias: Nashorn
Engine Alias: js
Engine Alias: JS
Engine Alias: JavaScript
Engine Alias: javascript
Engine Alias: ECMAScript
Engine Alias: ecmascript
Language: ECMAScript (ECMA - 262 Edition 5.1)
java.lang.NullPointerException
at me.soulmachine.JythonExample.main(JythonExample.java:21)
Exception in thread "main" ImportError: Cannot import site module and its dependencies: No module named site
Determine if the following attributes are correct:
* sys.path: ['/home/programmer/src/github/JythonExample/JythonExample/target/Lib', '__classpath__', '__pyclasspath__/']
This attribute might be including the wrong directories, such as from CPython
* sys.prefix: /home/programmer/src/github/JythonExample/JythonExample/target
This attribute is set by the system property python.home, although it can
be often automatically determined by the location of the Jython jar file
You can use the -S option or python.import.site=false to not import the site module
It seems the pyEngine is null.
So I wonder what's the difference between jython-standalone-2.7.0.jar and jython-2.7.0.jar
One problem I've just discovered with the same error is that the maven build 2.7.0 does not include the lib folder. This is probably a build error for the release build. I had to move up the b2 build which does properly include the lib folder in the supplied jar.
Problem maven 2.7.0 jar:
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.0</version>
</dependency>
Working maven 2.7.1b2 that includes the lib folder:
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.1b2</version>
</dependency>
NOTE: If you download the jar directly from the Jython site it does correctly include the lib folder. It's just the maven repository version.
I believe the main difference causing your issue is that the jython-standalone jar provides Lib/ (which contains site.py) while the jython jar does not.
https://github.com/scijava/jython-shaded gives a more in-depth description of the issue, as well as other issues, and provides an alternative jar to get around some issues noted in the description.
I don't have experience with scijava:jython-shaded, but I substituted it into your pom (for my setup I also had to change jdk.version to 1.7 and to JythonExample) and your example runs.