In my gradle script I have following dependencies:
dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:'3.9.1'
compile group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '2.2.4'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.6.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.6.2'
compile group: 'org.uncommons', name: 'reportng', version:'1.1.4'
compile group: 'com.google.inject', name: 'guice', version:'4.0'
compile group: 'org.apache.commons', name:'commons-math3', version: '3.6.1'
testCompile group: 'org.testng', name: 'testng', version:'6.14.3'
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'}
As seen here I ask to use 6.14.3 as the testng version. Only when I try to run my script I get the issue:
Execution failed for task ':compileJava'.
I first checked if the Java version is correct, but no issues there. Only if i run gradle --debug. I found that testng jar downloaded was of version 7.0.0-beta4. But as I did not declare this I'm not sure why this is used or I can force to use the correct one?
Running ./gradlew dependencies should show you the following compile dependencies (amongst many others):
…
+--- org.uncommons:reportng:1.1.4
| +--- org.testng:testng:[5.0,) -> 7.0.0-beta6
| \--- velocity:velocity:1.4
| \--- velocity:velocity-dep:1.4
…
In other words, your declared compile dependency on org.uncommons:reportng:1.1.4 has a transitive dependency on TestNG which Gradle resolves to the latest TestNG version – since you don’t explicitly declare any other TestNG dependency for the compile configuration. Note that you only directly depend on TestNG from the testCompile configuration!
You should be able to fix this by changing your TestNG dependency declaration as follows:
compile group: 'org.testng', name: 'testng', version:'6.14.3'
Related
I'm using selenium for UI testing in java.
I have a module cloned from git hub which is being used in my project.
In spite of having the latest jar dependencies in my build.gradle file(intelliJ), I'm encountering
package org.openqa.selenium.html5 not found error
Only during runtime.
The selenium dependency does not complain at compile time, but during run time I am having errors that say
java:package org.openqa.selenium.logging does not exist
java:package org.openqa.selenium.remote does not exist
java:package org.openqa.selenium.support.ui does not exist
java:package org.openqa.selenium does not exist
I try clearing my gradle cache and re-installing the jars with the latest versions, and yet it's still the same issue.
These are the dependencies I have for selenium in my project:
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.0.0-alpha-2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '4.0.0-alpha-2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-api', version: '4.0.0-alpha-2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '4.0.0-alpha-2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version: '4.0.0-alpha-2'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '4.0.0-alpha-2'
I also tried with different versions of selenium, but nothing works.
Any solutions that I could try to fix this issue.
Or am I missing something?
I need help. My dependency is following:
compile group: 'org.springframework.cloud', name: 'spring-cloud-stream-binder-kinesis', version: '2.0.1.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '3.0.2.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework:spring-context-support'
I get the error:
java.lang.NoClassDefFoundError: org/springframework/web/context/support/StandardServletEnvironment
Is there something wrong with my dependency?
it's in spring-web, which is a dependency of spring-boot-starter-web. Here you've overridden spring-web with a very old Spring Framework version. That's the source of your problem.
I am new to Gradle, basically from Maven background.
I have the following dependency in one project [Lets call it 'Project A']
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
Now I want to use 'Project A' in 'Project B'. I have done the following to refer Project A in Project B.
Updated the settings.gradle of Project B to include Project A
include ':project-a'
project(':project-a').projectDir = new File('path to Project A')
Following is added to Project B build.gradle
implementation project(":project-a")
While synchronizing, Project B complains the following.
Could not run phased build action using Gradle distribution
'https://services.gradle.org/distributions/gradle-6.6.1-bin.zip'.
Build file 'path to project A\build.gradle' line: 9 A problem occurred
evaluating project ':project-a'. Could not find method
implementation() for arguments [{group=org.apache.commons,
name=commons-lang3, version=3.0}] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
UPDATE*
Java plugin added as requested in comment
apply plugin: 'java'
//plugins {
// id 'java'
//}
dependencies {
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
implementation group: 'org.springframework', name: 'spring-context', version: "${spring_version}"
implementation group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: "${springboot_version}"
implementation group: 'org.springframework.cloud', name: 'spring-cloud-context'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-commons'
versions are declared in gradle.properties file
spring_version=5.2.5.RELEASE
springboot_version=2.2.6.RELEASE
servlet_version=3.1.0
Now none of the dependencies are getting downloaded.
I am relatively new to using gradle, and am having trouble understanding dependencies. I have been using the Apache POI library to read from excel for a project, and initially I downloaded the JARs into my project and it worked completely fine. I decided to use gradle dependencies when I put my project on GitLab (from what I understand it is the same as using JARs but better when sharing the project since you don't have to download them?). This worked for most of the imports; however, for some reason my project is no longer able to import CellType. I redownloaded the JARs for the time being and it works again.
A summary of the question(s):
Why is CellType the only thing that stopped working, and why did it stop working? What is different about it?
Edit: here is the dependencies section from my build.gradle
compile 'com.google.apis:google-api-services-sheets:v4-rev499-1.23.0'
testCompile group: 'org.testng', name: 'testng', version: '6.9.10'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.8.1'
// https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-java6
compile group: 'com.google.oauth-client', name: 'google-oauth-client-java6', version: '1.11.0-beta'
// https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-jetty
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.11.0-beta'
// https://mvnrepository.com/artifact/org.apache.poi/poi
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
// https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.9'
// https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas
compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.17'
// https://mvnrepository.com/artifact/org.apache.commons/commons-collections4
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
(Sorry for the messiness :/ )
The compile error I was getting was something like "cannot resolve" (the import statement was turning red)
import org.apache.poi.ss.usermodel.CellType;
I am trying to figure out gradle and the netbeans plugin. I have easily been able to put together simple projects, but when trying to convert a project that uses JOGL to gradle I have run into problems. I can get it to compile, but when I try to get it to run, it does not. I assume it is not finding the native libraries.
Here is my build.gradle:
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = '1.6'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = 'com.protocase.viewer.JDesigner'
}
repositories {
mavenCentral()
maven {
url "https://repository.apache.org/content/repositories/snapshots/"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.10'
compile files('../logger/dist/logger.jar')
compile files('../postalker/build/libs/postalker.jar')
compile group: 'org.yaml', name: 'snakeyaml', version: '1.15+'
compile group: 'commons-io', name: 'commons-io', version: '2.4+'
compile group: 'gov.nist.math', name: 'jama', version: '1.0.3+'
compile group: 'org.apache.commons', name: 'commons-imaging', version: '1.0-SNAPSHOT+'
compile group: 'com.itextpdf', name: 'itextpdf', version: '5.5.5+'
compile files('/home/vextorspace/.netbeans/8.0.2/jogl-runtime/jogl.jar')
compile files('~/.netbeans/8.0.2/jogl-runtime/jogl.jar-natives-linux-amd64/libjogl_awt.so'\
, '~/.netbeans/8.0.2/jogl-runtime/jogl.jar-natives-linux-amd64/libjogl_cg.so', '~/.netbeans/8.\
0.2/jogl-runtime/jogl.jar-natives-linux-amd64/libjogl.so')
runtime fileTree(dir: '~/.netbeans/8.0.2/jogl-runtime/jogl.jar-natives-linux-amd64/', incl\
ude: '*.so')
compile files('~/.netbeans/8.0.2/gluegen-runtime/gluegen-rt.jar')
runtime files('~/.netbeans/8.0.2/gluegen-runtime/gluegen-rt.jar-natives-linux-amd64/libglu\
egen-rt.so')
compile files('libs/toxiclibscore.jar')
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.5+'
compile group: 'commons-codec', name: 'commons-codec', version: '1.6'
compile group: 'commons-logging', name: 'commons-logging', version: '1.1.3'
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.3.3'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.6'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.6'
}
but when I try to run I get
Executing: gradle run
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/sun/gluegen/runtime/DynamicLookupHelper
at java.lang.ClassLoader.defineClass1(Native Method)
Any help would be much appreciated!
Thank you
Avoid tilde character in paths in your build script. It is interpreted by bash when you use it on command line and Gradle knows nothing about it.