I want to use testcontainer during code generation. I have a project for 2 modules:
processor (with implementation of SymbolProcessorProvider and BuildProcessor)
workload
This is my build.gradle.kts in processor module
plugins {
kotlin("jvm")
}
group = "com.processor"
version = "1.0-SNAPSHOT"
val testcontainers = "1.17.6"
dependencies {
implementation(kotlin("stdlib"))
implementation("com.squareup:javapoet:1.12.1")
implementation("com.google.devtools.ksp:symbol-processing-api:$kspVersion")
implementation("org.testcontainers:testcontainers:$testcontainers")
}
Unfortunately I get this error when I try to run any container:
Script file extensions:
[KOTLIN] Kotlin compilation 'jdkHome' argument: /Users/user/Library/Java/JavaVirtualMachines/adopt-openjdk-1.8.0_302/Contents/Home
i: found daemon on port 17051 (6824097 ms old), trying to connect
i: connected to the daemon
i: [ksp] loaded provider(s): [com.memodict.BuilderProcessorProvider]
e: [ksp] java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
I'm wondering is it possible to use docker during KSP? In my workload module I can use docker in the test without any problem
Linux Mint 20.2
IntelliJ IDEA 2021.3 (Community Edition
In build.gradle:
plugins {
id 'java'
id 'org.springframework.boot' version '2.6.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'com.github.tomakehurst:wiremock:2.27.2'
}
test {
useJUnitPlatform()
}
In my project settings:
But when I try to run app I get error:
> Task :compileJava FAILED
Execution failed for task ':compileJava'.
> error: invalid source release: 17
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
You have to make sure that the Gradle version you are using supports Java 17. At the time of writing, the only versions that do this are versions 7.3.+.
You can configure the version under Settings -> Build, Execution, Deployment -> Build Tools -> Gradle. For example, if you use Gradle from the "gradle-wrapper.properties" file, then the distributionUrl in this file should be set to something like
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
You should also set the Gradle JVM to Java 17. Sometimes I found it necessary before executing the build task to run the clean task first, in order to delete all files that might have been compiled with a previous Java version. Also, it might then be necessary to delete the old Gradle configurations (under Edit configurations...) and just create new ones.
Are you running the application from within IntelliJ or are you running it via the terminal. If so, you need to make sure that the appropriate JDK is installed on your computer.
What is the result of the following command in terminal?
java -version
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'
apply plugin: 'base'
gradle tasks
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.
Configure test task
test {
dependsOn bar
}
Error
Could not find method test() for arguments
[build_740ewxgjzod99mmq37aj1jekp$_run_closure17#3e64d862]
on root project 'foo' of type org.gradle.api.Project.
In Gradle doc, it said:
Adds the standard lifecycle tasks and configures reasonable defaults
for the archive tasks:
adds build ConfigurationName tasks. Those tasks assemble the artifacts belonging to the specified configuration.
adds upload ConfigurationName tasks. Those tasks assemble and upload the artifacts belonging to the specified configuration.
configures reasonable default values for all archive tasks (e.g. tasks that inherit from AbstractArchiveTask).
As you can see, there is no test task, you can also verify in the source code:
public void apply(Project project) {
project.getPluginManager().apply(LifecycleBasePlugin.class);
BasePluginConvention convention = new BasePluginConvention(project);
project.getConvention().getPlugins().put("base", convention);
configureBuildConfigurationRule(project);
configureUploadRules(project);
configureUploadArchivesTask();
configureArchiveDefaults(project, convention);
configureConfigurations(project);
configureAssemble((ProjectInternal) project);
}
So, the test task you are looking for is in either 'groovy' (groovy plugin includes java plugin) or 'java' plugin Gradle doc:
> gradle build
:compileJava
:processResources
:classes
:jar
:assemble
:compileTestJava
:processTestResources
:testClasses
:test
:check
:build
BUILD SUCCESSFUL
Total time: 1 secs
Let me know if this makes sense.