复现步骤:
package test;
public class Test {
public static void main(String[] args) {
}
}
Run Code Online (Sandbox Code Playgroud)
通常我希望我可以,System.out.printLn("Hello World")但是这次,无论是新项目,我都会收到以下错误:
2:34:23 PM: Executing task 'Test.main()'...
Executing tasks: [Test.main()] in project C:\Users\regan\Desktop\events\MyApplication
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\regan\AppData\Local\Temp\Test_main__2.gradle' line: 20
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:Test.main()'.
> SourceSet with name 'test' not found.
* Try:
Run with …Run Code Online (Sandbox Code Playgroud) 我正在为 Android Studio 开发一个 gradle 插件。这是我的问题如何使用 Gradle API 获取 Android Studio 主 SourceSet?
我想用java源目录做一些复制的东西。在问这个问题之前,我发现了一些有用但不起作用的东西。
SourceSet main = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME)
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息
Caused by: org.gradle.api.UnknownDomainObjectException: SourceSet with name 'main' not found.