Facing issues while running cucumber with serenity - cucumber

To integrate Cucumber with Serenity, I have created below Gardle file. Serenity is working fine, however I am not able to use it with Cucumber. When I use #RunWith(CucumberWithSerenity.class) in runner class, it gives me unresolved type error.
build.gradle:
apply plugin: "java"
apply plugin: "maven"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
apply plugin: 'com.jfrog.bintray'
group = "myorg"
version = 1.0
repositories {
maven {
url "http://nexus2.sdmc.ao-srv.com/content/groups/inhouse_dit/"
}
}
buildscript {
repositories {
maven {
url "http://nexus2.sdmc.ao-srv.com/content/groups/inhouse_dit/"
}
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.47")
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
}
}
ext {
bintrayBaseUrl = 'https://api.bintray.com/maven'
bintrayRepository = 'maven'
bintrayPackage = 'serenity-cucumber'
projectDescription = 'Serenity Cucumber integration'
if (!project.hasProperty("bintrayUsername")) {
bintrayUsername = 'wakaleo'
}
if (!project.hasProperty("bintrayApiKey")) {
bintrayApiKey = ''
}
serenityCoreVersion = '1.0.49'
cucumberJVMVersion = '1.2.2'
//versionCounter = new ProjectVersionCounter(isRelease: project.hasProperty("releaseBuild"))
}
sourceSets.all { set ->
def jarTask = task("${set.name}Jar", type: Jar) {
baseName = baseName + "-$set.name"
from set.output
}
artifacts {
archives jarTask
}
}
sourceSets {
api
impl
}
dependencies {
apiCompile 'commons-codec:commons-codec:1.5'
implCompile sourceSets.api.output
implCompile 'commons-lang:commons-lang:2.6'
compile "info.cukes:cucumber-java:${cucumberJVMVersion}"
compile "info.cukes:cucumber-junit:${cucumberJVMVersion}"
testCompile 'net.serenity-bdd:core:1.0.47'
testCompile 'net.serenity-bdd:serenity-junit:1.0.47'
testCompile('junit:junit:4.11')
testCompile('org.assertj:assertj-core:1.7.0')
testCompile('org.slf4j:slf4j-simple:1.7.7')
testCompile sourceSets.api.output
testCompile sourceSets.impl.output
testCompile 'org.codehaus.groovy:groovy-all:2.3.6'
testCompile("org.spockframework:spock-core:0.7-groovy-2.0") {
exclude group: "junit"
exclude module: "groovy-all"
}
testCompile("com.github.goldin:spock-extensions:0.1.4") {
exclude module: "spock-core"
exclude module: "slf4j-api"
}
runtime configurations.apiRuntime
runtime configurations.implRuntime
}
gradle.startParameter.continueOnFailure = true
jar {
from sourceSets.api.output
from sourceSets.impl.output
manifest {
attributes("Implementation-Title": "Serenity Cucumber Plugin",
"Implementation-Version": project.version.toString())
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
bintray {
user = bintrayUsername //this usually comes form gradle.properties file in ~/.gradle
key = bintrayApiKey //this usually comes form gradle.properties file in ~/.gradle
publications = ['mavenJava'] // see publications closure
pkg {
repo = 'maven'
userOrg = 'serenity'
name = 'serenity-cucumber'
desc = 'Serenity Cucumber integration'
licenses = ['Apache-2.0']
labels = ['serenity','bdd','cucumber']
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri("${buildDir}/repo"))
addFilter("main") { artifact, file -> artifact.name == project.name }
["api", "impl"].each { type ->
addFilter(type) { artifact, file -> artifact.name.endsWith("-$type") }
// We now have to map our configurations to the correct maven scope for each pom
["compile", "runtime"].each { scope ->
configuration = configurations[type + scope.capitalize()]
["main", type].each { pomName ->
pom(pomName).scopeMappings.addMapping 1, configuration, scope
}
}
}
}
}
}
task wrapper (type: Wrapper) {
gradleVersion = '2.3'
distributionUrl = 'http://nexus2.sdmc.ao-srv.com/content/repositories/inhouse_dit_thirdparty/org/gradle/gradle-bin/2.3/gradle-2.3-bin.zip'
}
Please suggest what I need to change to run serenity with Cucumber. Thanks in advance.

You need to add serenity-cucumber to your dependencies:
testCompile 'net.serenity-bdd:serenity-cucumber:1.0.17'

Following line fixed the issue for me (gradle 4.10):
testCompile group: 'net.serenity-bdd', name: 'serenity-cucumber', version: '1.9.40'

Related

Failed to apply plugin [id 'org.gradle.checkstyle']?

