小编dmi*_*ich的帖子

如何让依赖关系克服Java

如何使用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时

java gradle gradle-plugin

2
推荐指数
1
解决办法
2091
查看次数

标签 统计

gradle ×1

gradle-plugin ×1

java ×1