fail to run the specific class or method in the IDE with some error in the gradle project
已回答


There are some errors in the FlowerBox.java, but it isn't in the same package with application.java. Application.java is fine, but when I try to run it, it seems like fails to compile, why was that? How to run this specific class?
I have uploaded the project and the log. Upload id: 2023_07_18_sUkMKeR7EHienyky7SyzuP (files: idea-logs-20230718-19001411725644664595873310.zip, lab08.zip)
请先登录再写评论。
Hello!
This is a Gradle-based Project and Gradle works on the basis of Source Sets.
In this Project Application class and FlowerBox class belong to the same Source Set (main), so Gradle builds them together.
If you want to run Application class only you can create a new Source Set by adding this to build.gradle:
Make sure to click "Load Gradle Changes" pop-up once you have modified build.gradle
Create a new directory for it by right-clicking on src (New -> Directory) IDEA will suggest myNewSourceSet\java automatically.
Copy ticketingsystem directory to the myNewSourceSet\java using Copy/Paste actions available from the right-click menu in the Project Tool Window.
You should be able to run Application class from the newly-created Source Set.
Hope this helps!
P. S.: You can also exclude parts from the main Source Set as shown here, but this may compromise your Project's consistency, so, in my opinion, it's better to create a standalone Source Set for testing and/or running isolated parts the code.