How to solve this error?
Error:(24, 1) A problem occurred evaluating root project 'myproject10'.
Failed to apply plugin [id 'org.gradle.checkstyle']
Could not create service of type CachingFileHasher using TaskExecutionServices.createFileSnapshotter().
subprojects {
def projectName = it.name
if (projectName != "graphql-java-support") {
apply from: "../gradle/dependencies.gradle"
}
buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'https://maven.google.com' }
}
if (projectName != "graphql-java-support") {
apply plugin: 'checkstyle'
checkstyle {
toolVersion = "5.9"
configFile rootProject.file('checkstyle.xml')
configProperties = ['checkstyle.cache.file': rootProject.file('build/checkstyle.cache')]
ignoreFailures false
showViolations true
}
task checkstyle(type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
classpath = files()
}
afterEvaluate {
if (project.tasks.findByName('check')) {
check.dependsOn('checkstyle')
}
}
}
}
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}

No such field: maven for class: org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig

I try to build java library using android studio and want to host at my local artifactory.
I face this problem at noon. Try different code, but no improvements.
buildscript {
repositories {
jcenter()
}
repositories {
maven {
url 'http://localhost:8081/artifactory/libs-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
name = "maven-main-cache"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1"
}
}
project.getExtensions().getByName("ext")
apply plugin: 'scala'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"
version = '1.0.0-SNAPSHOT'
group = 'com.buransky'
repositories {
add buildscript.repositories.getByName("maven-main-cache")
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.2'
}
tasks.withType(ScalaCompile) {
scalaCompileOptions.useAnt = false
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-snapshot-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
Above my build.gradle code block.
Please help. I didn't found any solutions in google
Looking here it looks like it's
artifactory {
publish {
repository {
ivy {
mavenCompatible = true
}
}
}
}
Instead of
artifactory {
publish {
repository {
maven = true
}
}
}

Gradle task dependencies on dynamically created tasks

I have a multiproject build where I need to publish some dependencies to a custom local Maven repository on disk and then add this folder to a distribution zip.
I define publishing tasks for each subproject using the maven-publish plugin.
subprojects {
apply plugin: 'maven-publish'
configurations {
offlineDependencies
}
publishing {
publications {
configurations.each { config ->
if (config.name == "offlineDependencies") {
def files = config.files
config.dependencies.each { dep ->
files.each { file ->
if (file.name == "${dep.name}-${dep.version}.jar") {
"${dep.name}"(MavenPublication) {
artifact (file) {
groupId = "${dep.group}"
artifactId = "${dep.name}"
version = "${dep.version}"
}
}
}
}
}
}
}
}
repositories {
maven {
name 'dependencies'
url '../build/repository'
}
}
}
}
Using the distribution plugin I create a zip file
distributions {
release {
baseName 'release'
contents {
from('src/main/resources/')
into("repository"){
from("$buildDir/repository")
}
}
}
}
How can I make sure that all the dynamically created publish tasks are run before creating the zip file?
I tried making a new task for all subprojects that depends on the dynamically created tasks, but it seems they're not created yet at that time.
subprojects {
task offlineDep << {
println 'Creating offline dependencies'
}
offlineDep.dependsOn {
tasks.findAll { task -> task.name.endsWith('PublicationToDependenciesRepository') }
}
}
I found a solution to this problem. By collecting the names of the artifacts and generating the tasknames I know will be created later and adding them as dependencies.
subprojects {
apply plugin: 'maven-publish'
def offlineDependencyNames = []
publishing {
publications {
configurations.each { config ->
if (config.name == "offlineDependencies") {
def files = config.files
config.dependencies.each { dep ->
files.each { file ->
if (file.name == "${dep.name}-${dep.version}.jar") {
offlineDependencyNames << dep.name
"${dep.name}"(MavenPublication) {
artifact (file) {
groupId = "${dep.group}"
artifactId = "${dep.name}"
version = "${dep.version}"
}
}
}
}
}
}
}
}
repositories {
maven {
name 'dependencies'
url "${rootProject.buildDir}/repository"
}
}
}
task publishOfflineDependencies
publishOfflineDependencies.dependsOn {
offlineDependencyNames.collect { name ->
"publish${name[0].toUpperCase()}${name.substring(1)}PublicationToDependenciesRepository"
}
}
}
releaseDistZip.dependsOn {
subprojects.collect {
p -> p.path + ':publishOfflineDependencies'
}
}

ndk-build.cmd: command not found 3

Error:Execution failed for task ':imagepipeline:ndk_build_bitmaps'.
A problem occurred starting process 'command 'ndk-build.cmd''
How to solve?The problem with for a long time, don't know how to do?For the great spirit guide
apply plugin: 'com.android.library'
apply plugin: 'maven'
project.group = GROUP
version = VERSION_NAME
apply plugin: 'org.robolectric'
apply plugin: 'de.undercouch.download'
import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
dependencies {
provided "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
compile "com.parse.bolts:bolts-android:${BOLTS_ANDROID_VERSION}"
compile "com.nineoldandroids:library:${NINEOLDANDROID_VERSION}"
compile "com.android.support:support-v4:${SUPPORT_V4_VERSION}"
provided "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"
compile project(':fbcore')
testCompile "com.google.guava:guava:${GUAVA_VERSION}"
testCompile "junit:junit:${JUNIT_VERSION}"
testCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
testCompile "org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}"
testCompile "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
testCompile "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"
testCompile("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}") {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
apply from: rootProject.file('release.gradle')
// We download various C++ open-source dependencies from SourceForge into nativedeps/downloads.
// We then copy both downloaded code and our custom makefiles and headers into nativedeps/merge.
def nativeDepsDir = new File("${projectDir}/nativedeps")
def downloadsDir = new File("${nativeDepsDir}/downloads")
def mergeDir = new File("${nativeDepsDir}/merge")
task createNativeDepsDirectories {
nativeDepsDir.mkdirs()
downloadsDir.mkdirs()
mergeDir.mkdirs()
}
task downloadGiflib(dependsOn: createNativeDepsDirectories, type: Download) {
src 'http://downloads.sourceforge.net/project/giflib/giflib-5.1.1.tar.gz'
onlyIfNewer true
overwrite false
dest downloadsDir
}
task downloadLibjpeg(dependsOn: createNativeDepsDirectories, type: Download) {
src 'http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.1/libjpeg-turbo-1.3.1.tar.gz'
onlyIfNewer true
overwrite false
dest downloadsDir
}
task downloadLibpng(dependsOn: createNativeDepsDirectories, type: Download) {
src 'http://downloads.sourceforge.net/project/libpng/libpng16/older-releases/1.6.10/libpng-1.6.10.tar.gz'
onlyIfNewer true
overwrite false
dest downloadsDir
}
task downloadLibwebp(dependsOn: createNativeDepsDirectories, type: Download) {
src 'https://github.com/webmproject/libwebp/archive/v0.4.2.tar.gz'
onlyIfNewer true
overwrite false
dest downloadsDir
}
task unpackGiflib(dependsOn: downloadGiflib, type: Copy) {
from tarTree(resources.gzip("${downloadGiflib.dest}/giflib-5.1.1.tar.gz"))
into "${downloadsDir}"
}
task unpackLibjpeg(dependsOn: downloadLibjpeg, type: Copy) {
from tarTree(resources.gzip("${downloadLibjpeg.dest}/libjpeg-turbo-1.3.1.tar.gz"))
into "${downloadsDir}"
}
task unpackLibpng(dependsOn: downloadLibpng, type: Copy) {
from tarTree(resources.gzip("${downloadLibpng.dest}/libpng-1.6.10.tar.gz"))
into "${downloadsDir}"
}
task unpackLibwebp(dependsOn: downloadLibwebp, type: Copy) {
from tarTree(resources.gzip("${downloadLibwebp.dest}/v0.4.2.tar.gz"))
into "${downloadsDir}"
}
task copyGiflib(dependsOn: unpackGiflib, type: Copy) {
from "${unpackGiflib.destinationDir}/giflib-5.1.1/lib"
from 'src/main/jni/third-party/giflib'
include('*.c', '*.h', '*.mk')
into "${mergeDir}/giflib"
}
task copyLibjpeg(dependsOn: unpackLibjpeg, type: Copy) {
from "${unpackLibjpeg.destinationDir}/libjpeg-turbo-1.3.1"
from 'src/main/jni/third-party/libjpeg-turbo-1.3.x'
include('**/*.c', '**/*.h','**/*.S', '**/*.asm', '**/*.inc', '*.mk')
into "${mergeDir}/libjpeg-turbo-1.3.x"
}
task copyLibpng(dependsOn: unpackLibpng, type: Copy) {
from "${unpackLibpng.destinationDir}/libpng-1.6.10"
from 'src/main/jni/third-party/libpng-1.6.10'
include('**/*.c', '**/*.h', '**/*.S', '*.mk')
into "${mergeDir}/libpng-1.6.10"
}
task copyLibwebp(dependsOn: unpackLibwebp, type: Copy) {
from "${unpackLibwebp.destinationDir}/libwebp-0.4.2"
from 'src/main/jni/third-party/libwebp-0.4.2'
include('src/**/*.c', 'src/**/*.h', '*.mk')
into "${mergeDir}/libwebp-0.4.2"
}
task fetchNativeDeps(dependsOn: [copyGiflib, copyLibjpeg, copyLibpng, copyLibwebp]) {
}
task removeNativeDeps(type: Delete) {
delete nativeDepsDir
}
allclean.dependsOn removeNativeDeps
def getNdkBuildName() {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
return "ndk-build.cmd"
} else {
return "ndk-build"
}
}
def getNdkBuildFullPath() {
// we allow to provide full path to ndk-build tool
if (hasProperty('ndk.command')) {
return property('ndk.command')
}
// or just a path to the containing directiry
if (hasProperty('ndk.path')) {
def path = property('ndk.path')
if (!path.endsWith(File.separator)) {
path += File.separator
}
return path + getNdkBuildName()
}
// if none of above is provided, we assume ndk-build is already in $PATH
return getNdkBuildName()
}
def makeNdkTasks(String name, Object[] deps) {
task "ndk_build_$name"(dependsOn: deps, type: Exec) {
inputs.file("src/main/jni/$name")
outputs.dir("$buildDir/$name")
commandLine getNdkBuildFullPath(),
'NDK_PROJECT_PATH=null',
'NDK_APPLICATION_MK=../Application.mk',
'NDK_OUT=' + temporaryDir,
"NDK_LIBS_OUT=$buildDir/$name",
'-C', file("src/main/jni/$name").absolutePath,
'--jobs', '8'
}
task "ndk_clean_$name"(type: Exec) {
ignoreExitValue true
commandLine getNdkBuildFullPath(),
'NDK_PROJECT_PATH=null',
'NDK_APPLICATION_MK=../Application.mk',
'NDK_OUT=' + temporaryDir,
"NDK_LIBS_OUT=$buildDir/$name",
'-C', file("src/main/jni/$name").absolutePath,
'clean'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn "ndk_build_$name"
}
clean.dependsOn "ndk_clean_$name"
}
android {
def ndkLibs = [
['bitmaps', []],
['gifimage', [copyGiflib]],
['imagepipeline', [copyLibjpeg, copyLibpng, copyLibwebp]],
['memchunk', []],
['webpimage', [copyLibwebp]]]
buildToolsVersion "21.1.2"
compileSdkVersion 21
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDirs = ndkLibs.collect { "$buildDir/${it[0]}" }
}
}
ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] }
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts.add('archives', sourcesJar)
You don't have ndk-build in the path.
Have you configured the android-ndk properly?
Try adding it and that problem should be solved

