After updating the cucumber version to 7.2.3, Allure not generating reports. (unknown report and NaN%). It still uses the config file in the directory. I think it's not about the folder path. If I decrease the version to 5.6.0 it is working.
The related part of the pom.xml is like below.
Does anyone have a solution for this??
Thanks,
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.2.3</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<version>2.17.3</version>
</dependency>
<dependencies>
<argLine>
-Dcucumber.options="--plugin io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm
</argLine>
I know that it doesn't answer the exact question but hope it can help somebody.
I had the same issue with Gradle - build/allure-results folder had only one small json file that generated empty allure report.
It seems like not all the Cucumber and Allure versions are compatible with each other. So I have found a compatible versions pair of Cucumber and Allure. Surprisingly they are the same as author has:
cucumberVersion = '7.2.3'
allureVersion = '2.17.3'
related part of my build.gradle:
plugins {
id 'java'
id 'io.qameta.allure' version '2.9.1'
}
apply plugin: 'io.qameta.allure'
dependencies {
implementation group: 'io.cucumber', name: 'cucumber-java', version: '7.2.3'
testImplementation group: 'io.cucumber', name: 'cucumber-java', version: '7.2.3'
implementation group: 'io.qameta.allure', name: 'allure-cucumber7-jvm', version: '2.17.3'
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
task cucumber() {
dependsOn assemble, testClasses
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'html:results.html',
'--plugin', 'pretty',
'--plugin', 'io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm',
'--glue', 'step_definitions',
'src/test/resources']
}
}
}
No, no this problem is not depend any cucumber version. Allure report have to write allure-result to any folder on test executing so you can use this commandline under <argLine> raw your pom.xml.
<systemPropertyVariables>
<allure.results.directory>
${project.build.directory}/allure-results
</allure.results.directory>
</systemPropertyVariables>
Related
I'm developing a IDEA-Plugin. But after updating Intellij IDEA, the ide always show the warning that leading to the failure of code completion:
Cannot access class 'com.intellij.psi.PsiElement'. Check your module classpath for missing or conflicting dependencies
I have tried to upgrade gradle plugin or dependencies version, unfortunately it not work.
My build.gradle script at root project directory:
plugins {
id 'org.jetbrains.intellij' version '1.1.6'
id "org.jetbrains.kotlin.jvm" version '1.5.21'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
}
intellij {
version '2021.2'
plugins = ['java','Kotlin']
}
patchPluginXml {
changeNotes.set(
"""
Add change notes here.<br>
<em>most HTML tags may be used</em>
"""
)
}
test {
useJUnitPlatform()
}
My plugin.xml file:
<idea-plugin>
<id>org.example.TestPlugin</id>
<name>Plugin display name here</name>
<vendor email="support#yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
<description><![CDATA[
Enter short description for your plugin here.<br>
<em>most HTML tags may be used</em>
]]></description>
<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<depends>org.jetbrains.kotlin</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>
<actions>
<!-- Add your actions here -->
<action id="TestAction" class="org.example.TestAction" text="TestAction" description="TestAction">
<add-to-group group-id="GenerateGroup" anchor="last"/>
</action>
</actions>
</idea-plugin>
What's wrong with my Project? Thanks for your answer!
Since the IntelliJ SDK 2020.3, you're supposed to use Java 11, not 8.
Ref: https://blog.jetbrains.com/platform/2020/09/intellij-project-migrates-to-java-11/
Error:(11, 40) Kotlin: Cannot access built-in declaration
'kotlin.coroutines.SuspendFunction1'. Ensure that you have a
dependency on the Kotlin standard library
fun Route.coroutineHandler(fn: suspend (RoutingContext) -> Unit) {
handler { ctx ->
launch(ctx.vertx().dispatcher()) {
try {
fn(ctx)
} catch (e: Exception) {
ctx.fail(e)
}
}
}
Like Slaw commented just add the kotlinx-coroutines-core dependency to your project as described in the README
Maven
Add dependencies (you can also add other modules that you need):
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.3.5</version>
</dependency>
And make sure that you use the latest Kotlin version:
<properties>
<kotlin.version>1.3.70</kotlin.version>
</properties>
Gradle
Add dependencies (you can also add other modules that you need):
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
}
And make sure that you use the latest Kotlin version:
buildscript {
ext.kotlin_version = '1.3.70'
}
Make sure that you have either jcenter() or mavenCentral() in the list of repositories:
repository {
jcenter()
}
I am using javax.mail library in my project. My project is building fine using - mvn clean install, but when i try to debug my Intellij IDE shows error and it is not able to recognize the javax.mail imports. I have restarted my IDE from FILE -> Invalidate Caches and restart,still no luck.
These are not getting recognized by intellij IDEA,stating unused imports. I am using below the depeendency versions as:- javax.activation - 1.1.1 and javax.mail - 1.4.
Because the project is building fine,i believe the problem lies in some IDE setting.Kindly let me know if this can be resolved.
Try this maven dependency:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope> <!-- add this only if code will run in a java container (i.e. tomcat, etc)-->
</dependency>
And you should also see the mail classes under External Libraries -> Maven:javax.mail:mail:1.4 -> mail-1.4.jar -> javax.mail
There are also newer versions of the java mail dependency you can use, like 1.4.7 or 1.5.0-b01
The latest version (as pointed out by #Mark Rotteveel) is 1.6.3 and the maven coordinates have changed to jakarta:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.3</version>
</dependency>
Based on your code I have created a simplified project version with only two files; pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>message-test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
</dependencies>
</project>
and SendMail.java
package com.test;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Properties;
public class SendMail {
public static void main(String[] args) {
sendMail(new Exception("Problem with cable"));
}
public static void sendMail(Exception exception) {
String to = "destination#test.com";
String from = "sender#test.com";
String host = "smtp.test.com";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Trade-processor instance shutdown!");
message.setText(getExceptionMessage(exception));
Transport.send(message);
} catch (MessagingException mex) {
mex.printStackTrace();
}
}
private static String getExceptionMessage(Exception e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
}
Make sure your 'java' source folder is marked as source (right click on it and select 'Mark directory as -> sources root' if it is not already light blue)
Make sure the class package (com.test) names match i.e. 'src/main/java/com/test/SendMail' on the project pane and 'package com.test' in SendMail.java
I have Intellij Idea 2016.1 gradle-application(Not Android) written in Kotlin. I need to place it in jCenter and add to the Android-application as a dependency. I can not find any information about it. All references refer to the Android project. I have no concept of how this can be done. Looking for detailed instructions
Publishing Kotlin libraries to jCenter is absolutely the same as for JAva libraries.
buildscript {
ext.kotlinVersion = '1.0.2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins {
id "com.jfrog.bintray" version "1.6"
}
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
group '<groupId>'
version '<version>'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}
bintray {
user = '<bintray user name>'
key = '<bintray API key>'
publications = ['mavenJava']
pkg {
repo = '<repository name on bintray>'
name = '<artifactId>'
version {
name = project.version
released = new Date()
vcsTag = "v${project.version}"
}
}
}
task sourcesJar(type: Jar, dependsOn: project.classes) {
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: project.javadoc) {
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId project.bintray.pkg.name
from components.java
artifact sourcesJar {
classifier = 'sources'
}
artifact javadocJar {
classifier = 'javadoc'
}
}
}
}
Create a repository on bintray and then just call ./gradlew bintrayUpload. If you don't ask the bintray plugin to publish an uploaded dependency then you have to publish it manually from your bintray account.
When the dependency is published you can link it to jCenter from your account. After it's published on jCenter you can use it as a regular dependency from an Android project.
Michael's answer is correct. But if you execute bintrayUpload, the kotlin dependency will be included to the .pom file. This lead to adding kotlin libs twice when you include your lib in gradle-project. This lead to DuplicateFileException. I don't know what's wrong. Maybe I did some stupid mistake. But if this is your case to, you can execute gradlew build with Michael's build.gradle for generating .jar and source.jar. Then you can create your own .pom file with no dependencies and deploy 3 files(jar, source.jar and .pom) to bintray manually. Then link library to jCenter.
For example:
Generated .pom with ./gradlew bintrayUpload:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.livemaster</groupId>
<artifactId>LongToWords</artifactId>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.0.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
Your own .pom for deploying without kotlin-dependencies:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.livemaster</groupId>
<artifactId>LongToWords</artifactId>
<version>0.1</version>
</project>
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.