简体   繁体   中英

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). 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. 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. 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. 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. All source code is viewable there (it can be imported as an Eclipse project).


The answer ultimately involved 2 things:

  1. I wasn't including the lib directory during the build process. The dependency I use (Apache Commons Codec) wasn't included, so of course it wouldn't run.
  2. During the testing process, I had tried manually putting a build of Hasher into eclipse/plugins. I incorrectly assumed that if I uninstalled Hasher through the Eclipse interface, this file would be removed. It wasn't. So for the last month, I've had a stale version of Hasher being loaded into 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. Get everything you need out of the event in the execute method and pass them to the worker thread.

Also rather than use object instanceof IFile or IFolder use:

IFile file = (IFile)Platform.getAdapterManager().getAdapter(object, IFile.class);

and same for 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. You need to add entries these folders in your build.properties file. 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. 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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