Fixing Vanishing LaunchShortcut in Eclipse Plugin - java

I'm developing an eclipse plugin for creating a plugin for another java platform.
I've managed to figure out the LaunchShortcut concept, LaunchDelegate, etc. The basic codepath of the plugin:
I have a launchShortcut display if it detects the project right clicked is a "plugin" project.
This is detected via a propertyTester
Once successful, my launch shortcut runs, which finds an existing launch configuration, or creates a new one if non previously existed.
This launch configuration is then launched via DebugUITools.launch(...)
My LaunchDelegate is thus run, which sets up VMRunnerConfiguration for launching the "application" the plugin is to be loaded with. This is all done so we can easily use the debugger in eclipse against the launched application to test the plugin.
Up until this point, the world is happy and well. You can do this over and over and over again by right click project, go to run/debug, launch the plugin.
However, the SECOND you click the drop down in the Eclipse menu bar for run or debug (you know the list of apps previously run), from this point forward the right click on project no longer works.
The PropertyTester is not even invoked. Digging deep into the LaunchConfigurationManager shows that some how my launchShortcut no longer exists, which is especially strange since the list of shortcuts is only loaded once.
Anyways, I'm at a COMPLETE loss as to what Eclipse is doing here and what I need to do in order to make things happy again.
Any advice/help would be greatly appreciated. Thank you.

For those of you who may hit this problem later.
Apparently, your PropertyTester needs to be able to test java.lang.Object. If you do not do this and you try to test something like IJavaProject, your plugin will fail during the hover of the run drop down as it will not be able to use your property tester on certain objects (duh).
Whats not duh is when this happens, that your shortcut is removed from all possible places it can be used.

Related

Eclipse plugin operation does nothing in normal 2019-12 instance, but works fine in rcp debug instance

