Update Gradle plugin to skip processAot when there is no main source and to skip processTestAot when there is no test source
See original GitHub issue@sdeleuze pointed out that https://github.com/mhalbritter/spring-aot-jarsigner-reproducer fails with the following.
> Task :app:processTestAot FAILED
Error: Could not find or load main class org.springframework.test.context.aot.TestAotProcessor
Caused by: java.lang.ClassNotFoundException: org.springframework.test.context.aot.TestAotProcessor
The app
project does not have a dependency on spring-test
(or spring-boot-starter-test
). So that explains why org.springframework.test.context.aot.TestAotProcessor
cannot be found.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
android - Gradle Skip Test - Stack Overflow
Due to official user guide, there are 3 ways to skip some task in gradle. The first 2, are: using predicate and exception...
Read more >Spring Boot Gradle Plugin Reference Guide
It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot ...
Read more >Skipping Tests With Gradle - Baeldung
In this short tutorial, we'll see how to skip tests when using the Gradle build tool.
Read more >Upgrading your build from Gradle 7.x to the latest
The kotlin-gradle-plugin version 1.7.10 changes the type hierarchy of the KotlinCompile task type. It doesn't extend from AbstractCompile anymore.
Read more >Configure your build - Android Developers
The Android build system compiles app resources and source code and ... notes to learn how to update Gradle and the Android Gradle...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, Sam. Skipping
processAot
when the main source set hasn’t output anything andprocessTestAot
when the test source set hasn’t output anything sounds like a good idea to me.The example project does not include any tests.
./gradlew build -x test
succeeds../gradlew build
fails with the aforementioned error../gradlew build -x processTestAot
succeeds.Thus, the issue is that
processTestAot
runs automatically even if there are no tests, and IMO that’s what we should fix.Attempting to build a project that does not include tests should not fail when trying to process non-existent tests for AOT.
The Native Build Tools project ran into similar issues where users complained about native tests failing when the project didn’t contain any tests.
As Stéphane pointed out, this can be particularly cumbersome in multi-module projects (both for Gradle and Maven): some modules may contain tests while others do not.
Related Issues
Summary
I think
processAot
should probably fail with an informative message if the required dependencies are missing.I think
processTestAot
should not run at all if there are no tests. If there are tests and required dependencies are missing,processTestAot
should fail with an informative message.