Search code examples
spring-bootkotlinintellij-idea

Trigger ./gradlew test when files have changed


I am building a Spring Boot REST API application and using Kotlin as the language. For the development I am using IntellJ as the IDE.

The project structure looks as follows:

enter image description here

Is there a way to watch changes in the folder src to trigger the gradle task ./gradlew test after files have been changed?


Solution

  • You can use Gradle's support for continuous builds:

    ./gradlew test --continuous
    

    This will cause Gradle to watch the filesystem for changes and execute the test task and any tasks upon which it depends whenever a change is detected.