0

Hello I have a issue with Gradle and IntelliJ that appeared from nowhere. Everything was working but one day it stop to work. I am talking about any interaction with Gradle in IntelliJ. I have Spring Boot app, Gradle 6.7. When there is no .gradle directory in the root, everything works. If the directory is present I gets

Main class name has not been configured and it could not be resolved

for gradle build or

Test events were not received

for gradle test. If I delete .gradle directory one gradle task is completed fine and the some goes again and again. If I try to run test by IntelliJ runner with .gradle directory present I get

No tests were found

I noticed that after first build, build directory contains everything as expected. But when I run another task, build directory emptied somehow and I believe that the absence of compiled sources leads to the errors.

I have no vintage-engine on classpath, only jupiter for junit tests.

I tried to clear gradle cache, invalidate IntelliJ caches, both in the same time, reinstall IntelliJ with by older version, uninstall IntelliJ completely and install new one. Nothing helped.

Does anybody has an idea how to solve it?

Thanks

UPDATE:

build.gradle on what I am able to reproduce the issue:

plugins {
    id 'org.springframework.boot' version '2.5.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
    useJUnitPlatform()
}

I found that the file which is causing the behavior is executionHistory.bin. If the file is present, it ruins a build.

Majlanky
  • 198
  • 2
  • 9
  • please provide your build.gradle file. I've had this same issue myself when I did not supply gradle to use junit 5. It might have to do with the fact that you are no longer using intellij to run tests, but gradle – p.streef Jul 15 '21 at 20:37
  • There is not problem only with tests. Lets put the tests aside and focus on repeated build. If I run build and no .gradle dir is present, everything goes well. One more build with .gradle present and I get "Main class name has not been configured and it could not be resolved". – Majlanky Jul 15 '21 at 20:55
  • how do you build? Are you using gradle wrapper? Are you building using intellij or gradle directly? Are you running custom tasks? Are there any conflicts in inputs/outputs of those tasks? Please post your build.gradle. If you are building using intellij I suggest to see what happens if you build/test with gradle directly to pinpoint the issue. if you add --scan you might get some useful insight from the buildscan (it's posted to a public server but with a private link and you can delete the build scan when you're done) – p.streef Jul 16 '21 at 06:23
  • I can not post build.gradle because it contains information about commertial project. I am building by Gradle. There are no conflicts or errors during the clean build. We can put aside IntelliJ too as the issue is reproducible from console and I tried to install gradle and it instead of gradlew. Still the same issue. – Majlanky Jul 16 '21 at 07:19
  • then it's quite likely that it's an issue in your gradle code/config. So without the build.gradle (maybe you can obfuscate it?) it's hard to go on from here. – p.streef Jul 16 '21 at 07:28
  • I created whole new project on Initilizr and it behave the same way... I attached the build.gradle to the post... – Majlanky Jul 16 '21 at 08:27
  • please create an issue in the YouTrack: https://youtrack.jetbrains.com/issues/IDEA and attach the sample project to reproduce the case to it. Thank you – Olga Klisho Jul 16 '21 at 08:35
  • I found out that it is not IntelliJ IDEA issues. I can reproduce the issues simply from console by twice executed command `./gradlew assemble` – Majlanky Jul 16 '21 at 08:40
  • I just did the same with the same versions as in your build.gradle (demo from spring initializer). It works fine, so it is likely related to your environment. – p.streef Jul 16 '21 at 14:04
  • Thanks for the test! Really! Do you have an idea what can be wrong on my environment? I tries change everything from JVM to Gradle and erase every cache I know about. – Majlanky Jul 16 '21 at 15:23

2 Answers2

1

I spend many hours to find the origin of my troubles. It comes out that Gradle is not working properly on exFAT. exFAT is file system I am using on my encrypted partition. When I moved the project to NTSC file system, everything works as expected...

Majlanky
  • 198
  • 2
  • 9
0

It's a bit of a wild guess from what you have provided, but perhaps you are missing

tasks.withType(Test) {
    useJUnitPlatform()
}

in your build gradle

p.streef
  • 3,652
  • 3
  • 26
  • 50
  • Unfortunatelly this not help (I tried it). I have already useJUnitPlatform() in test which is just different style for the same thing. – Majlanky Jul 15 '21 at 20:56