如何使用Java获取当前项目的依赖关系?我在Java类中尝试此代码,但结果为空:
class Example implements Plugin<Project> {
void apply(Project project) {
project.getConfigurations().getByName("runtime").getAllDependencies();
}
}
Run Code Online (Sandbox Code Playgroud)
感谢您的回答JBirdVegas.我尝试在Java上编写你的例子:
List<String> deps = new ArrayList<>();
Configuration configuration = project.getConfigurations().getByName("compile");
for (File file : configuration) {
deps.add(file.toString());
}
Run Code Online (Sandbox Code Playgroud)
但有错误:
Cannot change dependencies of configuration ':compile' after it has been resolved.
Run Code Online (Sandbox Code Playgroud)
当运行gradle build时