Compile error during compilation with javac | Groovy

Have an err with compiling gradle idea
error see on screen
http://upwap.ru/1884422
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'code-quality'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'project-reports'
sourceCompatibility = 1.6 archivesBaseName = 'opas-client'
ideaModule { downloadJavadoc = true }
buildscript {
repositories {
mavenRepo urls: "f:/dev/lib/"
}
}
version = '0.1'
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(':release')) {
version = '0.1.2' // } else { // version = '1.0.624'
}
}
repositories {
mavenRepo urls: "f:/dev/lib/"
}
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.7.5'
compile 'log4j:log4j:1.2.14',
'com.caucho:hessian:4.0.7',
'com.toedter:jcalendar:1.3.2',
'org.springframework:spring-context-support:3.0.5.RELEASE',
'org.springframework:spring-web:3.0.5.RELEASE',
'com.jgoodies:looks:2.2.2',
'com.jgoodies:animation:1.2.0',
'com.jgoodies:binding:2.0.6',
'com.jgoodies:forms:1.2.1',
'com.jgoodies:validation:2.0.1'
testCompile 'junit:junit:4.7',
'org.unitils:unitils-spring:3.1',
'org.unitils:unitils-easymock:3.1',
'org.unitils:unitils-inject:3.1',
'org.springframework:spring-test:3.0.5.RELEASE'
}
manifest.mainAttributes(
'Implementation-Title': 'victoria',
'Implementation-Version': version,
'Main-Class': 'com.sirius.opas.client.Client',
'Class-Path':manifestClasspath() )
task release(dependsOn: 'jar') << {
ant.delete(dir:releaseDir, quiet:"true" )
ant.mkdir(dir:releaseDir)
copy {
from configurations.compile
into "${releaseDir}/${releaseLibDir}"
}
copy {
from "$libsDir/${archivesBaseName}-${version}.jar"
from "dist/start.sh"
from "dist/start.cmd"
into "${releaseDir}"
}
}
String manifestClasspath() {
String classes = ""
configurations.compile.files.each { file ->
classes += " ${releaseLibDir}/${file.name}"
}
return classes
}
I think you are simply missing a dependency that provides BeanDefinition class. Try adding 'org.springframework:spring-beans:3.0.5.RELEASE' to your compile dependencies list.

Resources