I have a Gradle plugin implemented with Kotlin, which is built with a gradle kotlin DSL build script. This works fine. The build script is as follows and is located in the buildSrc directory of project:
plugins {
groovy
`kotlin-dsl`
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
testImplementation(gradleTestKit())
implementation(kotlin("gradle-plugin"))
implementation ("com.bmuschko:gradle-docker-plugin:6.1.3")
}
Now i want to call a existing Groovy Class in the same buildSrc Source Tree from the Kotlin Plugin code. This works fine in Intellij.
But when building with gradle i get a : unresolved reference Class for the Groovy Class.
Looking at the build, i see that the compileKotlin task is executed first. When i uncomment the failing reference, i see that the groovyCompile produces the correct binaries.
So i tried this:
tasks.compileKotlin {
dependsOn(tasks.compileGroovy)
}
Naturally that is not good enough, but i tried to get the build to compile the Groovy code first.
I got the following error:
Circular dependency between the following tasks:
:buildSrc:compileGroovy
\--- :buildSrc:compileJava
\--- :buildSrc:compileKotlin
\--- :buildSrc:compileGroovy (*)
So i tried without succeeding , to remove the compileJava task dependency from compileGroovy:
tasks.compileGroovy {
dependsOn.remove(tasks.compileJava)
}
Some problem as above. Basically it is unclear to me how to remove precondigured taskdependencies in gradle
What i really need is something equivalent to gradle groovy build as :
compileGroovy.dependsOn = compileGroovy.taskDependencies.values - 'compileJava'
compileKotlin.dependsOn compileGroovy
compileKotlin.classpath += files(compileGroovy.destinationDir)
classes.dependsOn compileKotlin
How would look that like the Gradle Kotlin Dsl?
Or are there better ways to solve this Groovy / Kotlin Code Dependency problem?
Version Info:
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_232 (AdoptOpenJDK 25.232-b09)
OS: Mac OS X 10.15.3 x86_64
I think this is equivalent, though I think it just knocks Java out of the picture, so Groovy/Kotlin/Java buildSrc code won't work...:
tasks {
val compileJava = named("compileJava", JavaCompile::class).get()
val compileKotlin = named("compileKotlin", KotlinCompile::class).get()
val compileGroovy = named("compileGroovy", GroovyCompile::class).get()
val classes by getting
compileGroovy.dependsOn.remove("compileJava")
compileKotlin.setDependsOn(mutableListOf(compileGroovy))
compileKotlin.classpath += files(compileGroovy.destinationDir)
classes.setDependsOn(mutableListOf(compileKotlin))
}
This has been vastly improved in Gradle 6.1
https://docs.gradle.org/6.1/release-notes.html#defining-compilation-order-between-groovy,-scala-and-java
And I'm not sure the above works for test ordering if they have unexpected language dependency ordering
I am getting this error while running a fragment test which is a simple test that launches fragmentInContatiner:
Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints:
Dependency path 'Host Work.features:ui-home:unspecified' --> 'androidx.test:runner:1.2.0' --> 'androidx.test:monitor:1.2.0'
Constraint path 'Host Work.features:ui-home:unspecified' --> 'androidx.test:monitor:{strictly 1.1.1}' because of the following reason: debugRuntimeClasspath uses version 1.1.1
Dependency path 'Host Work.features:ui-home:unspecified' --> 'androidx.fragment:fragment-testing:1.2.0-alpha02' --> 'androidx.test:core:1.1.0' --> 'androidx.test:monitor:1.1.1'
Here are my gradle dependencies that are creating this problem:
implementation 'androidx.fragment:fragment:1.2.0-alpha02'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha02'
implementation 'androidx.test:core:1.2.0-alpha02'
implementation 'androidx.test:runner:1.2.0-alpha02'
I found the problem and had to exclude the core module from fragment-testing dependency. It was this conflict that was creating the problem.
debugImplementation ("androidx.fragment:fragment-testing:1.2.5") {
exclude group: "androidx.test", module : "core"
}
Just excluding module: core didn't worked for me. I had same problem and I changed my espresso dependencies in this way successfully:
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
debugImplementation ("androidx.fragment:fragment-testing:1.3.6") {
exclude group:'androidx.test', module:'monitor'
}
As stated in this official issue: https://github.com/android/android-test/issues/481
I am trying to run Cucumber feature files in IntelliJ.
Cucumber Options is pointing to the right folder, but I get the "No tasks available" notification when trying to execute the JUnit runner class.
What am I doing wrong?
Here is my build.gradle:
plugins {
id 'java'
}
sourceCompatibility = 1.8
apply plugin: 'java'
repositories {
mavenCentral()
}
compileJava.options.encoding = "UTF-8"
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:4.7.1'
compile 'org.seleniumhq.selenium:selenium-server:2.44.0'
testImplementation 'io.cucumber:cucumber-java:4.7.1'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
compile group: 'io.cucumber', name: 'cucumber-java', version: '4.7.1'
compile group: 'io.cucumber', name: 'cucumber-junit', version: '4.7.1'
compile group: 'io.cucumber', name: 'cucumber-core', version: '4.7.1'
compile group: 'net.masterthought', name: 'cucumber-reporting', version: '3.20.0'
compile group: 'io.cucumber', name: 'gherkin', version: '5.1.0'
compile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
compile group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '3.6.0'
}
Ok, none of the proposed solutions worked, but I finally figured it out.
Went to Settings > Build, Execution, Deployment > Build Tools > Gradle and changed Run tests using: from Gradle (Default) to IntelliJ IDEA.
Note: found the solution here.
When I had this problem ("No tasks available" message when trying to run a test), what worked for me was to simply re-import the project from the Gradle view.
Right-click on project in Gradle view and select Reimport Gradle Project.
I was facing the same issue.
When using gradle make sure your project structure is correct.
Your tests should be in src>test>java
This resolved the issue for me.
"No tasks available" – I got this message when trying to run Spock test.
The reason was I did not have gradle plugins configured properly:
plugins {
id 'java-library'
id 'groovy' // this one is also necessary
}
Make sure you have 'groovy' plugin enabled, then re-import your project.
I had the same problem. When I used the full package name in glue it worked, this is mine:
...
features = "src/test/resources/features",
glue = {"test.java.stepdefinitions"},
...
I also faced a similar issue, In my case, it was because I forget to use the "public" access modifier while defining test class, and apparent with Junit 4, all test classes should be public.
I faced the same issue when I was trying to run the JUnit tests in my Gradle project. the solution worked in my case.
In the Android Studio, open the Gradle panel and right click on your project name, then click on Reload Gradle Project
I'm trying to set up Appium with Android Studio and encounter loads of errors. I include the necessary dependencies via Selenium and Appium jar file for java and use as a library, I get the following error:
Error: Program type already present: org.openqa.selenium.WebDriver$Window
**Just add the following dependency in your app gradle. it is working fine for me **
implementation('org.seleniumhq.selenium:selenium-java:2.41.0')
testImplementation group: 'junit', name: 'junit', version: '4.12'
I am an intermediate level tester who is currently exploring options for mobile automation. I am familiar with Appium/Selenium and am now attempting to introduce TestNG to manage test suites.
I have run into an error when attempting to build a simple project to begin mobile testing using TestNG and Appium/Selenium. I am unable to figure out how to fix this error.
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.mikejohnson.testngtest"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' // added this to resolve initial build conflict
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'org.testng:testng:6.11' //added this
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'org.seleniumhq.selenium:selenium-java:3.7.1' //added this
implementation 'io.appium:java-client:5.0.4' //added this
}
Here is the error:
Information:Gradle tasks [clean, :app:assembleDebug]
Warning:Ignoring InnerClasses attribute for an anonymous inner class
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Mike.Johnson\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-firefox-driver\3.7.1\460c39abe149b7c649dd05dd71ab64ca80f738aa\selenium-firefox-driver-3.7.1.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing org/openqa/selenium/firefox/FirefoxBinary.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Mike.Johnson\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-firefox-driver\3.7.1\460c39abe149b7c649dd05dd71ab64ca80f738aa\selenium-firefox-driver-3.7.1.jar
Information:BUILD FAILED in 10s
Information:4 errors
Information:1 warning
Information:See complete output in console
To get to this point all I have done is create a basic android project and attempted to add the required dependencies for TestNG and Appium/Selenium to build.gradle
The errors are introduced when combining the dependencies for TestNG and Appium/Selenium. The project is able to successfully build with just TestNG dependencies, or just Appium/Selenium dependencies. As soon as I combine TestNG along with Appium/Selenium, errors begin to appear.
I have searched and tried many possible solutions, however it always ends with a DexArchiveBulderException. I do not have the experience to deduce what is going wrong with the dependencies, and there is very little information available on 'DexArchiveBuilderException' when searching.
If there is any other information I can provide, please let me know. Thank you for the assistance in advance.
The initial problem is that you are trying to create Selenium tests inside Android project, at least it looks like you are adding dependencies to build.gradle in Android project.
And that is really strange way to start. Take look at official Appium java-client tests to get understanding how to design project
Problem fixed - recreated project in Intellij IDEA as a basic gradle/java project.