简体   繁体   English

Eclipse插件在调试时有效,但在安装时无效

[英]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: 答案最终涉及两件事:

  1. I wasn't including the lib directory during the build process. 我在构建过程中没有包含lib目录。 The dependency I use (Apache Commons Codec) wasn't included, so of course it wouldn't run. 我使用的依赖项(Apache Commons Codec)没有包含在内,所以它当然不能运行。
  2. During the testing process, I had tried manually putting a build of Hasher into eclipse/plugins. 在测试过程中,我曾尝试手动将Hasher构建到eclipse / plugins中。 I incorrectly assumed that if I uninstalled Hasher through the Eclipse interface, this file would be removed. 我错误地认为,如果我通过Eclipse界面卸载Hasher,则会删除此文件。 It wasn't. 事实并非如此。 So for the last month, I've had a stale version of Hasher being loaded into Eclipse. 所以在上个月,我已经将一个陈旧版本的Hasher加载到Eclipse中。 That's incredibly frustrating. 这令人非常沮丧。 Oh, well. 那好吧。 Lesson learned. 学过的知识。

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 IFileIFolder使用:

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.

相关问题 Eclipse“Enhanced Class Decompiler”插件调试时不反编译 - Eclipse “Enhanced Class Decompiler” plugin does not decompile when debugging System.getenv()仅在调试IntelliJ插件时正常工作 - System.getenv() only works properly when debugging IntelliJ plugin 在Eclipse中调试时出现问题 - Problem when debugging in eclipse 安装插件时,ADT恢复为标准Eclipse - ADT reverting back to standard Eclipse when installing plugin 安装eclipse的android插件时安装失败。 - installation fail when installing the android plugin for eclipse.. 重新安装和eclipse插件时覆盖jar文件 - Overwrite jar files when re-installing and eclipse plugin 在MyEclipse中安装Windows Azure插件时为WrongFileLengthExeption,在Eclipse Indigo中安装时没有错误。 有什么建议吗? - WrongFileLengthExeption when installing Windows Azure Plugin in MyEclipse, No error when Installing into Eclipse Indigo. Suggestions? Netbeans插件在调试时可以完美地工作,但是在将插件安装到IDE时不能工作 - Netbeans plugin works perfectly while debugging, but not working when the plugin is installed to the IDE 在Eclipse中进行调试时获取MissingResourceException - Getting MissingResourceException when debugging in Eclipse 在安装Eclipse时缺少JRE - JRE Missing when installing eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM