I'm trying to generate reports by ussing
gradlew clean test
command. It fails with error:
Error occured during intialization of VM
Error opening zip file or JAR nanifest missing : ${configurations.agent.singleFile}
Here's my build.gradle file:
group 'RegisteredUserFlow'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
jcenter()
}
configurations {
agent
}
dependencies {
agent 'org.aspectj:aspectjweaver:1.8.10'
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-2'
testCompile 'com.codeborne:selenide:4.4.3'
testCompile 'org.testng:testng:6.10'
testCompile 'io.qameta.allure:allure-testng:2.0-BETA6'
testCompile 'io.github.bonigarcia:webdrivermanager:1.6.2'
}
test.doFirst {
jvmArgs '-javaagent:${configurations.agent.singleFile}'
}
test {
useTestNG(){
suites'src/test/resources/testng.xml'
}
systemProperty 'allure.results.directory', 'build/allure-results'
systemProperty 'allure.link.issue.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
systemProperty 'allure.link.tms.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
}
I've been thinking that the problems are with aspectJ but I'm not sure.
Do I miss something in gradle file? Or is it somewhere in my test files? Or maybe there's a problems with latest Allure version? I see that jvmArgs is highlighted with gray (never used) - maybe problem with that?
Sorry for that much of questions I've never worked with Allure and aspectJ.
Thanks for any help!
Your problem is that you used a String where you should have used a GString.
jvmArgs '-javaagent:${configurations.agent.singleFile}'
This line is taken literally. It should have been
jvmArgs "-javaagent:${configurations.agent.singleFile}"
to get the placeholder replaced. (single- vs. double-quotes).
Related
I want to generate antlr4 lexer using gradle generateGrammarSource task.
Path to g4 file is src/main/antlr4/my/package/mygrammar.g4
I tried to use some examples I found so build.gradle has the following code:
buildscript {
ext.kotlin_version = '1.3.20'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
group 'my.package'
version '1.0-SNAPSHOT'
apply plugin: 'kotlin'
apply plugin: 'antlr'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile group: 'org.antlr', name: 'antlr4', version: '4.7.2'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}
generateGrammarSource {
arguments += ['-package', 'my.package']
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Executing generateGrammarSource task generates nothing and gives the following output:
:generateGrammarSource NO-SOURCE
BUILD SUCCESSFUL in 0s
How can I fix it?
you need to create directory src/main/antlr and add Kotlin grammar files into there. most likely the my/package/ is the reason why it cannot find the grammar files; while this answers hints for, to add generated sources to the source-set. see The ANTLR Plugin.
I'm pretty new to Gradle and Kotlin Native. I want to setup my build.gradle so that I can use Native to compile my code. I'm using the Konan plugin to do this. It worked fine when I hard-coded my class in the konanArtifacts.program.srcFiles. But obviously if I add more classes, I'll have to add the paths to srcFiles and I don't (and shouldn't) need to. So I looked around to find a way to add any classes I add automatically, and I attempted sourceSets. But when I try to run the compileKonanClientMingw task now my gradle console gives me the following:
error: you have not specified any compilation arguments. No output has been produced.
I'm not entirely sure that I'm using sourceSets correctly, but this seems to be the farthest I got. Below is my build.gradle
build.gradle:
buildscript {
ext.kotlin_version = '1.2.41'
ext.konan_version = '0.6'
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$konan_version"
}
}
plugins {
id 'java'
}
group 'net.dev909'
version '1.0'
apply plugin: 'kotlin'
apply plugin: 'konan'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
sourceSets.main.allSource.srcDir '/src/main/kotlin/'
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
konanArtifacts {
program('client-' + version) {
srcFiles sourceSets.main.runtimeClasspath
}
}
Source sets are a part of the Java world and the Java plugin, so the Kotlin/Native plugin avoids using them to be independent on Java. But you still able to compile a bunch of classes, just specify the srcDir parameter:
konanArtifacts {
program('client-' + version) {
srcDir 'src/main/kotlin/'
}
}
Also note that src/main/kotlin/ is a default source path. So if you use only this path, you don't need to specify it explicitly. You may just write:
konanArtifacts {
program('client-' + version)
}
As the title says I cannot force Allure 2 to generate reports for me on local machine.
I've tried a lot of things from Google but nothing helped. I use Kotlin+Selenide+TestNG to write tests, if it helps somehow :)
I'm a little bit confused with Allure because it has version for testNG and version for Gradle - which one should be used? Both?
Here's my build.gradle file:
group 'RegisteredUserFlow'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = "1.1.2-2"
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "ru.d10xa:gradle-allure-plugin:0.5.5"
}
}
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'ru.d10xa.allure'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
allure {
aspectjweaver = true
testNG = true
}
repositories {
jcenter()
}
configurations {
agent
}
dependencies {
agent "org.aspectj:aspectjweaver:1.8.10"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-2"
testCompile "com.codeborne:selenide:4.4.3"
testCompile "org.testng:testng:6.10"
testCompile "io.qameta.allure:allure-testng:2.0-BETA6"
testCompile "io.github.bonigarcia:webdrivermanager:1.6.2"
}
test.doFirst {
jvmArgs "-javaagent:${configurations.agent.singleFile}"
}
test {
useTestNG(){
suites 'src/test/kotlin/testng.xml'
}
systemProperty 'allure.results.directory', 'build/allure-results'
systemProperty 'allure.link.issue.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
systemProperty 'allure.link.tms.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
}
tasks.withType(Test)*.finalizedBy allureReport
Commands I used were: allure serve build/allure-results and gradlew clean test allureReport
Also, do I need Java plugin?
Appreciate any help!
Thanks!
P.S. Here's the error I get in console after gradlew clean test allureReport command:
Execution failed for task ':allureReport'.
> Could not resolve all dependencies for configuration ':allureReport'.
> Could not resolve org.slf4j:slf4j-api:1.7.12.
Required by:
project : > ru.yandex.qatools.allure:allure-bundle:1.4.24.RC3 > org.slf4j:slf4j-simple:1.7.12
project : > ru.yandex.qatools.allure:allure-bundle:1.4.24.RC3 > ru.yandex.qatools.allure:allure-report-data:1.4.24.RC3 > ru.yandex.qatools.allure:allure-report-plugin-api:1.4.24.RC3 > ru.yandex.qatools.allure:allure-model:1.4.24.RC3
The problem is that ru.d10xa:gradle-allure-plugin:0.5.5 is not support Allure 2. We are working on brand new Allure Gradle plugin that available here https://github.com/allure-framework/allure-gradle
At the moment you can use allure-commandline to generate the report at local machine and Allure Jenkins/Teamcity plugin to generate the report on CI.
Update
New Allure Gradle plugin that supports Allure 2 is available now. See the docs https://docs.qameta.io/allure/2.0/#_gradle_3 for more details.
I am trying to add errorprone to my gradle build file as follows:
relevant parts of build.gradle
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
}
}
plugins {
id 'java'
id 'application'
id 'idea'
id 'com.github.johnrengelman.shadow' version '1.2.4'
id "net.ltgt.errorprone" version "0.0.9"
}
dependencies {
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'
}
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.19'
}
error from classpath line when I run gradle clean
Could not find method classpath() for arguments [net.ltgt.gradle:gradle-errorprone-plugin:0.0.9] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Any thoughts on what is causing this issue and what might help resolve this? Thanks
I got errorprone to work with gradle by making the following changes:
replaced this from dependencies:
classpath net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'
with
errorprone "com.google.errorprone:error_prone_core:latest.release"
and removed the configurations line:
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.19'
}
This worked.
I am testing the Kotlin Quasar actor example.
Quasar and Kotlin – a Powerful Match
So the question is, is this example out of date and is there any documentation in which I can find out how to use Kotlin and Quasar?
This is my gradle.build file.
group 'no.inmeta.kotlin.akka'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.0.1'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "co.paralleluniverse:quasar-kotlin:0.7.4"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
I'm part of the Quasar team.
The post cites Quasar tests which you can run by cloning the Quasar repo and running e.g. gradle :quasar-kotlin:build (requires Gradle installed) but for new projects/experiments I suggest to start instead from the Gradle template, kotlin branch which now uses the latest Kotlin 1.0.1-2 (and for simplicity the latest Quasar 0.7.5-SNAPSHOT that depends on it).
Starting from that template I built this project (more info about how to configure it and run it in the main README) that runs the same Quasar actor tests as normal programs rather than tests. Here's its build.gradle:
group 'no.inmeta.kotlin.akka'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlinVer = '1.0.1-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVer"
}
}
apply plugin: 'kotlin'
apply plugin: 'application'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceCompatibility = 1.8 // 1.7
targetCompatibility = 1.8 // 1.7
configurations {
quasar
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
}
repositories {
// mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/releases" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
// maven { url 'https://maven.java.net/content/repositories/snapshots' }
}
ext.classifier = ':jdk8' // ':'
ext.quasarVer = '0.7.5-SNAPSHOT'
dependencies {
compile "co.paralleluniverse:quasar-core:${quasarVer}${classifier}"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVer"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVer"
compile "co.paralleluniverse:quasar-kotlin:${quasarVer}"
quasar "co.paralleluniverse:quasar-core:${quasarVer}${classifier}#jar"
}
applicationDefaultJvmArgs = [
"-Dco.paralleluniverse.fibers.verifyInstrumentation=true",
"-Dco.paralleluniverse.fibers.detectRunawayFibers=false",
"-javaagent:${configurations.quasar.singleFile}" // =v, =d
]
// mainClassName = 'co.paralleluniverse.kotlin.actors1.PingPongKt'
mainClassName = 'co.paralleluniverse.kotlin.actors2.PingPongWithDeferKt'
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
defaultTasks 'run'
Some notes about the differences with your build file:
Since I converted the tests to programs, I'm including the application plugin and its configuration (here, applicationDefaultJvmArgs and mainClassName) as well as setting the default Gradle task to run.
In addition to the above, a gradle wrapper has been generated and pushed so that ./gradlew is all you need on the command line, with no need to have a local Gradle installation (how to run it in an IDE depends on the IDE).
You need to run the Quasar agent (or AoT instrumentation but using the agent here) so there's a quasar configuration pointing to the artifact that is then used to pass the -javaagent:${configurations.quasar.singleFile} JVM argument.
Using Java 8 as Quasar has a specific optimized build for it.
Also note that there is now a 1.0 branch of the quasar-kotlin-jetbrains-webinar project (which is now the HEAD one in fact), which contains the companion source code of this guest webinar with IntelliJ, ported to the latest Kotlin and Quasar as well.
Let me know if this helps.