After update, old Eclipse plugins remain in \"plugins\" folder (there are also leftovers in \"features\" folder).
Is there a way to remove those automatically?
Instead of sorting, etc. the solutions should be based on the contents of bundles.info
.
Manual solution:
eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
.*plugins/([^,]*),.*
, replace with: $1
(e.g. using Notepad++)eclipse/plugin/
I also want to remove old plugins, but still found no answer today, so I wrote a quick and dirty script guess-old-eclipse-plugins.sh
to handle old plugins.
This script will scan plugins directory under Eclipse directory. and will generate a remove-old-eclipse-plugins.txt
file which can be used to remove old plugins.
This script is tested under Cygwin 1.7.15 on Windows XP.
PluginsDir=plugins
FeaturesDir=features
PluginIDSeparator=_
RemovingScriptFileName=remove-old-eclipse-plugins.txt
rm -rf $RemovingScriptFileName
#for dir in $PluginsDir $FeaturesDir
for dir in $PluginsDir # $FeaturesDir: most file names in features dir contains more than 1 _ character
do
echo "Processing [$dir] directory..."
# split PluginID from filename
# (not reliable, but general working. (ex: will get one junit PluginID because there're move than 1 _ characters in file name))
file_list=$(ls $dir);
echo "$file_list" | cut -f1 -d $PluginIDSeparator > $dir-all.txt
echo "$file_list" | cut -f1 -d $PluginIDSeparator | uniq > $dir-uniq.txt
# get the PluginList which VERY POSSIBLY has old versions
diff_result=$(diff -U 0 $dir-uniq.txt $dir-all.txt)
plugins_which_has_old_versions=$(echo "$diff_result" | grep -e "^+[^+]" | cut -f 2 -d +)
#
for p in $(echo "$plugins_which_has_old_versions")
do
echo "$p"
i=0
for f in $(ls -d -t $dir/$p$PluginIDSeparator*) # use 'ls' command, can sort result by file time, but can not handle file name contains special characters (white space) when using wildcard
#for f in $(find $dir -name "$p$PluginIDSeparator*") # use 'find' command
do
if [ -d $f ]
then
# should use rm -rf
echo -n "[D]"
else
echo -n " "
fi
echo -n "$f"
((i++))
if [ $i -eq 1 ]
then
echo ""
continue # first file, the newest version
fi
echo " [old]"
echo "rm -rf $f" >> $RemovingScriptFileName
done
echo
done
done
Before use the generated remove-old-eclipse-plugins.txt
file to remove plugins, make sure all the listed plugins in it are REALLY old plugins. Because, this script can't handle file name contains more than 1 _
characters. For example: JUnit v3 and v4 plugins are 2 different plugins, but the script will treat it as same plugins because these 2 file names use same org.junit_
prefix.
org.junit
[D]plugins/org.junit_3.8.2.v3_8_2_v20100427-1100
[D]plugins/org.junit_4.8.2.v4_8_2_v20110321-1705 [old] <-- wrong
So, use it VERY CAREFULLY, remove the wrong part before use it, or your Eclipse IDE may not work properly.
$ ./guess-old-eclipse-plugins.sh
Processing [plugins] directory...
org.eclipse.gef
plugins/org.eclipse.gef_3.7.2.v20111106-2020.jar
plugins/org.eclipse.gef_3.6.2.v20110110-2020.jar [old]
org.eclipse.help.base
plugins/org.eclipse.help.base_3.6.2.v201202080800.jar
plugins/org.eclipse.help.base_3.5.3.v201102101200.jar [old]
org.eclipse.help.ui
plugins/org.eclipse.help.ui_3.5.101.r37_20110819.jar
plugins/org.eclipse.help.ui_3.5.3.r36_20101116.jar [old]
...
rm -rf plugins/org.eclipse.gef_3.6.2.v20110110-2020.jar
rm -rf plugins/org.eclipse.help.base_3.5.3.v201102101200.jar
rm -rf plugins/org.eclipse.help.ui_3.5.3.r36_20101116.jar
rm -rf plugins/org.eclipse.help.webapp_3.5.3.r36_20101130.jar
rm -rf plugins/org.eclipse.jdt.apt.core_3.3.402.R36_v20110120-1000.jar
rm -rf plugins/org.eclipse.jdt.debug.ui_3.5.2.v20100928a_r362.jar
To get rid of the old plugins you have to clear the Installation History. Go to Help | About Eclipse | Installation Details | Installation History and select all the old stuff. Then click delete and restart. Voila. This works with Eclipse Helios (3.6)
Removing old plugins is always a hassle. Especially when you upgrade and your Eclipse just doesn't want to start again and you need to figure it out via the metadata hell of plugins dependencies.
I've seen that couple of you tried to fix this via a script.
Well I have created a java based tool (with tests, build by maven & hosted at github, so you are free to fork it) that checks for duplicities of plugins by introspecting manifest files (or file names if the manifest is incomplete or corrupted).
you can quite easily for example download the latest Eclipse and put your old Eclipse into dropins/eclipse
folder and the tool will clean up the dropins folder - thus your new bundles are preserved and old one are deleted (The dropins
folder is prefered for deletion if 2 or more same versions are found).
More information about the Eclipse Plugin Cleaner can be found at https://github.com/azachar/eclipse-plugin-cleaner
For me this works:
eclipse -application org.eclipse.equinox.p2.garbagecollector.application -profile SDKProfile
Tested Eclipse v4.9. Removes old version of my plugins.
The profile epp.package.jee
mentioned in other solutions returns "not existing" for me.
For STM32CubeIDE, a popular Eclipse-based IDE for the STM32 microcontroller-family, this command did clean-up old plugin versions under Windows 10:
"C:\ST\STM32CubeIDE_1.3.0\STM32CubeIDE\eclipsec" -application org.eclipse.equinox.p2.garbagecollector.application -profile STM32CubeIDE