Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean the workspace .metadata folder on product startup

I develop an Eclipse plugin which extends to Eclipse UI, and we deliver it as a whole Eclipse product. The plugin has as a target some automotive projects.

The version of the product can be configured from the project and executing a batch file will launch the proper version of the product.

So the final command will be something like this:

start /B %PRODUCT_PATH%/eclipse.exe -clean -configuration %PATH_TO_PROJECT_CONFIG% -data %PROJECT_PATH

The problem comes when switching from one product version to another, the .metadata folder is corrupted or the information from it is not compatible between products, I am not sure what happens exactly but I get sporadic exceptions at startup.

When I clean the .metadata and launch the product without an existing .metadata folder in the project location, everything runs normally.

Is there an command line option for Eclipse to clean the workspace .metadata before startup?

like image 487
John Doe Avatar asked Mar 05 '18 10:03

John Doe


People also ask

Can I delete .metadata folder?

On a Windows operating systemRight-click on the file. View its Properties. If there is metadata that you would like to remove, select the Details tab. Click Remove Properties and Personal Information.

How do I clean up my Eclipse workspace?

Open Eclipse and navigate to the Window > Preferences. Scroll down the left-hand panel in the Preferences window and click the Remote Systems drop-down root menu. 3. Click the Clear Cached Files button in the File Cache window.

Can I delete Eclipse workspace?

It's possible to remove the workspace in Eclipse without much complications. The options are available under Preferences->General->Startup and Shutdown->Workspaces. Note that this does not actually delete the files from the system, it simply removes it from the list of suggested workspaces. It changes the org.


2 Answers

All (I think!) the Eclipse command line arguments can be found in the Runtime options section of the reference documentation.

I find nothing in that document about removing the .metadatadirectory.

I have also searched for usage of the words "clean", "clear" and "remove", and reference to osgi.instance.area (which and think is the OSGI term for the .metadata directory) and found nothing that seems relevant.

Suggestion 1: clearPersistedState

You could try -clearPersistedState option. Maybe that could help? (I don' really know the purpose of the option, I just found it in the documentation.)

Suggestion 2: Start script

Otherwise maybe you could have a start script which simply runs del to remove the directory.

Suggestion 3: Find the root cause

The best thing to do is of course to find the root cause of the startup problems and solve that. But maybe that is too time consuming or impossible in your case.

like image 174
Lii Avatar answered Oct 14 '22 04:10

Lii


The .metadata folder of the worksapce does not only contain caches but also the local history, the layout of the perspectives with their editors and views, and non-shared launch configurations are stored in the .metadata folder. Therefore deleting the .metadata folder is not a good idea.

Instead of cleaning the whole .metadata folder find the root cause, the files causing the problem and write code that discards or migrates these data to the new format. The Eclipse bug 411602 is an example of such an issue that was caused by not migrated data stored in the .metadata folder.

like image 27
howlger Avatar answered Oct 14 '22 04:10

howlger