I'm trying to debug a problem with the Eclipse plugin at https://github.com/davidmichaelkarr/e4macs . This is a fork of the original application, which is now unfortunately abandonware.
As Eclipse has moved on with further releases, there have been a small number of issues in the plugin. I was able to fix the first problem (shown by my diffs with the base repo), but the next problem that appeared around 2019-09 is a little harder to figure out.
Specifically, the "split-window-vertically" command just does nothing when I execute it. It doesn't matter whether it's bound to a key or executed directly from the "execute extended command" prompt. Nothing appears in the log about this.
So, I downloaded an instance of the RCP 2019-12 distro and set up to debug this. I ran an "Eclipse Application" in debug and tested the function. It worked perfectly fine. This means that somehow something else that I have loaded in my regular 2019-12 installation is making this function not do anything.
From the Marketplace Client, I tried installing some of the same plugins in the debug instance that I have in my regular instance, but I didn't get very far doing this. I tried to install the "Spring IDE", but this gave me many errors. It starts out with "Cannot be completed", and it gave me a long list of "will be uninstalled", "Will be upgraded/downgraded", and "Will not be installed". All of the Spring features were in the latter list. I tried to install the "Groovy" plugin, and that gave me several "Missing requirement" errors.
I don't know whether the missing plugins are what is causing the operation to work, and I can't figure out why I can't install the plugins.
I'm not sure what to do here.
Update:
A comment pointed out that the way to install plugins in a debug instance is to add plugins to the target platform. I proceeded to do that, and discovered that one of the choices for sets of plugins to use is from an existing installation, which is perfect, because that's exactly what I want the debug instance to use, all the plugins in my existing 2019-12 installation.
Unfortunately, doing this has apparently removed my other installed plugins as the source of the problem. I tested the plugin code in this newly edited debug instance, which has all of the same plugins as my regular instance, and the plugin is working perfectly fine. In my regular instance, when I execute the operation in question, nothing happens. No error of any kind, and I don't get the expected result. The operation in question is "split-window-vertically", which should do what it sounds like.
Note that by setting the plugin source to the regular installation, that also included the installed copy of the plugin in question, the Emacs+ plugin (which is installed from the "dropins" directory). I'm not sure exactly what that would do. In any case, I set breakpoints in the plugin code, and when I executed the operation, it did hit the breakpoints.
Note that I also did import the same preferences file into the debug instance that I use in the regular installation, so the preferences are identical, and based on the previous information, the set of installed plugins should be almost identical (I'm not convinced they are exactly identical).
The only other difference between the debug instance and my regular installation is that the regular installation is the "Eclipse IDE for Java Developers" variation from the Eclipse installer, but the debug instance was launched from the "Eclipse for RCP and RAP Developers" variation. I have no idea whether that is significant.
Update:
I added logger calls to the plugin code (using "org.eclipse.equinox.log.Logger", is that the correct logger class to use?). I even added a logger call (and even a println) to the constructor of the operation handler class. None of those were seen in the log file. That tells me that something is wrong with my plugin configuration files, like the "plugin.xml" file.
The "plugin.xml" file is 3928 lines long, so I'm a bit hesitant to just paste it here. I tried opening it in Eclipse, and it doesn't complain about anything.
The following is a screen grab showing the relevant entry:
Note that although the executable operation isn't doing anything, and it seems like the handler isn't being executed, there are some aspects of the operation definition that are being properly loaded into Eclipse, like the description of the operation. Emacs+ provides a "describe-command" function, and I can specify "split-window-vertically" to this command, and it properly returns the description of this command as set in the "plugin.properties" file.
Also note that although this particular operation is not doing anything in this version of Eclipse, there are other functions in Emacs+ that are still working perfectly fine.

Intellij build times are too long. Gradle not helping

I am frustrated by the long build time that IDEA needs before starting my application. I do use DCEVM to enjoy changing code on the fly better than plain hot-swap does, but this doesn't work if I really do need to start my applications multiple times.
IDEA is supposed to be able to have incremental compilation, but I'm not seeing it. I see no options to enable this. Start or starting a debug of the application, takes nearly half a minute. Must it take so long? In theory, IDEA has all the class files already generated, except for the source files that were just edited. IDEA ought to be able to fill in the few blanks, and get the application running almost instantly. What's the hold up, why does it insist it must re-compile every single source file again?
ps. I'm using the Eclipse compiler in IDEA, so that it tolerates some source files not being compilable. I have to do that, because it is one giant tree of java files, where I can not control every one.
Then I saw that perhaps Gradle does have incremental compilation. So I thought to re-create my project, this time with Gradle. I am having a very difficult time figuring out how it works, how it integrates, what tasks are moved from IDEA to Gradle (if any). Even creating a simple skeleton test application with Gradle in IDEA is very frustrating. There are all sorts of fuzzy bits all over the place that leaves you guessing. The tutorials on Jetbrains are almost useless. I can't find one single clear to the point that just explains it in a nutshell how it works. I see some demos that says, click here, and here, and there, but the results on my end aren't the same as what I see outlined.
For instance, Gradle complains that it can't find the junit jar. Ok, so I go into the project settings, and attempt to add the junit jar to the classpath. Under Libraries, I then see an entry to "Gradle: junit:junit:4.11". But there is a second one: "junit-4.11". Why two? Can I delete one? Why is the one so verbal, colon this colon that, etc.
So I add the junit jar files I have to both.
But then in the Gradle Projects window, where I see the hierarchical breakdown of the gradle project setup, verification->test. This is then supposed to run the test class I did manage to create.
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':testCompileClasspath'.
> Could not resolve junit:junit:4.11.
Required by:
xpert_client4:xpert_client4:1.0-SNAPSHOT
> No cached version of junit:junit:4.11 available for offline mode.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
"Could not resolve junit:junit:4.11".
Gradle is extremely frustrating. If all I have to have, is to start a main() in a large project, why would I go through this trouble of using this gradle system that offers things I don't need? Why is it so convoluted, fuzzy, and confusing?
Same goes for an Android project. IDEA can compile and run an Android app without Gradle just fine. Simply avoid anything gradle when setting up, and it just works.
Plus there are all the things that one has to do to speed up the supposedly slow Gradle system. There is the daemon thing. Parallelize, and apparently you can set it in two ways (why). Configure on demand. Globalize. Minimize. minSdkVersion. Offline (oh no, not that Maven thing that pulls down jar files from the internet over and over). jCenter. Profile.... it goes on and on. All those workarounds, hacks, adjustments, tweaks.
Is there anything to be gained by gradle-ifying a working IDEA project? Would I get faster build and startup times if I go through all this trouble? Can I avoid Gradle altogether, and forever (in the hopes that it doesn't somehow becomes mandatory).
I've been coding since the 80s. I've used all sorts of systems. I've build my own build systems. I'm not green here. I also hate having RTFM, if those FMs don't get to the point, and don't explain things well - as if the ones that wrote it, don't really understand it themselves - they know what buttons to press to get it going and that's it.
I find this thing one of the most frustrating things I have seen in a long time. The previous horrible build system I've tried in the past, and have avoided like the plague since, is Maven. The lack of clear thinking with these systems is astounding.
So, aside from these frustrations, what I'm after is: is it worth figuring out Gradle and applying all the workarounds and tweaks, so that I may, once I go through this grief, enjoy faster build and startup times of my application?
Or, would I be better off, avoid Gradle altogether, and instead, do something like place the startup of my application in a loop, so that every time I exit that the application that it re-runs main(). I would then use DCEVM to code on the fly while possible.
Lastly, I forgot to mention. Enabling automatic build in IDEA works really badly. A build seems to always involve re-building every single file, over and over. And setting build to automatic, all it ends up doing is it redoing this in the background over and over. There is nothing that happens in an asynchronous way, where when I finish editing a source file, and start the debug of the application, where IDEA has done any of the building in the background ahead of time, because it redoes the whole thing again after every single tiny little code change. Plus it makes the CPUs spike to near 100% constantly.
IDEA is a great IDE, but the whole compile thing is a total nightmare front to back.
Make sure to disable anti-virus protection in your Gradle caches directory and your IntelliJ project directory. For me, this reduces Java compilation time dramatically, because of all the intermediate files and JARs associated with Java builds. Excluding those same directories from Windows Search indexing can also help.
As of September, 2020, this is the list of default directory locations that should be exluded from virus scanning and Windows search indexing, published here.
Gradle cache: %USERPROFILE%\.gradle
Android Studio projects: %USERPROFILE%\AndroidStudioProjects
Android SDK: %USERPROFILE%\AppData\Local\Android\SDK
Android Studio system files: %USERPROFILE%\.AndroidStudio<version>\system
I published some instructions on my blog for doing this for Windows Defender and Windows Search Indexing, which I'll repost here for completeness:
Windows Defender - How to Exclude a Directory
Open Windows Defender Settings
Click "Virus & threat protection"
Click "Virus & threat protection settings"
Scroll down to "Exclusions" and click "Add or remove exclusions"
Click "Add an exclusion" and select "Folder" from the drop-down menu
Navigate to the directory to be excluded, or paste its path into the "Folder" text-box, and click "Select Folder"
Windows Search Indexing - How to Exclude A Directory
Open Windows Control Panel
Search for "index" and choose "Indexing Options"
Click the "Modify" button
Under the appropriate drive letter, navigate to the folder you want to exclude, and make sure it is unchecked
Double-check your work by verifying the directory shows up in the "Exclude" column of the "Summary of selected locations" table
Even I was facing the same issue and found one option in Intellij IDE, which closely solves my issue, but not fully.
Build Project Automatically and Compile in Parallel
Though it does not solve fully, but I see some performance improvement in build time, whenever I add/upgrade dependency and run the tests.

Non-existing MySql message error

I have to build a Decision Support System, but dont have much experience in Java. So after I connected to MySql with Eclipse (with Connector/J) eclipse started to mess up my other projects. Now, when i try to run other projects in eclipse (that are not related to MySql, ex. Guessing Game) the following error message apperars:
Launch configuration DocsConnectionPropsHelper references non-existing project MySql connection test.
Can anyone help me to resolve this problem please?
UPDATE. it seems that when i press "RUN" elcipse is not running the project that im working with, but other
Your update indicates the issue is actually running the wrong project. To avoid that you may want to close projects you're not working on (right click them in package explorer and select close).
If you do need multiple projects open then when clicking the run icon (which defaults to re-run whatever was ran last among your open projects) make sure you have open in the editor window something that can be ran (and is from the project you want to run).
Then click the drop down arrow to the right of the icon. This will open up a small menu with options to change your build configurations or how it should run your program (i.e. as an application or on a server).
To solve the problem:
-click right botton on the project package you want to work on (run)
-choose Run As
-choose Run Configurations...
-choose DocsConnectionPropsHelper - if in the Project box you see not correct title just remove it. Also remove anything what is in the Main Class box.
-click Apply
-the best option is to close Eclipse and reopen it to make sure that all the settings were configured
It worked for me. Hopefully it will work for you too.

Grails Project Not Compiling Automatically in STS Version 2.9.2

I have a project which has couple of plugins. It has a fairly large amount of classes. The problem is when I tried to save the changes in my code (ie in a controller or gsp file), it doesnt automatically compile. The project by the way is running, but if I change something lets say in the controller or gsp file, it doesnt automatically compile and therefore the changes doesn't take effect. I have to stop the run process first and then run it again so that the changes will take effect. I just encounter this problem recently. I am using SpringSourceToolSuite Version: 2.9.2.RELEASE. I checked the Automatic Build option and it was turned on. Any idea why is this happening and how to solve it?

Handling the export in eclipse thru a plugin

I have a java application that have different settings and dependency versions depending on the company branch it is install in.
So what I did is to create a plugin that create an item in the right click context menu of the project in eclipse to make these changes.
However I am wondering if its possible to catch the OnExport event of eclispe (if it exists) and do this automatically everytime the solution is exported.
Would this be possible?
Many thanks
If I understand what you're asking correctly, the Eclipse way to do this would be to write a Builder and add it to the project; then the settings file would be rebuilt whenever it's appropriate, making an up-to-date version always available to export. Here is a good place to start learning about how to do this.

Categories