[英]Eclipse plugin works when debugging but not when installing
I wrote an Eclipse plugin that presents a right click menu option on any file or folder (for example, in navigator view). 我编写了一个Eclipse插件,它在任何文件或文件夹上显示右键菜单选项(例如,在导航器视图中)。 For each file selected (and for each file inside of a selected directory), the plugin computes and displays the MD5, SHA-1, SHA-256, SHA-384, or SHA-512 hash of the file.
对于所选的每个文件(以及所选目录中的每个文件),插件计算并显示文件的MD5,SHA-1,SHA-256,SHA-384或SHA-512哈希值。 The plugin works perfectly when I debug while developing.
当我在开发时调试时,该插件工作正常。
If I make the site using site.xml, put it on my server, and then install to Eclipse (it installs just fine), I see the menu. 如果我使用site.xml创建网站,将它放在我的服务器上,然后安装到Eclipse(它安装得很好),我看到菜单。 I can compute and display the hash for a selected file, but it just won't work for a selected folder.
我可以计算并显示所选文件的哈希值,但它不适用于所选文件夹。 Absolutely nothing has changed in the code;
代码中没有任何变化; it always works in debug mode, and it never works when I install it.
它总是在调试模式下工作,它在我安装它时永远不会起作用。
My question is this: how can I debug this? 我的问题是:我该怎么调试呢? At first, I thought Eclipse's
workspace/.metadata/.log
file would offer some clue, but no error is output. 起初,我认为Eclipse的
workspace/.metadata/.log
文件会提供一些线索,但不会输出错误。 I even went so far as to try adding some code in that writes a file to the desktop, but that file never gets created. 我甚至尝试添加一些将文件写入桌面的代码,但该文件永远不会被创建。 Does anyone have any clue what is going on or how I should go about fixing this?
有没有人知道发生了什么或我应该如何解决这个问题? I've never had such a hard time debugging before!
我以前从来没有遇到过这么难的调试!
For reference, https://github.com/gfairchild/eclipse-hasher is the project. 作为参考, https://github.com/gfairchild/eclipse-hasher是该项目。 All source code is viewable there (it can be imported as an Eclipse project).
所有源代码都可以在那里查看(它可以作为Eclipse项目导入)。
The answer ultimately involved 2 things: 答案最终涉及两件事:
lib
directory during the build process. lib
目录。 The dependency I use (Apache Commons Codec) wasn't included, so of course it wouldn't run. Thanks very much to everyone that offered help! 非常感谢所有提供帮助的人!
这可能是你第一次只测试您的插件在目标平台IFIle
具体延伸和补充IFolder
后,但没有加载的更新插件到Eclipse,因为你并没有增加插件的版本,并没有与运行-clean (Eclipse需要重新加载你的插件)。
You code is assuming that the values in the ExecutionEvent
remain valid until your thread runs which may not be the case. 您的代码假设
ExecutionEvent
中的值保持有效,直到您的线程运行,这可能不是这种情况。 Get everything you need out of the event in the execute
method and pass them to the worker thread. 在
execute
方法中获取事件所需的所有内容,并将它们传递给工作线程。
Also rather than use object instanceof IFile
or IFolder
use: 此外,而不是使用
object instanceof IFile
或IFolder
使用:
IFile file = (IFile)Platform.getAdapterManager().getAdapter(object, IFile.class);
and same for IFolder
. 和
IFolder
。
I see issues in your packaging. 我看到你的包装上有问题。 If you open the jar file via any zip software you can see lib and images folder missing.
如果您通过任何zip软件打开jar文件,您可以看到缺少lib和images文件夹。 You need to add entries these folders in your build.properties file.
您需要在build.properties文件中添加这些文件夹的条目。 Also you need to add the library to the class path (extra classpath entry) If you build the plugin after making these changes it should ideally work.
您还需要将库添加到类路径(额外的类路径条目)如果您在进行这些更改后构建插件,它理想情况下应该工作。
Your question: "My question is this: how can I debug this?" 你的问题:“我的问题是:我该怎么调试呢?”
My answer: "Remote debugging" 我的回答:“远程调试”
You might want to google about that topic, but I encourage you to read the following blog entry , which I always suggest when somebody ask me about how to debug code in the first eclipse installation. 您可能想要谷歌关于该主题,但我鼓励您阅读以下博客条目 ,当有人问我如何在第一次eclipse安装中调试代码时,我总是建议。 Doing that, you could debug your code just in case something were different in the enviroment between your first eclipse installation and the second eclipse instance you are probably using to debug (they could be different depending on your target platform setup and your second instance launch configuration).
这样做,你可以调试你的代码,以防你的第一个eclipse安装和你可能用来调试的第二个eclipse实例之间的环境有所不同(它们可能会有所不同,具体取决于你的目标平台设置和你的第二个实例启动配置)。
note: If your specific issue is a thread related issue as greg pointed out, debugging your code in the first instance installation would be useless, though. 注意:如果您的特定问题是与greg指出的线程相关的问题,那么在第一个实例安装中调试代码将是无用的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.