3

I am using STS/Eclipse to work on several Gradle projects which I have loaded on my workspace.

Some projects have dependencies on other projects, so I often need to perform Gradle builds into jar files, followed by a Gradle -> Refresh Dependencies and build up my dependency tree. This works fine, although I have noticed that sometimes Gradle will attempt to refresh the dependencies for all the projects in my workspace (even projects which are completely unrelated).

Not only is it bothersome and time-consuming having to wait for gradle to refresh all projects, but it also makes it difficult to debug issues with conflicting dependencies in the cache: Sometimes I want to disable a specific dependency on project A, but it still gets loaded to cache because an unrelated project B also has that dependency.

Is there a way to make gradle refresh the dependencies only for the project(s) I select instead of everything on my workspace?

For reference, I'm using STS version 3.6.3.RELEASE on Eclipse Kepler SR2 (4.3.2) using plugin Gradle IDE 3.6.3.201411271013-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group

4

2 回答 2

1

看来这毕竟是 STS 上的 Gradle 插件的问题。我是如何解决的:

  • 打开的窗口 -> 首选项;选择的 Gradle 菜单

  • 禁用“将罐子重新映射到 maven 项目”和“将罐子重新映射到 Gradle 项目”。

  • 应用的变化。

不确定这是否也是相关/必要的,但我也:

  • 打开外部工具配置菜单(右键单击项目,运行方式 -> 外部工具配置)。

  • 转到“刷新”选项卡并将“完成时刷新资源”选项从“整个工作区”更改为“包含所选资源的项目”并应用更改。

  • 我必须在工作区中的每个项目上手动更改此选项。

现在我可以只对我选择的项目而不是我工作区中的所有项目执行 gradle 构建和刷新依赖项。虽然如果我选择的项目包含缺少依赖项的依赖 jar 文件,这些文件也会被下载到缓存中(这是有道理的)。

在此处找到有关此问题的有用信息:

https://github.com/spring-projects/eclipse-integration-gradle/issues/57

于 2015-09-09T15:52:57.703 回答
0

在这种情况下,您可以使用命令提示符转到文件夹并执行以下命令

gradle build

如果要强制 gradle 再次下载所有库,可以使用 --refresh-dependencies 选项

gradle build --refresh-dependencies

这是 gradle 手册的副本。

--refresh-dependencies 选项告诉 Gradle 忽略已解析模块和工件的所有缓存条目。将对所有配置的存储库执行新的解析,重新计算动态版本,刷新模块并下载工件。

于 2015-09-09T03:15:40.630 回答