简体   繁体   English

使用Gradle在Eclipse中更新外部Jar时出现问题

[英]Problem updating an external jar in eclipse using gradle

I am having trouble deleting an external dependency from my build path. 我无法从构建路径中删除外部依赖项。 I have searched this site and the web but have not found a good answer. 我已经搜索了该站点和网络,但是没有找到一个好的答案。

I use gradle 4.9 and eclipse 4.7.3a to manage my automated tests. 我使用gradle 4.9和eclipse 4.7.3a来管理自动化测试。 I have placed external jars in a folder named artifact in a git project's root directory. 我将外部jar放在git项目的根目录下的名为artifact的文件夹中。

My build.gradle file contains this line in the dependencies section: 我的build.gradle文件在“依赖项”部分包含以下行:

compile fileTree(dir: "./artifact", include: '*.jar')

Well and good, it all works. 很好,一切正常。 However, when I try to delete a dependency using 但是,当我尝试使用删除依赖项时

Build Path > Configure Build Path... > Libraries > Project and External Dependencies all the buttons, including Remove, are grayed out. “构建路径”>“配置构建路径...”>“库”>“项目和外部依赖项”,包括“删除”在内的所有按钮均为灰色。

I can delete the file from the artifact directory and issue 我可以从工件目录中删除文件并发出

gradle cleanEclipse

from the command line but when I open Eclipse and try to open the project (under Project Explorer) I get 'Open Project' has encountered a problem. The project description file (.project) for 'project name' is missing. 从命令行,但是当我打开Eclipse并尝试打开项目(在Project Explorer下)时,出现'Open Project' has encountered a problem. The project description file (.project) for 'project name' is missing. 'Open Project' has encountered a problem. The project description file (.project) for 'project name' is missing.

After replacing the old jar with the new version (different file name of course), I tried running 用新版本(当然是不同的文件名)替换旧的jar之后,我尝试运行

gradle

which is supposed to recreate configuration files deleted by cleanEclipse. 应该重新创建由cleanEclipse删除的配置文件。 No joy. 不开心 Next, I tried running 接下来,我尝试跑步

gradle build

But after restarting eclipse, still a failure. 但是重新启动Eclipse之后,仍然失败。 The only thing that worked was to delete the project from eclipse and then to re-import it. 唯一有效的方法是从eclipse中删除项目,然后重新导入它。

Is there an easier way? 有更容易的方法吗?

Thank you. 谢谢。

Well, I found an answer. 好吧,我找到了答案。

After deleting and copying in the new jar file into the artifact directory, in eclipse, I selected Project > Clean ... 在删除并将新的jar文件中的副本复制到工件目录之后,在eclipse中,我选择了Project > Clean ...

Then I right-clicked on the project and selected Gradle > Refresh Gradle project 然后我右键单击该项目,然后选择Gradle > Refresh Gradle project

I guess writing the question got me thinking about how eclipse handles .project files. 我猜写这个问题让我想到了Eclipse如何处理.project文件。 Maybe this will help the next person. 也许这会帮助下一个人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM